diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-11-02 03:52:15 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-11-02 03:52:15 +0530 |
commit | 1147453fce0890ea229c3af5f43c909ebe53061e (patch) | |
tree | 221d816ef0c908044fd6029950ccad064866ab8f /railties/lib | |
parent | a3aa0c17ef8594a0084511f4852be7b5dc66e5e2 (diff) | |
parent | 5a02f0bccf55191c2cfbcc69bd8165df6d7a2012 (diff) | |
download | rails-1147453fce0890ea229c3af5f43c909ebe53061e.tar.gz rails-1147453fce0890ea229c3af5f43c909ebe53061e.tar.bz2 rails-1147453fce0890ea229c3af5f43c909ebe53061e.zip |
Merge commit 'mainstream/master'
Conflicts:
railties/doc/guides/html/layouts_and_rendering.html
railties/doc/guides/source/active_record_basics.txt
railties/doc/guides/source/layouts_and_rendering.txt
Diffstat (limited to 'railties/lib')
7 files changed, 43 insertions, 26 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 6500b2d309..e3a0e3bad1 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -267,6 +267,7 @@ module Rails end def add_gem_load_paths + Rails::GemDependency.add_frozen_gem_path unless @configuration.gems.empty? require "rubygems" @configuration.gems.each { |gem| gem.add_load_paths } diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 46d5fd3a47..cd280ac023 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -18,11 +18,14 @@ module Rails def self.add_frozen_gem_path @@paths_loaded ||= begin - Gem.source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) + source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) + Gem.clear_paths + Gem.source_index = source_index # loaded before us - we can't change them, so mark them Gem.loaded_specs.each do |name, spec| @@framework_gems[name] = spec end + true end end @@ -170,19 +173,27 @@ module Rails exact_dep = Gem::Dependency.new(name, "= #{specification.version}") matches = real_gems.search(exact_dep) installed_spec = matches.first - if installed_spec - # we have a real copy - # get a fresh spec - matches should only have one element - # note that there is no reliable method to check that the loaded - # spec is the same as the copy from real_gems - Gem.activate changes - # some of the fields - real_spec = Gem::Specification.load(matches.first.loaded_from) - write_spec(directory, real_spec) - puts "Reloaded specification for #{name} from installed gems." + if File.exist?(File.dirname(spec_filename(directory))) + if installed_spec + # we have a real copy + # get a fresh spec - matches should only have one element + # note that there is no reliable method to check that the loaded + # spec is the same as the copy from real_gems - Gem.activate changes + # some of the fields + real_spec = Gem::Specification.load(matches.first.loaded_from) + write_spec(directory, real_spec) + puts "Reloaded specification for #{name} from installed gems." + else + # the gem isn't installed locally - write out our current specs + write_spec(directory, specification) + puts "Gem #{name} not loaded locally - writing out current spec." + end else - # the gem isn't installed locally - write out our current specs - write_spec(directory, specification) - puts "Gem #{name} not loaded locally - writing out current spec." + if framework_gem? + puts "Gem directory for #{name} not found - check if it's loading before rails." + else + puts "Something bad is going on - gem directory not found for #{name}." + end end end diff --git a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb index 615c575e6e..6826998252 100644 --- a/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +++ b/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb @@ -16,16 +16,16 @@ class PluginGenerator < Rails::Generator::NamedBase m.directory "#{plugin_path}/tasks" m.directory "#{plugin_path}/test" - m.template 'README', "#{plugin_path}/README" - m.template 'MIT-LICENSE', "#{plugin_path}/MIT-LICENSE" - m.template 'Rakefile', "#{plugin_path}/Rakefile" - m.template 'init.rb', "#{plugin_path}/init.rb" - m.template 'install.rb', "#{plugin_path}/install.rb" - m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb" - m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" - m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake" - m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" - + m.template 'README', "#{plugin_path}/README" + m.template 'MIT-LICENSE', "#{plugin_path}/MIT-LICENSE" + m.template 'Rakefile', "#{plugin_path}/Rakefile" + m.template 'init.rb', "#{plugin_path}/init.rb" + m.template 'install.rb', "#{plugin_path}/install.rb" + m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb" + m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb" + m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake" + m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb" + m.template 'test_helper.rb', "#{plugin_path}/test/test_helper.rb" if @with_generator m.directory "#{plugin_path}/generators" m.directory "#{plugin_path}/generators/#{file_name}" diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile b/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile index 1824fb10fe..85e8ff1834 100644 --- a/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +++ b/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile @@ -8,6 +8,7 @@ task :default => :test desc 'Test the <%= file_name %> plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' + t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb b/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb new file mode 100644 index 0000000000..cf148b8b47 --- /dev/null +++ b/railties/lib/rails_generator/generators/components/plugin/templates/test_helper.rb @@ -0,0 +1,3 @@ +require 'rubygems' +require 'active_support' +require 'active_support/test_case'
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb index 6ede6ef1d2..3e0bc29d3a 100644 --- a/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +++ b/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb @@ -1,6 +1,6 @@ -require 'test/unit' +require 'test_helper' -class <%= class_name %>Test < Test::Unit::TestCase +class <%= class_name %>Test < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake index e2cb4b9577..754e3ba5c9 100644 --- a/railties/lib/tasks/gems.rake +++ b/railties/lib/tasks/gems.rake @@ -6,10 +6,11 @@ task :gems => 'gems:base' do puts puts "I = Installed" puts "F = Frozen" + puts "R = Framework (loaded before rails starts)" end def print_gem_status(gem, indent=1) - code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " " + code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " " puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}" gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded? end |