SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding this sed command to the deploy script

    Hello,

    I have a small section of sed code I would like to add to the deploy.rb script.

    The code changes the image paths of our stylesheets

    for file in *; do
    sed -e 's/\/images/http:\/\/cache\.reverbnation\.com\/images/g' "$file" > "${file}.sub"
    rm "$file"
    mv "${file}.sub" "${file}"
    done

    I am a newbie at writing and testing rake tasks and would like to know what the best way to test this before it goes live?

    Thanks,
    Clem C Rock

  2. #2
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the "problem" is that you are writing all that as a bash script (or whatever language it is) as opposed to pure ruby. I guess the best way would be to wrap that functionality in an external class and use Test/Unit to write tests. Use setup / teardown to setup some css files for each test, run the operations, and check the output.
    Ohai!

  3. #3
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    clem:

    In your deploy.rb script, add a capistrano after_hook: (i suggest :after_update_code or :after_sym_link)
    Code:
      cmd_to_execute = 'for file in *; do
    sed -e 's/\/images/http:\/\/cache\.reverbnation\.com\/images/g' "$file" > "${file}.sub"
    rm  "${file}"
    mv "${file}.sub" "${file}"
    done'
      run cmd_to_execute
    If you give someone a program,
    you will frustrate them for a day;
    if you teach them how to program,
    you will frustrate them for a lifetime.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •