rails 2.3.18 → 3.2.22.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- metadata +114 -330
- data/CHANGELOG +0 -2193
- data/MIT-LICENSE +0 -20
- data/README +0 -243
- data/Rakefile +0 -365
- data/bin/about +0 -4
- data/bin/console +0 -3
- data/bin/dbconsole +0 -3
- data/bin/destroy +0 -3
- data/bin/generate +0 -3
- data/bin/performance/benchmarker +0 -3
- data/bin/performance/profiler +0 -3
- data/bin/plugin +0 -3
- data/bin/rails +0 -21
- data/bin/runner +0 -3
- data/bin/server +0 -3
- data/builtin/rails_info/rails/info.rb +0 -131
- data/builtin/rails_info/rails/info_controller.rb +0 -9
- data/builtin/rails_info/rails/info_helper.rb +0 -2
- data/builtin/rails_info/rails_info_controller.rb +0 -2
- data/configs/databases/frontbase.yml +0 -28
- data/configs/databases/ibm_db.yml +0 -62
- data/configs/databases/mysql.yml +0 -60
- data/configs/databases/oracle.yml +0 -39
- data/configs/databases/postgresql.yml +0 -51
- data/configs/databases/sqlite2.yml +0 -19
- data/configs/databases/sqlite3.yml +0 -22
- data/configs/empty.log +0 -0
- data/configs/initializers/backtrace_silencers.rb +0 -7
- data/configs/initializers/cookie_verification_secret.rb +0 -7
- data/configs/initializers/inflections.rb +0 -10
- data/configs/initializers/mime_types.rb +0 -5
- data/configs/initializers/new_rails_defaults.rb +0 -21
- data/configs/initializers/session_store.rb +0 -15
- data/configs/locales/en.yml +0 -5
- data/configs/routes.rb +0 -43
- data/configs/seeds.rb +0 -7
- data/dispatches/config.ru +0 -7
- data/dispatches/dispatch.fcgi +0 -24
- data/dispatches/dispatch.rb +0 -10
- data/dispatches/gateway.cgi +0 -97
- data/doc/README_FOR_APP +0 -2
- data/environments/boot.rb +0 -114
- data/environments/development.rb +0 -17
- data/environments/environment.rb +0 -41
- data/environments/production.rb +0 -28
- data/environments/test.rb +0 -28
- data/fresh_rakefile +0 -10
- data/helpers/application_controller.rb +0 -10
- data/helpers/application_helper.rb +0 -3
- data/helpers/performance_test.rb +0 -9
- data/helpers/test_helper.rb +0 -38
- data/html/404.html +0 -30
- data/html/422.html +0 -30
- data/html/500.html +0 -30
- data/html/favicon.ico +0 -0
- data/html/images/rails.png +0 -0
- data/html/index.html +0 -275
- data/html/javascripts/application.js +0 -2
- data/html/javascripts/controls.js +0 -963
- data/html/javascripts/dragdrop.js +0 -973
- data/html/javascripts/effects.js +0 -1128
- data/html/javascripts/prototype.js +0 -4320
- data/html/robots.txt +0 -5
- data/lib/code_statistics.rb +0 -107
- data/lib/commands/about.rb +0 -3
- data/lib/commands/console.rb +0 -45
- data/lib/commands/dbconsole.rb +0 -87
- data/lib/commands/destroy.rb +0 -6
- data/lib/commands/generate.rb +0 -6
- data/lib/commands/ncgi/listener +0 -86
- data/lib/commands/ncgi/tracker +0 -69
- data/lib/commands/performance/benchmarker.rb +0 -24
- data/lib/commands/performance/profiler.rb +0 -50
- data/lib/commands/plugin.rb +0 -968
- data/lib/commands/runner.rb +0 -54
- data/lib/commands/server.rb +0 -114
- data/lib/commands/update.rb +0 -4
- data/lib/commands.rb +0 -17
- data/lib/console_app.rb +0 -30
- data/lib/console_sandbox.rb +0 -6
- data/lib/console_with_helpers.rb +0 -5
- data/lib/dispatcher.rb +0 -24
- data/lib/fcgi_handler.rb +0 -239
- data/lib/initializer.rb +0 -1152
- data/lib/performance_test_help.rb +0 -5
- data/lib/rails/backtrace_cleaner.rb +0 -54
- data/lib/rails/gem_builder.rb +0 -21
- data/lib/rails/gem_dependency.rb +0 -317
- data/lib/rails/plugin/loader.rb +0 -198
- data/lib/rails/plugin/locator.rb +0 -100
- data/lib/rails/plugin.rb +0 -179
- data/lib/rails/rack/debugger.rb +0 -23
- data/lib/rails/rack/log_tailer.rb +0 -35
- data/lib/rails/rack/metal.rb +0 -51
- data/lib/rails/rack/static.rb +0 -46
- data/lib/rails/rack.rb +0 -8
- data/lib/rails/vendor_gem_source_index.rb +0 -140
- data/lib/rails/version.rb +0 -9
- data/lib/rails_generator/base.rb +0 -266
- data/lib/rails_generator/commands.rb +0 -621
- data/lib/rails_generator/generated_attribute.rb +0 -47
- data/lib/rails_generator/generators/applications/app/USAGE +0 -9
- data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -266
- data/lib/rails_generator/generators/applications/app/scm/git.rb +0 -18
- data/lib/rails_generator/generators/applications/app/scm/scm.rb +0 -8
- data/lib/rails_generator/generators/applications/app/scm/svn.rb +0 -7
- data/lib/rails_generator/generators/applications/app/template_runner.rb +0 -401
- data/lib/rails_generator/generators/components/controller/USAGE +0 -30
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -43
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
- data/lib/rails_generator/generators/components/helper/USAGE +0 -24
- data/lib/rails_generator/generators/components/helper/helper_generator.rb +0 -25
- data/lib/rails_generator/generators/components/helper/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
- data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
- data/lib/rails_generator/generators/components/metal/USAGE +0 -8
- data/lib/rails_generator/generators/components/metal/metal_generator.rb +0 -8
- data/lib/rails_generator/generators/components/metal/templates/metal.rb +0 -12
- data/lib/rails_generator/generators/components/migration/USAGE +0 -29
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
- data/lib/rails_generator/generators/components/model/USAGE +0 -27
- data/lib/rails_generator/generators/components/model/model_generator.rb +0 -52
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -23
- data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
- data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/observer/USAGE +0 -13
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
- data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
- data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/USAGE +0 -23
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -76
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -103
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -83
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +0 -4
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
- data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
- data/lib/rails_generator/lookup.rb +0 -249
- data/lib/rails_generator/manifest.rb +0 -53
- data/lib/rails_generator/options.rb +0 -150
- data/lib/rails_generator/scripts/destroy.rb +0 -29
- data/lib/rails_generator/scripts/generate.rb +0 -7
- data/lib/rails_generator/scripts/update.rb +0 -12
- data/lib/rails_generator/scripts.rb +0 -89
- data/lib/rails_generator/secret_key_generator.rb +0 -24
- data/lib/rails_generator/simple_logger.rb +0 -46
- data/lib/rails_generator/spec.rb +0 -44
- data/lib/rails_generator.rb +0 -46
- data/lib/railties_path.rb +0 -1
- data/lib/ruby_version_check.rb +0 -17
- data/lib/rubyprof_ext.rb +0 -35
- data/lib/source_annotation_extractor.rb +0 -102
- data/lib/tasks/annotations.rake +0 -20
- data/lib/tasks/databases.rake +0 -436
- data/lib/tasks/documentation.rake +0 -93
- data/lib/tasks/framework.rake +0 -146
- data/lib/tasks/gems.rake +0 -78
- data/lib/tasks/log.rake +0 -9
- data/lib/tasks/middleware.rake +0 -7
- data/lib/tasks/misc.rake +0 -63
- data/lib/tasks/rails.rb +0 -14
- data/lib/tasks/routes.rake +0 -18
- data/lib/tasks/statistics.rake +0 -17
- data/lib/tasks/testing.rake +0 -139
- data/lib/tasks/tmp.rake +0 -37
- data/lib/test_help.rb +0 -38
- data/lib/webrick_server.rb +0 -156
- data/railties.gemspec +0 -22
@@ -1,54 +0,0 @@
|
|
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_builder.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rubygems/installer'
|
3
|
-
|
4
|
-
module Rails
|
5
|
-
|
6
|
-
# this class hijacks the functionality of Gem::Installer by overloading its
|
7
|
-
# initializer to only provide the information needed by
|
8
|
-
# Gem::Installer#build_extensions (which happens to be what we have)
|
9
|
-
class GemBuilder < Gem::Installer
|
10
|
-
|
11
|
-
def initialize(spec, gem_dir)
|
12
|
-
@spec = spec
|
13
|
-
@gem_dir = gem_dir
|
14
|
-
end
|
15
|
-
|
16
|
-
# silence the underlying builder
|
17
|
-
def say(message)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
data/lib/rails/gem_dependency.rb
DELETED
@@ -1,317 +0,0 @@
|
|
1
|
-
require 'rails/vendor_gem_source_index'
|
2
|
-
|
3
|
-
module Gem
|
4
|
-
def self.source_index=(index)
|
5
|
-
@@source_index = index
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
module Rails
|
10
|
-
class GemDependency < Gem::Dependency
|
11
|
-
attr_accessor :lib, :source, :dep
|
12
|
-
|
13
|
-
def self.unpacked_path
|
14
|
-
@unpacked_path ||= File.join(RAILS_ROOT, 'vendor', 'gems')
|
15
|
-
end
|
16
|
-
|
17
|
-
@@framework_gems = {}
|
18
|
-
|
19
|
-
def self.add_frozen_gem_path
|
20
|
-
@@paths_loaded ||= begin
|
21
|
-
source_index = Rails::VendorGemSourceIndex.new(Gem.source_index)
|
22
|
-
Gem.clear_paths
|
23
|
-
Gem.source_index = source_index
|
24
|
-
# loaded before us - we can't change them, so mark them
|
25
|
-
Gem.loaded_specs.each do |name, spec|
|
26
|
-
@@framework_gems[name] = spec
|
27
|
-
end
|
28
|
-
true
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.from_directory_name(directory_name, load_spec=true)
|
33
|
-
directory_name_parts = File.basename(directory_name).split('-')
|
34
|
-
|
35
|
-
version = directory_name_parts.find { |s| s.match(/^\d(\.\d|\.\w+)*$/) }
|
36
|
-
name = directory_name_parts[0..directory_name_parts.index(version)-1].join('-') if version
|
37
|
-
|
38
|
-
result = self.new(name, :version => version)
|
39
|
-
spec_filename = File.join(directory_name, '.specification')
|
40
|
-
if load_spec
|
41
|
-
raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'\?" unless File.exists?(spec_filename)
|
42
|
-
spec = YAML::load_file(spec_filename)
|
43
|
-
result.specification = spec
|
44
|
-
end
|
45
|
-
result
|
46
|
-
rescue ArgumentError => e
|
47
|
-
raise "Unable to determine gem name and version from '#{directory_name}'"
|
48
|
-
end
|
49
|
-
|
50
|
-
def initialize(name, options = {})
|
51
|
-
require 'rubygems' unless Object.const_defined?(:Gem)
|
52
|
-
|
53
|
-
if options[:requirement]
|
54
|
-
req = options[:requirement]
|
55
|
-
elsif options[:version]
|
56
|
-
req = Gem::Requirement.create(options[:version])
|
57
|
-
else
|
58
|
-
req = Gem::Requirement.default
|
59
|
-
end
|
60
|
-
|
61
|
-
@lib = options[:lib]
|
62
|
-
@source = options[:source]
|
63
|
-
@loaded = @frozen = @load_paths_added = false
|
64
|
-
|
65
|
-
super(name, req)
|
66
|
-
end
|
67
|
-
|
68
|
-
def add_load_paths
|
69
|
-
self.class.add_frozen_gem_path
|
70
|
-
return if @loaded || @load_paths_added
|
71
|
-
if framework_gem?
|
72
|
-
@load_paths_added = @loaded = @frozen = true
|
73
|
-
return
|
74
|
-
end
|
75
|
-
|
76
|
-
begin
|
77
|
-
dep = Gem::Dependency.new(name, requirement)
|
78
|
-
spec = Gem.source_index.find { |_,s| s.satisfies_requirement?(dep) }.last
|
79
|
-
spec.activate # a way that exists
|
80
|
-
rescue
|
81
|
-
gem self.name, self.requirement # < 1.8 unhappy way
|
82
|
-
end
|
83
|
-
|
84
|
-
@spec = Gem.loaded_specs[name]
|
85
|
-
@frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec
|
86
|
-
@load_paths_added = true
|
87
|
-
rescue Gem::LoadError
|
88
|
-
end
|
89
|
-
|
90
|
-
def dependencies
|
91
|
-
return [] if framework_gem?
|
92
|
-
return [] unless installed?
|
93
|
-
specification.dependencies.reject do |dependency|
|
94
|
-
dependency.type == :development
|
95
|
-
end.map do |dependency|
|
96
|
-
GemDependency.new(dependency.name, :requirement => (dependency.respond_to?(:requirement) ? dependency.requirement : dependency.version_requirements))
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def specification
|
101
|
-
# code repeated from Gem.activate. Find a matching spec, or the currently loaded version.
|
102
|
-
# error out if loaded version and requested version are incompatible.
|
103
|
-
@spec ||= begin
|
104
|
-
matches = Gem.source_index.search(self)
|
105
|
-
matches << @@framework_gems[name] if framework_gem?
|
106
|
-
if Gem.loaded_specs[name] then
|
107
|
-
# This gem is already loaded. If the currently loaded gem is not in the
|
108
|
-
# list of candidate gems, then we have a version conflict.
|
109
|
-
existing_spec = Gem.loaded_specs[name]
|
110
|
-
unless matches.any? { |spec| spec.version == existing_spec.version } then
|
111
|
-
raise Gem::Exception,
|
112
|
-
"can't activate #{@dep}, already activated #{existing_spec.full_name}"
|
113
|
-
end
|
114
|
-
# we're stuck with it, so change to match
|
115
|
-
version_requirements = Gem::Requirement.create("=#{existing_spec.version}")
|
116
|
-
existing_spec
|
117
|
-
else
|
118
|
-
# new load
|
119
|
-
matches.last
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def specification=(s)
|
125
|
-
@spec = s
|
126
|
-
end
|
127
|
-
|
128
|
-
def built?
|
129
|
-
return false unless frozen?
|
130
|
-
|
131
|
-
if vendor_gem?
|
132
|
-
specification.extensions.each do |ext|
|
133
|
-
makefile = File.join(unpacked_gem_directory, File.dirname(ext), 'Makefile')
|
134
|
-
return false unless File.exists?(makefile)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
true
|
139
|
-
end
|
140
|
-
|
141
|
-
def framework_gem?
|
142
|
-
@@framework_gems.has_key?(name)
|
143
|
-
end
|
144
|
-
|
145
|
-
def frozen?
|
146
|
-
@frozen ||= vendor_rails? || vendor_gem?
|
147
|
-
end
|
148
|
-
|
149
|
-
def installed?
|
150
|
-
Gem.loaded_specs.keys.include?(name)
|
151
|
-
end
|
152
|
-
|
153
|
-
def load_paths_added?
|
154
|
-
# always try to add load paths - even if a gem is loaded, it may not
|
155
|
-
# be a compatible version (ie random_gem 0.4 is loaded and a later spec
|
156
|
-
# needs >= 0.5 - gem 'random_gem' will catch this and error out)
|
157
|
-
@load_paths_added
|
158
|
-
end
|
159
|
-
|
160
|
-
def loaded?
|
161
|
-
@loaded ||= begin
|
162
|
-
if vendor_rails?
|
163
|
-
true
|
164
|
-
elsif specification.nil?
|
165
|
-
false
|
166
|
-
else
|
167
|
-
# check if the gem is loaded by inspecting $"
|
168
|
-
# specification.files lists all the files contained in the gem
|
169
|
-
gem_files = specification.files
|
170
|
-
# select only the files contained in require_paths - typically in bin and lib
|
171
|
-
require_paths_regexp = Regexp.new("^(#{specification.require_paths*'|'})/")
|
172
|
-
gem_lib_files = gem_files.select { |f| require_paths_regexp.match(f) }
|
173
|
-
# chop the leading directory off - a typical file might be in
|
174
|
-
# lib/gem_name/file_name.rb, but it will be 'require'd as gem_name/file_name.rb
|
175
|
-
gem_lib_files.map! { |f| f.split('/', 2)[1] }
|
176
|
-
# if any of the files from the above list appear in $", the gem is assumed to
|
177
|
-
# have been loaded
|
178
|
-
!(gem_lib_files & $").empty?
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def vendor_rails?
|
184
|
-
Gem.loaded_specs.has_key?(name) && Gem.loaded_specs[name].loaded_from.empty?
|
185
|
-
end
|
186
|
-
|
187
|
-
def vendor_gem?
|
188
|
-
specification && File.exists?(unpacked_gem_directory)
|
189
|
-
end
|
190
|
-
|
191
|
-
def build(options={})
|
192
|
-
require 'rails/gem_builder'
|
193
|
-
return if specification.nil?
|
194
|
-
if options[:force] || !built?
|
195
|
-
return unless File.exists?(unpacked_specification_filename)
|
196
|
-
spec = YAML::load_file(unpacked_specification_filename)
|
197
|
-
Rails::GemBuilder.new(spec, unpacked_gem_directory).build_extensions
|
198
|
-
puts "Built gem: '#{unpacked_gem_directory}'"
|
199
|
-
end
|
200
|
-
dependencies.each { |dep| dep.build(options) }
|
201
|
-
end
|
202
|
-
|
203
|
-
def install
|
204
|
-
unless installed?
|
205
|
-
cmd = "#{gem_command} #{install_command.join(' ')}"
|
206
|
-
puts cmd
|
207
|
-
puts %x(#{cmd})
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
def load
|
212
|
-
return if @loaded || @load_paths_added == false
|
213
|
-
require(@lib || name) unless @lib == false
|
214
|
-
@loaded = true
|
215
|
-
rescue LoadError
|
216
|
-
puts $!.to_s
|
217
|
-
$!.backtrace.each { |b| puts b }
|
218
|
-
end
|
219
|
-
|
220
|
-
def refresh
|
221
|
-
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
222
|
-
real_gems = Gem.source_index.installed_source_index
|
223
|
-
exact_dep = Gem::Dependency.new(name, "= #{specification.version}")
|
224
|
-
matches = real_gems.search(exact_dep)
|
225
|
-
installed_spec = matches.first
|
226
|
-
if frozen?
|
227
|
-
if installed_spec
|
228
|
-
# we have a real copy
|
229
|
-
# get a fresh spec - matches should only have one element
|
230
|
-
# note that there is no reliable method to check that the loaded
|
231
|
-
# spec is the same as the copy from real_gems - Gem.activate changes
|
232
|
-
# some of the fields
|
233
|
-
real_spec = Gem::Specification.load(matches.first.loaded_from)
|
234
|
-
write_specification(real_spec)
|
235
|
-
puts "Reloaded specification for #{name} from installed gems."
|
236
|
-
else
|
237
|
-
# the gem isn't installed locally - write out our current specs
|
238
|
-
write_specification(specification)
|
239
|
-
puts "Gem #{name} not loaded locally - writing out current spec."
|
240
|
-
end
|
241
|
-
else
|
242
|
-
if framework_gem?
|
243
|
-
puts "Gem directory for #{name} not found - check if it's loading before rails."
|
244
|
-
else
|
245
|
-
puts "Something bad is going on - gem directory not found for #{name}."
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def unpack(options={})
|
251
|
-
unless frozen? || framework_gem?
|
252
|
-
FileUtils.mkdir_p unpack_base
|
253
|
-
Dir.chdir unpack_base do
|
254
|
-
Gem::GemRunner.new.run(unpack_command)
|
255
|
-
end
|
256
|
-
# Gem.activate changes the spec - get the original
|
257
|
-
real_spec = Gem::Specification.load(specification.loaded_from)
|
258
|
-
write_specification(real_spec)
|
259
|
-
end
|
260
|
-
dependencies.each { |dep| dep.unpack(options) } if options[:recursive]
|
261
|
-
end
|
262
|
-
|
263
|
-
def write_specification(spec)
|
264
|
-
# copy the gem's specification into GEMDIR/.specification so that
|
265
|
-
# we can access information about the gem on deployment systems
|
266
|
-
# without having the gem installed
|
267
|
-
File.open(unpacked_specification_filename, 'w') do |file|
|
268
|
-
file.puts spec.to_yaml
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def ==(other)
|
273
|
-
Gem::Dependency === other.class &&
|
274
|
-
self.name == other.name && self.requirement == other.requirement
|
275
|
-
end
|
276
|
-
alias_method :eql?, :"=="
|
277
|
-
|
278
|
-
private
|
279
|
-
|
280
|
-
def gem_command
|
281
|
-
case RUBY_PLATFORM
|
282
|
-
when /win32/
|
283
|
-
'gem.bat'
|
284
|
-
when /java/
|
285
|
-
'jruby -S gem'
|
286
|
-
else
|
287
|
-
'gem'
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
def install_command
|
292
|
-
cmd = %w(install) << name
|
293
|
-
cmd << "--version" << %("#{requirement.to_s}") if requirement
|
294
|
-
cmd << "--source" << @source if @source
|
295
|
-
cmd
|
296
|
-
end
|
297
|
-
|
298
|
-
def unpack_command
|
299
|
-
cmd = %w(unpack) << name
|
300
|
-
cmd << "--version" << "= "+specification.version.to_s if requirement
|
301
|
-
cmd
|
302
|
-
end
|
303
|
-
|
304
|
-
def unpack_base
|
305
|
-
Rails::GemDependency.unpacked_path
|
306
|
-
end
|
307
|
-
|
308
|
-
def unpacked_gem_directory
|
309
|
-
File.join(unpack_base, specification.full_name)
|
310
|
-
end
|
311
|
-
|
312
|
-
def unpacked_specification_filename
|
313
|
-
File.join(unpacked_gem_directory, '.specification')
|
314
|
-
end
|
315
|
-
|
316
|
-
end
|
317
|
-
end
|
data/lib/rails/plugin/loader.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
require "rails/plugin"
|
2
|
-
|
3
|
-
module Rails
|
4
|
-
class Plugin
|
5
|
-
class Loader
|
6
|
-
attr_reader :initializer
|
7
|
-
|
8
|
-
# Creates a new Plugin::Loader instance, associated with the given
|
9
|
-
# Rails::Initializer. This default implementation automatically locates
|
10
|
-
# all plugins, and adds all plugin load paths, when it is created. The plugins
|
11
|
-
# are then fully loaded (init.rb is evaluated) when load_plugins is called.
|
12
|
-
#
|
13
|
-
# It is the loader's responsibility to ensure that only the plugins specified
|
14
|
-
# in the configuration are actually loaded, and that the order defined
|
15
|
-
# is respected.
|
16
|
-
def initialize(initializer)
|
17
|
-
@initializer = initializer
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns the plugins to be loaded, in the order they should be loaded.
|
21
|
-
def plugins
|
22
|
-
@plugins ||= all_plugins.select { |plugin| should_load?(plugin) }.sort { |p1, p2| order_plugins(p1, p2) }
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns the plugins that are in engine-form (have an app/ directory)
|
26
|
-
def engines
|
27
|
-
@engines ||= plugins.select(&:engine?)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Returns all the plugins that could be found by the current locators.
|
31
|
-
def all_plugins
|
32
|
-
@all_plugins ||= locate_plugins
|
33
|
-
@all_plugins
|
34
|
-
end
|
35
|
-
|
36
|
-
def load_plugins
|
37
|
-
plugins.each do |plugin|
|
38
|
-
plugin.load(initializer)
|
39
|
-
register_plugin_as_loaded(plugin)
|
40
|
-
end
|
41
|
-
|
42
|
-
configure_engines
|
43
|
-
|
44
|
-
ensure_all_registered_plugins_are_loaded!
|
45
|
-
end
|
46
|
-
|
47
|
-
# Adds the load paths for every plugin into the $LOAD_PATH. Plugin load paths are
|
48
|
-
# added *after* the application's <tt>lib</tt> directory, to ensure that an application
|
49
|
-
# can always override code within a plugin.
|
50
|
-
#
|
51
|
-
# Plugin load paths are also added to Dependencies.autoload_paths, and Dependencies.autoload_once_paths.
|
52
|
-
def add_plugin_load_paths
|
53
|
-
plugins.each do |plugin|
|
54
|
-
plugin.load_paths.each do |path|
|
55
|
-
$LOAD_PATH.insert(application_lib_index + 1, path)
|
56
|
-
|
57
|
-
ActiveSupport::Dependencies.autoload_paths << path
|
58
|
-
|
59
|
-
unless configuration.reload_plugins?
|
60
|
-
ActiveSupport::Dependencies.autoload_once_paths << path
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
$LOAD_PATH.uniq!
|
66
|
-
end
|
67
|
-
|
68
|
-
def engine_metal_paths
|
69
|
-
engines.collect(&:metal_path)
|
70
|
-
end
|
71
|
-
|
72
|
-
protected
|
73
|
-
def configure_engines
|
74
|
-
if engines.any?
|
75
|
-
add_engine_routing_configurations
|
76
|
-
add_engine_locales
|
77
|
-
add_engine_controller_paths
|
78
|
-
add_engine_view_paths
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_engine_routing_configurations
|
83
|
-
engines.select(&:routed?).collect(&:routing_file).each do |routing_file|
|
84
|
-
ActionController::Routing::Routes.add_configuration_file(routing_file)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def add_engine_locales
|
89
|
-
# reverse it such that the last engine can overwrite translations from the first, like with routes
|
90
|
-
locale_files = engines.select(&:localized?).collect(&:locale_files).reverse.flatten
|
91
|
-
I18n.load_path += locale_files - I18n.load_path
|
92
|
-
end
|
93
|
-
|
94
|
-
def add_engine_controller_paths
|
95
|
-
ActionController::Routing.controller_paths += engines.collect(&:controller_path)
|
96
|
-
end
|
97
|
-
|
98
|
-
def add_engine_view_paths
|
99
|
-
# reverse it such that the last engine can overwrite view paths from the first, like with routes
|
100
|
-
paths = ActionView::PathSet.new(engines.collect(&:view_path).reverse)
|
101
|
-
ActionController::Base.view_paths.concat(paths)
|
102
|
-
ActionMailer::Base.view_paths.concat(paths) if configuration.frameworks.include?(:action_mailer)
|
103
|
-
end
|
104
|
-
|
105
|
-
# The locate_plugins method uses each class in config.plugin_locators to
|
106
|
-
# find the set of all plugins available to this Rails application.
|
107
|
-
def locate_plugins
|
108
|
-
configuration.plugin_locators.map do |locator|
|
109
|
-
locator.new(initializer).plugins
|
110
|
-
end.flatten
|
111
|
-
# TODO: sorting based on config.plugins
|
112
|
-
end
|
113
|
-
|
114
|
-
def register_plugin_as_loaded(plugin)
|
115
|
-
initializer.loaded_plugins << plugin
|
116
|
-
end
|
117
|
-
|
118
|
-
def configuration
|
119
|
-
initializer.configuration
|
120
|
-
end
|
121
|
-
|
122
|
-
def should_load?(plugin)
|
123
|
-
# uses Plugin#name and Plugin#valid?
|
124
|
-
enabled?(plugin) && plugin.valid?
|
125
|
-
end
|
126
|
-
|
127
|
-
def order_plugins(plugin_a, plugin_b)
|
128
|
-
if !explicit_plugin_loading_order?
|
129
|
-
plugin_a <=> plugin_b
|
130
|
-
else
|
131
|
-
if !explicitly_enabled?(plugin_a) && !explicitly_enabled?(plugin_b)
|
132
|
-
plugin_a <=> plugin_b
|
133
|
-
else
|
134
|
-
effective_order_of(plugin_a) <=> effective_order_of(plugin_b)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def effective_order_of(plugin)
|
140
|
-
if explicitly_enabled?(plugin)
|
141
|
-
registered_plugin_names.index(plugin.name)
|
142
|
-
else
|
143
|
-
registered_plugin_names.index('all')
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def application_lib_index
|
148
|
-
$LOAD_PATH.index(File.join(RAILS_ROOT, 'lib')) || 0
|
149
|
-
end
|
150
|
-
|
151
|
-
def enabled?(plugin)
|
152
|
-
!explicit_plugin_loading_order? || registered?(plugin)
|
153
|
-
end
|
154
|
-
|
155
|
-
def explicit_plugin_loading_order?
|
156
|
-
!registered_plugin_names.nil?
|
157
|
-
end
|
158
|
-
|
159
|
-
def registered?(plugin)
|
160
|
-
explicit_plugin_loading_order? && registered_plugins_names_plugin?(plugin)
|
161
|
-
end
|
162
|
-
|
163
|
-
def explicitly_enabled?(plugin)
|
164
|
-
!explicit_plugin_loading_order? || explicitly_registered?(plugin)
|
165
|
-
end
|
166
|
-
|
167
|
-
def explicitly_registered?(plugin)
|
168
|
-
explicit_plugin_loading_order? && registered_plugin_names.include?(plugin.name)
|
169
|
-
end
|
170
|
-
|
171
|
-
def registered_plugins_names_plugin?(plugin)
|
172
|
-
registered_plugin_names.include?(plugin.name) || registered_plugin_names.include?('all')
|
173
|
-
end
|
174
|
-
|
175
|
-
# The plugins that have been explicitly listed with config.plugins. If this list is nil
|
176
|
-
# then it means the client does not care which plugins or in what order they are loaded,
|
177
|
-
# so we load all in alphabetical order. If it is an empty array, we load no plugins, if it is
|
178
|
-
# non empty, we load the named plugins in the order specified.
|
179
|
-
def registered_plugin_names
|
180
|
-
configuration.plugins ? configuration.plugins.map(&:to_s) : nil
|
181
|
-
end
|
182
|
-
|
183
|
-
def loaded?(plugin_name)
|
184
|
-
initializer.loaded_plugins.detect { |plugin| plugin.name == plugin_name.to_s }
|
185
|
-
end
|
186
|
-
|
187
|
-
def ensure_all_registered_plugins_are_loaded!
|
188
|
-
if explicit_plugin_loading_order?
|
189
|
-
if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) }
|
190
|
-
missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all])
|
191
|
-
raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence(:locale => :en)}"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
data/lib/rails/plugin/locator.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
module Rails
|
2
|
-
class Plugin
|
3
|
-
|
4
|
-
# The Plugin::Locator class should be subclasses to provide custom plugin-finding
|
5
|
-
# abilities to Rails (i.e. loading plugins from Gems, etc). Each subclass should implement
|
6
|
-
# the <tt>located_plugins</tt> method, which return an array of Plugin objects that have been found.
|
7
|
-
class Locator
|
8
|
-
include Enumerable
|
9
|
-
|
10
|
-
attr_reader :initializer
|
11
|
-
|
12
|
-
def initialize(initializer)
|
13
|
-
@initializer = initializer
|
14
|
-
end
|
15
|
-
|
16
|
-
# This method should return all the plugins which this Plugin::Locator can find
|
17
|
-
# These will then be used by the current Plugin::Loader, which is responsible for actually
|
18
|
-
# loading the plugins themselves
|
19
|
-
def plugins
|
20
|
-
raise "The `plugins' method must be defined by concrete subclasses of #{self.class}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def each(&block)
|
24
|
-
plugins.each(&block)
|
25
|
-
end
|
26
|
-
|
27
|
-
def plugin_names
|
28
|
-
plugins.map(&:name)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# The Rails::Plugin::FileSystemLocator will try to locate plugins by examining the directories
|
33
|
-
# in the paths given in configuration.plugin_paths. Any plugins that can be found are returned
|
34
|
-
# in a list.
|
35
|
-
#
|
36
|
-
# The criteria for a valid plugin in this case is found in Rails::Plugin#valid?, although
|
37
|
-
# other subclasses of Rails::Plugin::Locator can of course use different conditions.
|
38
|
-
class FileSystemLocator < Locator
|
39
|
-
|
40
|
-
# Returns all the plugins which can be loaded in the filesystem, under the paths given
|
41
|
-
# by configuration.plugin_paths.
|
42
|
-
def plugins
|
43
|
-
initializer.configuration.plugin_paths.flatten.inject([]) do |plugins, path|
|
44
|
-
plugins.concat locate_plugins_under(path)
|
45
|
-
plugins
|
46
|
-
end.flatten
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
# Attempts to create a plugin from the given path. If the created plugin is valid?
|
52
|
-
# (see Rails::Plugin#valid?) then the plugin instance is returned; otherwise nil.
|
53
|
-
def create_plugin(path)
|
54
|
-
plugin = Rails::Plugin.new(path)
|
55
|
-
plugin.valid? ? plugin : nil
|
56
|
-
end
|
57
|
-
|
58
|
-
# This starts at the base path looking for valid plugins (see Rails::Plugin#valid?).
|
59
|
-
# Since plugins can be nested arbitrarily deep within an unspecified number of intermediary
|
60
|
-
# directories, this method runs recursively until it finds a plugin directory, e.g.
|
61
|
-
#
|
62
|
-
# locate_plugins_under('vendor/plugins/acts/acts_as_chunky_bacon')
|
63
|
-
# => <Rails::Plugin name: 'acts_as_chunky_bacon' ... >
|
64
|
-
#
|
65
|
-
def locate_plugins_under(base_path)
|
66
|
-
Dir.glob(File.join(base_path, '*')).sort.inject([]) do |plugins, path|
|
67
|
-
if plugin = create_plugin(path)
|
68
|
-
plugins << plugin
|
69
|
-
elsif File.directory?(path)
|
70
|
-
plugins.concat locate_plugins_under(path)
|
71
|
-
end
|
72
|
-
plugins
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# The GemLocator scans all the loaded RubyGems, looking for gems with
|
78
|
-
# a <tt>rails/init.rb</tt> file.
|
79
|
-
class GemLocator < Locator
|
80
|
-
def plugins
|
81
|
-
gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem }
|
82
|
-
specs = gem_index.keys
|
83
|
-
specs += Gem.loaded_specs.values.select do |spec|
|
84
|
-
spec.loaded_from && # prune stubs
|
85
|
-
File.exist?(File.join(spec.full_gem_path, "rails", "init.rb"))
|
86
|
-
end
|
87
|
-
specs.compact!
|
88
|
-
|
89
|
-
require "rubygems/dependency_list"
|
90
|
-
|
91
|
-
deps = Gem::DependencyList.new
|
92
|
-
deps.add(*specs) unless specs.empty?
|
93
|
-
|
94
|
-
deps.dependency_order.collect do |spec|
|
95
|
-
Rails::GemPlugin.new(spec, gem_index[spec])
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|