diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-19 11:27:24 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-23 14:49:04 -0700 |
commit | 9cfd1d44915f4615bbb760198cd01bf4dfc69f5a (patch) | |
tree | 654db57da836f7a5d6cb96f80e8e29b48682128d /railties | |
parent | f2aea4d3eac467b85a63593ba7e2de28b2a2eb0a (diff) | |
download | rails-9cfd1d44915f4615bbb760198cd01bf4dfc69f5a.tar.gz rails-9cfd1d44915f4615bbb760198cd01bf4dfc69f5a.tar.bz2 rails-9cfd1d44915f4615bbb760198cd01bf4dfc69f5a.zip |
Get more tests to pass
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/initializer.rb | 73 | ||||
-rw-r--r-- | railties/test/generator_lookup_test.rb | 8 |
2 files changed, 76 insertions, 5 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index b2dfb6c970..3adc3b9ce5 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -1,10 +1,12 @@ +require "pathname" + module Rails class Configuration attr_accessor :cache_classes, :load_paths, :eager_load_paths, :framework_paths, :load_once_paths, :gems_dependencies_loaded, :after_initialize_blocks, :frameworks, :framework_root_path, :root_path, :plugin_paths, :plugins, :plugin_loader, :plugin_locators, :gems, :loaded_plugins, :reload_plugins, - :i18n + :i18n, :gems def initialize @framework_paths = [] @@ -68,6 +70,21 @@ module Rails i18n end + # Adds a single Gem dependency to the rails application. By default, it will require + # the library with the same name as the gem. Use :lib to specify a different name. + # + # # gem 'aws-s3', '>= 0.4.0' + # # require 'aws/s3' + # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ + # :source => "http://code.whytheluckystiff.net" + # + # To require a library be installed, but not attempt to load it, pass :lib => false + # + # config.gem 'qrp', :version => '0.4.1', :lib => false + def gem(name, options = {}) + @gems << Rails::GemDependency.new(name, options) + end + def default_gems [] end @@ -656,11 +673,63 @@ end # TODO: w0t? module Rails class << self + # The Configuration instance used to configure the Rails environment + def configuration + @@configuration + end + + def configuration=(configuration) + @@configuration = configuration + end + + def initialized? + @initialized || false + end + + def initialized=(initialized) + @initialized ||= initialized + end + + def logger + if defined?(RAILS_DEFAULT_LOGGER) + RAILS_DEFAULT_LOGGER + else + nil + end + end + + def backtrace_cleaner + @@backtrace_cleaner ||= begin + # Relies on ActiveSupport, so we have to lazy load to postpone definition until AS has been loaded + require 'rails/backtrace_cleaner' + Rails::BacktraceCleaner.new + end + end + def root Pathname.new(RAILS_ROOT) if defined?(RAILS_ROOT) end - end + def env + @_env ||= ActiveSupport::StringInquirer.new(RAILS_ENV) + end + + def cache + RAILS_CACHE + end + + def version + VERSION::STRING + end + + def public_path + @@public_path ||= self.root ? File.join(self.root, "public") : "public" + end + + def public_path=(path) + @@public_path = path + end + end class OrderedOptions < Array #:nodoc: def []=(key, value) key = key.to_sym diff --git a/railties/test/generator_lookup_test.rb b/railties/test/generator_lookup_test.rb index b650f304ed..b67087e5ea 100644 --- a/railties/test/generator_lookup_test.rb +++ b/railties/test/generator_lookup_test.rb @@ -7,9 +7,11 @@ class GeneratorLookupTest < Test::Unit::TestCase # We need to add our testing plugin directory to the plugin paths so # the locator knows where to look for our plugins @configuration.plugin_paths += @fixture_dirs.map{|fd| plugin_fixture_path(fd)} - @initializer = Rails::Initializer.new(@configuration) - @initializer.add_plugin_load_paths - @initializer.load_plugins + @initializer = Rails::Initializer.default + @initializer.config = @configuration + @initializer.run(:add_plugin_load_paths) + @initializer.run(:load_plugins) + @initializer.run(:set_root_path) load 'rails_generator.rb' require 'rails_generator/scripts' end |