rails 2.2.2 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +274 -189
- data/MIT-LICENSE +1 -1
- data/README +6 -19
- data/Rakefile +24 -71
- data/bin/rails +1 -0
- data/builtin/rails_info/rails/info.rb +12 -8
- data/configs/databases/mysql.yml +3 -0
- data/configs/initializers/backtrace_silencers.rb +7 -0
- data/configs/initializers/new_rails_defaults.rb +2 -0
- data/configs/initializers/session_store.rb +15 -0
- data/dispatches/config.ru +7 -0
- data/doc/README_FOR_APP +2 -5
- data/environments/boot.rb +1 -0
- data/environments/environment.rb +14 -48
- data/environments/production.rb +11 -7
- data/environments/test.rb +6 -0
- data/helpers/application_controller.rb +10 -0
- data/helpers/test_helper.rb +1 -1
- data/html/500.html +0 -3
- data/html/index.html +1 -0
- data/lib/commands/about.rb +1 -1
- data/lib/commands/dbconsole.rb +18 -2
- data/lib/commands/plugin.rb +4 -3
- data/lib/commands/runner.rb +13 -7
- data/lib/commands/server.rb +98 -33
- data/lib/console_app.rb +4 -4
- data/lib/console_with_helpers.rb +2 -23
- data/lib/dispatcher.rb +1 -1
- data/lib/fcgi_handler.rb +12 -10
- data/lib/initializer.rb +108 -41
- data/lib/rails/backtrace_cleaner.rb +54 -0
- data/lib/rails/gem_dependency.rb +124 -93
- data/lib/rails/plugin.rb +49 -6
- data/lib/rails/plugin/loader.rb +66 -27
- data/lib/rails/plugin/locator.rb +1 -1
- data/lib/rails/rack.rb +3 -1
- data/lib/rails/rack/debugger.rb +21 -0
- data/lib/rails/rack/log_tailer.rb +35 -0
- data/lib/rails/rack/metal.rb +51 -0
- data/lib/rails/rack/static.rb +15 -4
- data/lib/rails/version.rb +1 -1
- data/lib/rails_generator/base.rb +3 -0
- data/lib/rails_generator/commands.rb +8 -3
- data/lib/rails_generator/generators/applications/app/app_generator.rb +210 -136
- data/lib/rails_generator/generators/applications/app/scm/git.rb +16 -0
- data/lib/rails_generator/generators/applications/app/scm/scm.rb +8 -0
- data/lib/rails_generator/generators/applications/app/scm/svn.rb +7 -0
- data/lib/rails_generator/generators/applications/app/template_runner.rb +401 -0
- data/lib/rails_generator/generators/components/controller/USAGE +12 -11
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +7 -1
- data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/helper/USAGE +24 -0
- data/lib/rails_generator/generators/components/helper/helper_generator.rb +25 -0
- data/lib/rails_generator/generators/components/helper/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/metal/USAGE +8 -0
- data/lib/rails_generator/generators/components/metal/metal_generator.rb +8 -0
- data/lib/rails_generator/generators/components/metal/templates/metal.rb +12 -0
- data/lib/rails_generator/generators/components/resource/USAGE +2 -2
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +4 -4
- data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +1 -1
- data/lib/rails_generator/secret_key_generator.rb +2 -0
- data/lib/tasks/databases.rake +13 -6
- data/lib/tasks/documentation.rake +2 -9
- data/lib/tasks/framework.rake +26 -1
- data/lib/tasks/gems.rake +33 -48
- data/lib/tasks/middleware.rake +7 -0
- data/lib/tasks/misc.rake +7 -0
- data/lib/tasks/statistics.rake +0 -1
- data/lib/tasks/testing.rake +5 -5
- data/lib/tasks/tmp.rake +2 -2
- data/lib/test_help.rb +16 -8
- metadata +36 -170
- data/bin/performance/request +0 -3
- data/bin/process/inspector +0 -3
- data/bin/process/reaper +0 -3
- data/bin/process/spawner +0 -3
- data/config.ru +0 -17
- data/configs/apache.conf +0 -40
- data/configs/lighttpd.conf +0 -54
- data/doc/guides/html/2_2_release_notes.html +0 -1185
- data/doc/guides/html/actioncontroller_basics.html +0 -1270
- data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
- data/doc/guides/html/association_basics.html +0 -2585
- data/doc/guides/html/authors.html +0 -240
- data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
- data/doc/guides/html/caching_with_rails.html +0 -583
- data/doc/guides/html/command_line.html +0 -434
- data/doc/guides/html/configuring.html +0 -438
- data/doc/guides/html/creating_plugins.html +0 -1594
- data/doc/guides/html/debugging_rails_applications.html +0 -1175
- data/doc/guides/html/finders.html +0 -1090
- data/doc/guides/html/form_helpers.html +0 -638
- data/doc/guides/html/getting_started_with_rails.html +0 -2066
- data/doc/guides/html/index.html +0 -349
- data/doc/guides/html/layouts_and_rendering.html +0 -1406
- data/doc/guides/html/migrations.html +0 -921
- data/doc/guides/html/routing_outside_in.html +0 -2213
- data/doc/guides/html/security.html +0 -1346
- data/doc/guides/html/testing_rails_applications.html +0 -1859
- data/doc/guides/source/2_2_release_notes.txt +0 -435
- data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
- data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
- data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
- data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
- data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
- data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
- data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
- data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
- data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
- data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
- data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
- data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
- data/doc/guides/source/active_record_basics.txt +0 -181
- data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
- data/doc/guides/source/association_basics.txt +0 -1840
- data/doc/guides/source/authors.txt +0 -39
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
- data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
- data/doc/guides/source/caching_with_rails.txt +0 -367
- data/doc/guides/source/command_line.txt +0 -147
- data/doc/guides/source/configuring.txt +0 -225
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
- data/doc/guides/source/creating_plugins/appendix.txt +0 -46
- data/doc/guides/source/creating_plugins/controllers.txt +0 -59
- data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
- data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
- data/doc/guides/source/creating_plugins/gem.txt +0 -1
- data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
- data/doc/guides/source/creating_plugins/helpers.txt +0 -51
- data/doc/guides/source/creating_plugins/index.txt +0 -52
- data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
- data/doc/guides/source/creating_plugins/models.txt +0 -76
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
- data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
- data/doc/guides/source/debugging_rails_applications.txt +0 -733
- data/doc/guides/source/finders.txt +0 -668
- data/doc/guides/source/form_helpers.txt +0 -345
- data/doc/guides/source/getting_started_with_rails.txt +0 -1256
- data/doc/guides/source/images/belongs_to.png +0 -0
- data/doc/guides/source/images/bullet.gif +0 -0
- data/doc/guides/source/images/csrf.png +0 -0
- data/doc/guides/source/images/habtm.png +0 -0
- data/doc/guides/source/images/has_many.png +0 -0
- data/doc/guides/source/images/has_many_through.png +0 -0
- data/doc/guides/source/images/has_one.png +0 -0
- data/doc/guides/source/images/has_one_through.png +0 -0
- data/doc/guides/source/images/header_backdrop.png +0 -0
- data/doc/guides/source/images/icons/README +0 -5
- data/doc/guides/source/images/icons/callouts/1.png +0 -0
- data/doc/guides/source/images/icons/callouts/10.png +0 -0
- data/doc/guides/source/images/icons/callouts/11.png +0 -0
- data/doc/guides/source/images/icons/callouts/12.png +0 -0
- data/doc/guides/source/images/icons/callouts/13.png +0 -0
- data/doc/guides/source/images/icons/callouts/14.png +0 -0
- data/doc/guides/source/images/icons/callouts/15.png +0 -0
- data/doc/guides/source/images/icons/callouts/2.png +0 -0
- data/doc/guides/source/images/icons/callouts/3.png +0 -0
- data/doc/guides/source/images/icons/callouts/4.png +0 -0
- data/doc/guides/source/images/icons/callouts/5.png +0 -0
- data/doc/guides/source/images/icons/callouts/6.png +0 -0
- data/doc/guides/source/images/icons/callouts/7.png +0 -0
- data/doc/guides/source/images/icons/callouts/8.png +0 -0
- data/doc/guides/source/images/icons/callouts/9.png +0 -0
- data/doc/guides/source/images/icons/caution.png +0 -0
- data/doc/guides/source/images/icons/example.png +0 -0
- data/doc/guides/source/images/icons/home.png +0 -0
- data/doc/guides/source/images/icons/important.png +0 -0
- data/doc/guides/source/images/icons/next.png +0 -0
- data/doc/guides/source/images/icons/note.png +0 -0
- data/doc/guides/source/images/icons/prev.png +0 -0
- data/doc/guides/source/images/icons/tip.png +0 -0
- data/doc/guides/source/images/icons/up.png +0 -0
- data/doc/guides/source/images/icons/warning.png +0 -0
- data/doc/guides/source/images/polymorphic.png +0 -0
- data/doc/guides/source/images/rails_logo_remix.gif +0 -0
- data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
- data/doc/guides/source/images/session_fixation.png +0 -0
- data/doc/guides/source/index.txt +0 -118
- data/doc/guides/source/layouts_and_rendering.txt +0 -982
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
- data/doc/guides/source/migrations/changelog.txt +0 -5
- data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
- data/doc/guides/source/migrations/foreign_keys.txt +0 -8
- data/doc/guides/source/migrations/index.txt +0 -22
- data/doc/guides/source/migrations/rakeing_around.txt +0 -111
- data/doc/guides/source/migrations/scheming.txt +0 -47
- data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
- data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
- data/doc/guides/source/routing_outside_in.txt +0 -986
- data/doc/guides/source/security.txt +0 -984
- data/doc/guides/source/stylesheets/base.css +0 -358
- data/doc/guides/source/stylesheets/forms.css +0 -35
- data/doc/guides/source/stylesheets/more.css +0 -82
- data/doc/guides/source/templates/guides.html.erb +0 -97
- data/doc/guides/source/templates/inline.css +0 -165
- data/doc/guides/source/testing_rails_applications.txt +0 -995
- data/helpers/application.rb +0 -15
- data/lib/commands/performance/request.rb +0 -6
- data/lib/commands/process/inspector.rb +0 -68
- data/lib/commands/process/reaper.rb +0 -149
- data/lib/commands/process/spawner.rb +0 -219
- data/lib/commands/process/spinner.rb +0 -57
- data/lib/commands/servers/base.rb +0 -31
- data/lib/commands/servers/lighttpd.rb +0 -94
- data/lib/commands/servers/mongrel.rb +0 -69
- data/lib/commands/servers/new_mongrel.rb +0 -16
- data/lib/commands/servers/thin.rb +0 -25
- data/lib/commands/servers/webrick.rb +0 -66
- data/lib/rails/mongrel_server/commands.rb +0 -342
- data/lib/rails/mongrel_server/handler.rb +0 -55
- data/lib/rails/rack/logger.rb +0 -28
@@ -0,0 +1,54 @@
|
|
1
|
+
module Rails
|
2
|
+
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
|
3
|
+
ERB_METHOD_SIG = /:in `_run_erb_.*/
|
4
|
+
|
5
|
+
RAILS_GEMS = %w( actionpack activerecord actionmailer activesupport activeresource rails )
|
6
|
+
|
7
|
+
VENDOR_DIRS = %w( vendor/rails )
|
8
|
+
SERVER_DIRS = %w( lib/mongrel bin/mongrel
|
9
|
+
lib/passenger bin/passenger-spawn-server
|
10
|
+
lib/rack )
|
11
|
+
RAILS_NOISE = %w( script/server )
|
12
|
+
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
|
13
|
+
|
14
|
+
ALL_NOISE = VENDOR_DIRS + SERVER_DIRS + RAILS_NOISE + RUBY_NOISE
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
add_filter { |line| line.sub("#{RAILS_ROOT}/", '') }
|
19
|
+
add_filter { |line| line.sub(ERB_METHOD_SIG, '') }
|
20
|
+
add_filter { |line| line.sub('./', '/') } # for tests
|
21
|
+
|
22
|
+
add_gem_filters
|
23
|
+
|
24
|
+
add_silencer { |line| ALL_NOISE.any? { |dir| line.include?(dir) } }
|
25
|
+
add_silencer { |line| RAILS_GEMS.any? { |gem| line =~ /^#{gem} / } }
|
26
|
+
add_silencer { |line| line =~ %r(vendor/plugins/[^\/]+/lib) }
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
private
|
31
|
+
def add_gem_filters
|
32
|
+
Gem.path.each do |path|
|
33
|
+
# http://gist.github.com/30430
|
34
|
+
add_filter { |line| line.sub(/(#{path})\/gems\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) \4')}
|
35
|
+
end
|
36
|
+
|
37
|
+
vendor_gems_path = Rails::GemDependency.unpacked_path.sub("#{RAILS_ROOT}/",'')
|
38
|
+
add_filter { |line| line.sub(/(#{vendor_gems_path})\/([a-z]+)-([0-9.]+)\/(.*)/, '\2 (\3) [v] \4')}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# For installing the BacktraceCleaner in the test/unit
|
43
|
+
module BacktraceFilterForTestUnit #:nodoc:
|
44
|
+
def self.included(klass)
|
45
|
+
klass.send :alias_method_chain, :filter_backtrace, :cleaning
|
46
|
+
end
|
47
|
+
|
48
|
+
def filter_backtrace_with_cleaning(backtrace, prefix=nil)
|
49
|
+
backtrace = filter_backtrace_without_cleaning(backtrace, prefix)
|
50
|
+
backtrace = backtrace.first.split("\n") if backtrace.size == 1
|
51
|
+
Rails.backtrace_cleaner.clean(backtrace)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/rails/gem_dependency.rb
CHANGED
@@ -7,8 +7,8 @@ module Gem
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Rails
|
10
|
-
class GemDependency
|
11
|
-
attr_accessor :lib, :source
|
10
|
+
class GemDependency < Gem::Dependency
|
11
|
+
attr_accessor :lib, :source, :dep
|
12
12
|
|
13
13
|
def self.unpacked_path
|
14
14
|
@unpacked_path ||= File.join(RAILS_ROOT, 'vendor', 'gems')
|
@@ -29,18 +29,6 @@ module Rails
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def framework_gem?
|
33
|
-
@@framework_gems.has_key?(name)
|
34
|
-
end
|
35
|
-
|
36
|
-
def vendor_rails?
|
37
|
-
Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty?
|
38
|
-
end
|
39
|
-
|
40
|
-
def vendor_gem?
|
41
|
-
Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.include?(self.class.unpacked_path)
|
42
|
-
end
|
43
|
-
|
44
32
|
def initialize(name, options = {})
|
45
33
|
require 'rubygems' unless Object.const_defined?(:Gem)
|
46
34
|
|
@@ -52,10 +40,11 @@ module Rails
|
|
52
40
|
req = Gem::Requirement.default
|
53
41
|
end
|
54
42
|
|
55
|
-
@dep = Gem::Dependency.new(name, req)
|
56
43
|
@lib = options[:lib]
|
57
44
|
@source = options[:source]
|
58
45
|
@loaded = @frozen = @load_paths_added = false
|
46
|
+
|
47
|
+
super(name, req)
|
59
48
|
end
|
60
49
|
|
61
50
|
def add_load_paths
|
@@ -65,7 +54,7 @@ module Rails
|
|
65
54
|
@load_paths_added = @loaded = @frozen = true
|
66
55
|
return
|
67
56
|
end
|
68
|
-
gem
|
57
|
+
gem self
|
69
58
|
@spec = Gem.loaded_specs[name]
|
70
59
|
@frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec
|
71
60
|
@load_paths_added = true
|
@@ -74,43 +63,67 @@ module Rails
|
|
74
63
|
|
75
64
|
def dependencies
|
76
65
|
return [] if framework_gem?
|
77
|
-
|
66
|
+
return [] unless installed?
|
67
|
+
specification.dependencies.reject do |dependency|
|
68
|
+
dependency.type == :development
|
69
|
+
end.map do |dependency|
|
78
70
|
GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
|
79
71
|
end
|
80
|
-
all_dependencies += all_dependencies.map(&:dependencies).flatten
|
81
|
-
all_dependencies.uniq
|
82
72
|
end
|
83
73
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
74
|
+
def specification
|
75
|
+
# code repeated from Gem.activate. Find a matching spec, or the currently loaded version.
|
76
|
+
# error out if loaded version and requested version are incompatible.
|
77
|
+
@spec ||= begin
|
78
|
+
matches = Gem.source_index.search(self)
|
79
|
+
matches << @@framework_gems[name] if framework_gem?
|
80
|
+
if Gem.loaded_specs[name] then
|
81
|
+
# This gem is already loaded. If the currently loaded gem is not in the
|
82
|
+
# list of candidate gems, then we have a version conflict.
|
83
|
+
existing_spec = Gem.loaded_specs[name]
|
84
|
+
unless matches.any? { |spec| spec.version == existing_spec.version } then
|
85
|
+
raise Gem::Exception,
|
86
|
+
"can't activate #{@dep}, already activated #{existing_spec.full_name}"
|
87
|
+
end
|
88
|
+
# we're stuck with it, so change to match
|
89
|
+
version_requirements = Gem::Requirement.create("=#{existing_spec.version}")
|
90
|
+
existing_spec
|
91
|
+
else
|
92
|
+
# new load
|
93
|
+
matches.last
|
94
|
+
end
|
95
|
+
end
|
90
96
|
end
|
91
97
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
@loaded = true
|
96
|
-
rescue LoadError
|
97
|
-
puts $!.to_s
|
98
|
-
$!.backtrace.each { |b| puts b }
|
98
|
+
def requirement
|
99
|
+
r = version_requirements
|
100
|
+
(r == Gem::Requirement.default) ? nil : r
|
99
101
|
end
|
100
102
|
|
101
|
-
def
|
102
|
-
|
103
|
+
def built?
|
104
|
+
# TODO: If Rubygems ever gives us a way to detect this, we should use it
|
105
|
+
false
|
103
106
|
end
|
104
107
|
|
105
|
-
def
|
106
|
-
|
107
|
-
(r == Gem::Requirement.default) ? nil : r
|
108
|
+
def framework_gem?
|
109
|
+
@@framework_gems.has_key?(name)
|
108
110
|
end
|
109
111
|
|
110
112
|
def frozen?
|
111
113
|
@frozen ||= vendor_rails? || vendor_gem?
|
112
114
|
end
|
113
115
|
|
116
|
+
def installed?
|
117
|
+
Gem.loaded_specs.keys.include?(name)
|
118
|
+
end
|
119
|
+
|
120
|
+
def load_paths_added?
|
121
|
+
# always try to add load paths - even if a gem is loaded, it may not
|
122
|
+
# be a compatible version (ie random_gem 0.4 is loaded and a later spec
|
123
|
+
# needs >= 0.5 - gem 'random_gem' will catch this and error out)
|
124
|
+
@load_paths_added
|
125
|
+
end
|
126
|
+
|
114
127
|
def loaded?
|
115
128
|
@loaded ||= begin
|
116
129
|
if vendor_rails?
|
@@ -134,46 +147,49 @@ module Rails
|
|
134
147
|
end
|
135
148
|
end
|
136
149
|
|
137
|
-
def
|
138
|
-
|
139
|
-
# be a compatible version (ie random_gem 0.4 is loaded and a later spec
|
140
|
-
# needs >= 0.5 - gem 'random_gem' will catch this and error out)
|
141
|
-
@load_paths_added
|
150
|
+
def vendor_rails?
|
151
|
+
Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty?
|
142
152
|
end
|
143
153
|
|
144
|
-
def
|
145
|
-
|
146
|
-
puts cmd
|
147
|
-
puts %x(#{cmd})
|
154
|
+
def vendor_gem?
|
155
|
+
specification && File.exists?(unpacked_gem_directory)
|
148
156
|
end
|
149
157
|
|
150
|
-
def
|
151
|
-
|
152
|
-
|
153
|
-
|
158
|
+
def build
|
159
|
+
require 'rails/gem_builder'
|
160
|
+
unless built?
|
161
|
+
return unless File.exists?(unpacked_specification_filename)
|
162
|
+
spec = YAML::load_file(unpacked_specification_filename)
|
163
|
+
Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions
|
164
|
+
puts "Built gem: '#{unpacked_gem_directory}'"
|
154
165
|
end
|
155
|
-
|
156
|
-
# Gem.activate changes the spec - get the original
|
157
|
-
real_spec = Gem::Specification.load(specification.loaded_from)
|
158
|
-
write_spec(directory, real_spec)
|
159
|
-
|
166
|
+
dependencies.each { |dep| dep.build }
|
160
167
|
end
|
161
168
|
|
162
|
-
def
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
file.puts spec.to_yaml
|
169
|
+
def install
|
170
|
+
unless installed?
|
171
|
+
cmd = "#{gem_command} #{install_command.join(' ')}"
|
172
|
+
puts cmd
|
173
|
+
puts %x(#{cmd})
|
168
174
|
end
|
169
175
|
end
|
170
176
|
|
171
|
-
def
|
177
|
+
def load
|
178
|
+
return if @loaded || @load_paths_added == false
|
179
|
+
require(@lib || name) unless @lib == false
|
180
|
+
@loaded = true
|
181
|
+
rescue LoadError
|
182
|
+
puts $!.to_s
|
183
|
+
$!.backtrace.each { |b| puts b }
|
184
|
+
end
|
185
|
+
|
186
|
+
def refresh
|
187
|
+
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
172
188
|
real_gems = Gem.source_index.installed_source_index
|
173
189
|
exact_dep = Gem::Dependency.new(name, "= #{specification.version}")
|
174
190
|
matches = real_gems.search(exact_dep)
|
175
191
|
installed_spec = matches.first
|
176
|
-
if
|
192
|
+
if frozen?
|
177
193
|
if installed_spec
|
178
194
|
# we have a real copy
|
179
195
|
# get a fresh spec - matches should only have one element
|
@@ -181,11 +197,11 @@ module Rails
|
|
181
197
|
# spec is the same as the copy from real_gems - Gem.activate changes
|
182
198
|
# some of the fields
|
183
199
|
real_spec = Gem::Specification.load(matches.first.loaded_from)
|
184
|
-
|
200
|
+
write_specification(real_spec)
|
185
201
|
puts "Reloaded specification for #{name} from installed gems."
|
186
202
|
else
|
187
203
|
# the gem isn't installed locally - write out our current specs
|
188
|
-
|
204
|
+
write_specification(specification)
|
189
205
|
puts "Gem #{name} not loaded locally - writing out current spec."
|
190
206
|
end
|
191
207
|
else
|
@@ -197,42 +213,44 @@ module Rails
|
|
197
213
|
end
|
198
214
|
end
|
199
215
|
|
200
|
-
def
|
201
|
-
|
216
|
+
def unpack(options={})
|
217
|
+
unless frozen? || framework_gem?
|
218
|
+
FileUtils.mkdir_p unpack_base
|
219
|
+
Dir.chdir unpack_base do
|
220
|
+
Gem::GemRunner.new.run(unpack_command)
|
221
|
+
end
|
222
|
+
# Gem.activate changes the spec - get the original
|
223
|
+
real_spec = Gem::Specification.load(specification.loaded_from)
|
224
|
+
write_specification(real_spec)
|
225
|
+
end
|
226
|
+
dependencies.each { |dep| dep.unpack } if options[:recursive]
|
202
227
|
end
|
203
|
-
alias_method :"eql?", :"=="
|
204
228
|
|
205
|
-
def
|
206
|
-
|
229
|
+
def write_specification(spec)
|
230
|
+
# copy the gem's specification into GEMDIR/.specification so that
|
231
|
+
# we can access information about the gem on deployment systems
|
232
|
+
# without having the gem installed
|
233
|
+
File.open(unpacked_specification_filename, 'w') do |file|
|
234
|
+
file.puts spec.to_yaml
|
235
|
+
end
|
207
236
|
end
|
208
237
|
|
209
|
-
def
|
210
|
-
|
211
|
-
# error out if loaded version and requested version are incompatible.
|
212
|
-
@spec ||= begin
|
213
|
-
matches = Gem.source_index.search(@dep)
|
214
|
-
matches << @@framework_gems[name] if framework_gem?
|
215
|
-
if Gem.loaded_specs[name] then
|
216
|
-
# This gem is already loaded. If the currently loaded gem is not in the
|
217
|
-
# list of candidate gems, then we have a version conflict.
|
218
|
-
existing_spec = Gem.loaded_specs[name]
|
219
|
-
unless matches.any? { |spec| spec.version == existing_spec.version } then
|
220
|
-
raise Gem::Exception,
|
221
|
-
"can't activate #{@dep}, already activated #{existing_spec.full_name}"
|
222
|
-
end
|
223
|
-
# we're stuck with it, so change to match
|
224
|
-
@dep.version_requirements = Gem::Requirement.create("=#{existing_spec.version}")
|
225
|
-
existing_spec
|
226
|
-
else
|
227
|
-
# new load
|
228
|
-
matches.last
|
229
|
-
end
|
230
|
-
end
|
238
|
+
def ==(other)
|
239
|
+
self.name == other.name && self.requirement == other.requirement
|
231
240
|
end
|
241
|
+
alias_method :"eql?", :"=="
|
232
242
|
|
233
243
|
private
|
244
|
+
|
234
245
|
def gem_command
|
235
|
-
RUBY_PLATFORM
|
246
|
+
case RUBY_PLATFORM
|
247
|
+
when /win32/
|
248
|
+
'gem.bat'
|
249
|
+
when /java/
|
250
|
+
'jruby -S gem'
|
251
|
+
else
|
252
|
+
'gem'
|
253
|
+
end
|
236
254
|
end
|
237
255
|
|
238
256
|
def install_command
|
@@ -247,5 +265,18 @@ module Rails
|
|
247
265
|
cmd << "--version" << "= "+specification.version.to_s if requirement
|
248
266
|
cmd
|
249
267
|
end
|
268
|
+
|
269
|
+
def unpack_base
|
270
|
+
Rails::GemDependency.unpacked_path
|
271
|
+
end
|
272
|
+
|
273
|
+
def unpacked_gem_directory
|
274
|
+
File.join(unpack_base, specification.full_name)
|
275
|
+
end
|
276
|
+
|
277
|
+
def unpacked_specification_filename
|
278
|
+
File.join(unpacked_gem_directory, '.specification')
|
279
|
+
end
|
280
|
+
|
250
281
|
end
|
251
282
|
end
|
data/lib/rails/plugin.rb
CHANGED
@@ -28,15 +28,19 @@ module Rails
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def valid?
|
31
|
-
File.directory?(directory) && (has_lib_directory? || has_init_file?)
|
31
|
+
File.directory?(directory) && (has_app_directory? || has_lib_directory? || has_init_file?)
|
32
32
|
end
|
33
33
|
|
34
34
|
# Returns a list of paths this plugin wishes to make available in <tt>$LOAD_PATH</tt>.
|
35
35
|
def load_paths
|
36
36
|
report_nonexistant_or_empty_plugin! unless valid?
|
37
|
-
|
37
|
+
|
38
|
+
returning [] do |load_paths|
|
39
|
+
load_paths << lib_path if has_lib_directory?
|
40
|
+
load_paths << app_paths if has_app_directory?
|
41
|
+
end.flatten
|
38
42
|
end
|
39
|
-
|
43
|
+
|
40
44
|
# Evaluates a plugin's init.rb file.
|
41
45
|
def load(initializer)
|
42
46
|
return if loaded?
|
@@ -56,7 +60,35 @@ module Rails
|
|
56
60
|
def about
|
57
61
|
@about ||= load_about_information
|
58
62
|
end
|
63
|
+
|
64
|
+
# Engines are plugins with an app/ directory.
|
65
|
+
def engine?
|
66
|
+
has_app_directory?
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns true if the engine ships with a routing file
|
70
|
+
def routed?
|
71
|
+
File.exist?(routing_file)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def view_path
|
76
|
+
File.join(directory, 'app', 'views')
|
77
|
+
end
|
78
|
+
|
79
|
+
def controller_path
|
80
|
+
File.join(directory, 'app', 'controllers')
|
81
|
+
end
|
82
|
+
|
83
|
+
def metal_path
|
84
|
+
File.join(directory, 'app', 'metal')
|
85
|
+
end
|
86
|
+
|
87
|
+
def routing_file
|
88
|
+
File.join(directory, 'config', 'routes.rb')
|
89
|
+
end
|
59
90
|
|
91
|
+
|
60
92
|
private
|
61
93
|
def load_about_information
|
62
94
|
about_yml_path = File.join(@directory, "about.yml")
|
@@ -68,8 +100,13 @@ module Rails
|
|
68
100
|
|
69
101
|
def report_nonexistant_or_empty_plugin!
|
70
102
|
raise LoadError, "Can not find the plugin named: #{name}"
|
71
|
-
end
|
72
|
-
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def app_paths
|
107
|
+
[ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ]
|
108
|
+
end
|
109
|
+
|
73
110
|
def lib_path
|
74
111
|
File.join(directory, 'lib')
|
75
112
|
end
|
@@ -86,6 +123,11 @@ module Rails
|
|
86
123
|
File.file?(gem_init_path) ? gem_init_path : classic_init_path
|
87
124
|
end
|
88
125
|
|
126
|
+
|
127
|
+
def has_app_directory?
|
128
|
+
File.directory?(File.join(directory, 'app'))
|
129
|
+
end
|
130
|
+
|
89
131
|
def has_lib_directory?
|
90
132
|
File.directory?(lib_path)
|
91
133
|
end
|
@@ -94,6 +136,7 @@ module Rails
|
|
94
136
|
File.file?(init_path)
|
95
137
|
end
|
96
138
|
|
139
|
+
|
97
140
|
def evaluate_init_rb(initializer)
|
98
141
|
if has_init_file?
|
99
142
|
silence_warnings do
|
@@ -121,4 +164,4 @@ module Rails
|
|
121
164
|
File.join(directory, 'rails', 'init.rb')
|
122
165
|
end
|
123
166
|
end
|
124
|
-
end
|
167
|
+
end
|