Sha256: 2e75b56fe2353fa22587a1cba0d1c8dd0b8c6e14808c469ecc75ac5d765f4e2d
Contents?: true
Size: 1.26 KB
Versions: 4
Compression:
Stored size: 1.26 KB
Contents
module Crystal class Config attr_accessor :host, :port, :environment, :server, :static, :root %w{show_exceptions static}.each do |m| iv = "@#{m}" define_method("#{m}?"){!!instance_variable_get(iv)} end def initialize { :host => '0.0.0.0', :port => 4000, :environment => 'development', :server => 'Mongrel', :static => true }.each{|k, v| self.send "#{k}=", v if self.send(k).nil?} end def development?; environment == 'development' end def production?; environment == 'production' end def test?; environment == 'test' end def rack_config_file File.should! :exist?, "config.ru" "config.ru" end def root @root.should_not! :be_nil end def apply_command_line_arguments! require 'optparse' case ARGV.first when "p" then self.environment = "production" when "d" then self.environment = "development" when "t" then self.environment = "test" end OptionParser.new{|op| op.on('-e env'){|val| self.environment = val} op.on('-s server'){|val| self.server = val} op.on('-p port'){|val| self.port = val.to_i} }.parse!(ARGV.dup) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
crystal-0.0.8 | crystal/lib/crystal/config.rb |
crystal-0.0.7 | crystal/lib/crystal/config.rb |
crystal-0.0.6 | crystal/lib/crystal/config.rb |
crystal-0.0.5 | lib/crystal/config.rb |