adding directory location to my file output script

Discussion in 'Ruby' started by crossanpdx, Oct 10, 2012.

  1. crossanpdx

    crossanpdx Guest

    Below is my script which create me a html file called pickle.html and then when ran again, it checks if exists and if so appends to the file and creates new one.

    I need to tell the script where I want to the html file to go to.

    I run this from the working directory and in the same directory is a folder called 'logs' so I would like all the pickle.html files to go to logs.

    Suggestions? and Thank you much in advance!

    require 'date'

    file, new_file = 'pickle.html','%s')

    if File.exists?('file')
    File.rename('file', "pickle_#{new_file}.html")

    command = %Q(cucumber --format 'Timestamped::HtmlFormatter' --out #{file})

    exec command
    crossanpdx, Oct 10, 2012
    1. Advertisements

  2. How about:

    file, new_file = 'logs/pickle.html','%s')
    Why are you enclosing file in quotation marks? That's a string
    literal, not a variable name.
    File.rename(file, "logs/pickle_#{new_file}.html")

    [snip rest]
    Charles Calvert, Oct 11, 2012
    1. Advertisements

  3. crossanpdx

    Ryan Crossan Guest


    Thank you much for the tips and suggestions. It is working just like I need it to now.

    I appreciate it.

    - Ryan

    Ryan Crossan, Oct 11, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.