Rails deployment has been solved

Everyone knows that Rails deployment is a massive pain, right? Wrong. It’s time we all erased this outdated notion from our heads.

I just installed Redmine on my server, and it was simple. Thanks to mod_rails, the sum total of web server configuration needed was this:


<VirtualHost *:80>
  ServerName  dev.redcaride.com
  DocumentRoot /home/dbl/redmine/public

  <Directory "/home/dbl/redmine/public">
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
  </Directory>
</VirtualHost>

No mongrels, no proxy_balancers, no FCGI (shudder). This was actually easier than when I installed WordPress on the same server last week.

So never again be put off a Rails application because you’re scared of deploying it! The world of open-source Rails applications opens up before you….

Regex Replacer

Here is a little Ruby library that may be useful to you. It is a regular expression string replacing tool. It’s similar to what you can do with String#gsub in Ruby, but with a few more features.

I needed this library to get Textmate snippets working in Redcar, and therefore it uses a slightly different syntax to gsub (”$1″ instead of “\1″). Here are some examples:


rr = RegexReplace.new(/nuclear (\w+)/,
                      "solar $1")
rr.rep("nuclear nutcracker")
=> "solar nutcracker"

So far so obvious. That’s identical to Ruby gsub but with “\1″ changed to “$1″. Here’s something more useful:


rr = RegexReplace.new(/nuclear (\w+)/,
                      "solar \\u$1")
rr.rep("nuclear nutcracker")
=> "solar Nutcracker"

Whee! Letters following “\u” are upcased. What else can it do?

Upcase stretches with \U…\E


rr = RegexReplace.new(/nuclear (\w+)/,
                      "solar \\U$1\\E")
rr.rep("nuclear nutcracker")
=> "solar NUTCRACKER"

You can downcase in exactly the same way with “\l” and “\L..\E”.

Conditional replacement with (?1:then:else)


rr = RegexReplace.new(/nuclear( \w+)?/,
                      "solar(?1:$1: thingy)")
rr.rep("nuclear nutcracker")
=> "solar nutcracker"
rr.rep("nuclear")
=> "solar thingy"

You can also combine the operators in this fashion “\l\U…\E” to get (for instance) “fOO” from “foo”.

If you find it useful please let me know.

  • About

    Daniel Lucraft, London, UK. Interested in Ruby, Prolog and software.