Changeset 1044
- Timestamp:
- 11/24/07 14:47:17 (1 year ago)
- Files:
-
- trunk/app_generators/merb/templates/config/merb.yml (modified) (1 diff)
- trunk/lib/merb/core_ext/kernel.rb (modified) (2 diffs)
- trunk/lib/merb/server.rb (modified) (4 diffs)
- trunk/spec/fixtures/config/environments (added)
- trunk/spec/fixtures/config/environments/environment_config_test.yml (added)
- trunk/spec/merb/server_spec.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app_generators/merb/templates/config/merb.yml
r1039 r1044 67 67 # set this to the layout template (or :none) that you want to use by default 68 68 #:exception_layout: :none 69 69 70 # You can override settings for specific environments by creating a yaml 71 # file for that environment in config/environments. For example, to 72 # change the configuration only for development create 73 # config/environments/development.yml trunk/lib/merb/core_ext/kernel.rb
r856 r1044 1 1 module Kernel 2 # Example:3 # acquire 'foo/bar/*'4 # requires all files inside foo/bar - recursive5 # can take multiple parameters6 def acquire(*files)7 files.each do |file|8 require file if %w(rb so).any?{|f| File.file?("#{file}.#{f}")}9 $:.each do |path|10 Dir[File.join(path, file, '*.rb')].each do |file|11 require file12 end13 end14 end15 end16 2 17 3 # does a basic require, and prints the message passed as an optional … … 126 112 # Extracts an options hash if it is the last item in the args array 127 113 def extract_options_from_args!(args) 128 args.pop if args.last.is_a?( Hash )114 args.pop if Hash === args.last 129 115 end 130 116 trunk/lib/merb/server.rb
r1039 r1044 29 29 $LOAD_PATH.unshift( "#{defaults[:merb_root]}/framework" ) 30 30 end 31 merb_yml = "#{defaults[:merb_root]}/config/merb.yml" 32 if File.exists?(merb_yml) 31 global_merb_yml = "#{defaults[:merb_root]}/config/merb.yml" 32 apply_configuration_from_file defaults, global_merb_yml 33 end 34 35 def apply_configuration_from_file(configuration, file) 36 if File.exists?(file) 33 37 require 'merb/erubis_ext' 34 defaults.merge(Erubis.load_yaml_file(merb_yml))38 configuration.merge(Erubis.load_yaml_file(file)) 35 39 else 36 defaults40 configuration 37 41 end 38 42 end … … 44 48 class << self 45 49 46 def merb_config 50 def merb_config(argv = ARGV) 47 51 options = Merb::Config.setup 48 52 … … 155 159 156 160 # Special case of looking for help 157 if ARGV== ["-h"]161 if argv == ["-h"] 158 162 puts opts 159 163 exit 160 164 end 161 opts.parse!( @@merb_raw_opts)165 opts.parse!(argv) 162 166 # merb <argument> is same as merb -g <argument> 163 if ARGV.size == 1164 options[:generate] = File.expand_path( ARGV.last)167 if argv.size == 1 168 options[:generate] = File.expand_path(argv.last) 165 169 end 166 170 … … 193 197 options[:environment] = 'development' 194 198 end 199 200 201 environment_merb_yml = "#{options[:merb_root]}/config/environments/#{options[:environment]}.yml" 202 options = Merb::Config.apply_configuration_from_file options, environment_merb_yml 195 203 196 204 @@merb_opts = options
