Created
February 24, 2012 23:31
-
-
Save seanbehan/1904572 to your computer and use it in GitHub Desktop.
Misc Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ERB YAML Template | |
| def database_configuration | |
| require 'erb' | |
| YAML::load(ERB.new(IO.read(paths["config/database"].first)).result) | |
| end | |
| # HEREDOC Syntax | |
| TEMPLATE = <<-HTML # :nodoc: | |
| <!DOCTYPE html> | |
| <html> | |
| <head></head> | |
| </html> | |
| HTML | |
| # Option Parser | |
| require 'optparse' | |
| OptionParser.new { |op| | |
| op.on('-p port', 'set the port (default is 4567)') { |val| set :port, Integer(val) } | |
| op.on('-o addr', 'set the host (default is 0.0.0.0)') { |val| set :bind, val } | |
| op.on('-e env', 'set the environment (default is development)') { |val| set :environment, val.to_sym } | |
| op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val } | |
| op.on('-x', 'turn on the mutex lock (default is off)') { set :lock, true } | |
| }.parse!(ARGV.dup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment