rails 2.3.18 → 3.0.0

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.

Files changed (215) hide show
  1. data/bin/rails +8 -20
  2. metadata +74 -251
  3. data/CHANGELOG +0 -2193
  4. data/MIT-LICENSE +0 -20
  5. data/README +0 -243
  6. data/Rakefile +0 -365
  7. data/bin/about +0 -4
  8. data/bin/console +0 -3
  9. data/bin/dbconsole +0 -3
  10. data/bin/destroy +0 -3
  11. data/bin/generate +0 -3
  12. data/bin/performance/benchmarker +0 -3
  13. data/bin/performance/profiler +0 -3
  14. data/bin/plugin +0 -3
  15. data/bin/runner +0 -3
  16. data/bin/server +0 -3
  17. data/builtin/rails_info/rails/info.rb +0 -131
  18. data/builtin/rails_info/rails/info_controller.rb +0 -9
  19. data/builtin/rails_info/rails/info_helper.rb +0 -2
  20. data/builtin/rails_info/rails_info_controller.rb +0 -2
  21. data/configs/databases/frontbase.yml +0 -28
  22. data/configs/databases/ibm_db.yml +0 -62
  23. data/configs/databases/mysql.yml +0 -60
  24. data/configs/databases/oracle.yml +0 -39
  25. data/configs/databases/postgresql.yml +0 -51
  26. data/configs/databases/sqlite2.yml +0 -19
  27. data/configs/databases/sqlite3.yml +0 -22
  28. data/configs/empty.log +0 -0
  29. data/configs/initializers/backtrace_silencers.rb +0 -7
  30. data/configs/initializers/cookie_verification_secret.rb +0 -7
  31. data/configs/initializers/inflections.rb +0 -10
  32. data/configs/initializers/mime_types.rb +0 -5
  33. data/configs/initializers/new_rails_defaults.rb +0 -21
  34. data/configs/initializers/session_store.rb +0 -15
  35. data/configs/locales/en.yml +0 -5
  36. data/configs/routes.rb +0 -43
  37. data/configs/seeds.rb +0 -7
  38. data/dispatches/config.ru +0 -7
  39. data/dispatches/dispatch.fcgi +0 -24
  40. data/dispatches/dispatch.rb +0 -10
  41. data/dispatches/gateway.cgi +0 -97
  42. data/doc/README_FOR_APP +0 -2
  43. data/environments/boot.rb +0 -114
  44. data/environments/development.rb +0 -17
  45. data/environments/environment.rb +0 -41
  46. data/environments/production.rb +0 -28
  47. data/environments/test.rb +0 -28
  48. data/fresh_rakefile +0 -10
  49. data/helpers/application_controller.rb +0 -10
  50. data/helpers/application_helper.rb +0 -3
  51. data/helpers/performance_test.rb +0 -9
  52. data/helpers/test_helper.rb +0 -38
  53. data/html/404.html +0 -30
  54. data/html/422.html +0 -30
  55. data/html/500.html +0 -30
  56. data/html/favicon.ico +0 -0
  57. data/html/images/rails.png +0 -0
  58. data/html/index.html +0 -275
  59. data/html/javascripts/application.js +0 -2
  60. data/html/javascripts/controls.js +0 -963
  61. data/html/javascripts/dragdrop.js +0 -973
  62. data/html/javascripts/effects.js +0 -1128
  63. data/html/javascripts/prototype.js +0 -4320
  64. data/html/robots.txt +0 -5
  65. data/lib/code_statistics.rb +0 -107
  66. data/lib/commands.rb +0 -17
  67. data/lib/commands/about.rb +0 -3
  68. data/lib/commands/console.rb +0 -45
  69. data/lib/commands/dbconsole.rb +0 -87
  70. data/lib/commands/destroy.rb +0 -6
  71. data/lib/commands/generate.rb +0 -6
  72. data/lib/commands/ncgi/listener +0 -86
  73. data/lib/commands/ncgi/tracker +0 -69
  74. data/lib/commands/performance/benchmarker.rb +0 -24
  75. data/lib/commands/performance/profiler.rb +0 -50
  76. data/lib/commands/plugin.rb +0 -968
  77. data/lib/commands/runner.rb +0 -54
  78. data/lib/commands/server.rb +0 -114
  79. data/lib/commands/update.rb +0 -4
  80. data/lib/console_app.rb +0 -30
  81. data/lib/console_sandbox.rb +0 -6
  82. data/lib/console_with_helpers.rb +0 -5
  83. data/lib/dispatcher.rb +0 -24
  84. data/lib/fcgi_handler.rb +0 -239
  85. data/lib/initializer.rb +0 -1152
  86. data/lib/performance_test_help.rb +0 -5
  87. data/lib/rails/backtrace_cleaner.rb +0 -54
  88. data/lib/rails/gem_builder.rb +0 -21
  89. data/lib/rails/gem_dependency.rb +0 -317
  90. data/lib/rails/plugin.rb +0 -179
  91. data/lib/rails/plugin/loader.rb +0 -198
  92. data/lib/rails/plugin/locator.rb +0 -100
  93. data/lib/rails/rack.rb +0 -8
  94. data/lib/rails/rack/debugger.rb +0 -23
  95. data/lib/rails/rack/log_tailer.rb +0 -35
  96. data/lib/rails/rack/metal.rb +0 -51
  97. data/lib/rails/rack/static.rb +0 -46
  98. data/lib/rails/vendor_gem_source_index.rb +0 -140
  99. data/lib/rails/version.rb +0 -9
  100. data/lib/rails_generator.rb +0 -46
  101. data/lib/rails_generator/base.rb +0 -266
  102. data/lib/rails_generator/commands.rb +0 -621
  103. data/lib/rails_generator/generated_attribute.rb +0 -47
  104. data/lib/rails_generator/generators/applications/app/USAGE +0 -9
  105. data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -266
  106. data/lib/rails_generator/generators/applications/app/scm/git.rb +0 -18
  107. data/lib/rails_generator/generators/applications/app/scm/scm.rb +0 -8
  108. data/lib/rails_generator/generators/applications/app/scm/svn.rb +0 -7
  109. data/lib/rails_generator/generators/applications/app/template_runner.rb +0 -401
  110. data/lib/rails_generator/generators/components/controller/USAGE +0 -30
  111. data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -43
  112. data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
  113. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
  114. data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
  115. data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +0 -4
  116. data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
  117. data/lib/rails_generator/generators/components/helper/USAGE +0 -24
  118. data/lib/rails_generator/generators/components/helper/helper_generator.rb +0 -25
  119. data/lib/rails_generator/generators/components/helper/templates/helper.rb +0 -2
  120. data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +0 -4
  121. data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
  122. data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
  123. data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
  124. data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
  125. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
  126. data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
  127. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
  128. data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
  129. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
  130. data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
  131. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
  132. data/lib/rails_generator/generators/components/metal/USAGE +0 -8
  133. data/lib/rails_generator/generators/components/metal/metal_generator.rb +0 -8
  134. data/lib/rails_generator/generators/components/metal/templates/metal.rb +0 -12
  135. data/lib/rails_generator/generators/components/migration/USAGE +0 -29
  136. data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
  137. data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
  138. data/lib/rails_generator/generators/components/model/USAGE +0 -27
  139. data/lib/rails_generator/generators/components/model/model_generator.rb +0 -52
  140. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -23
  141. data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
  142. data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
  143. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
  144. data/lib/rails_generator/generators/components/observer/USAGE +0 -13
  145. data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
  146. data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
  147. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
  148. data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
  149. data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
  150. data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
  151. data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
  152. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
  153. data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
  154. data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
  155. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
  156. data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
  157. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
  158. data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
  159. data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
  160. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
  161. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
  162. data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -4
  163. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
  164. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
  165. data/lib/rails_generator/generators/components/resource/USAGE +0 -23
  166. data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -76
  167. data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
  168. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
  169. data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
  170. data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +0 -4
  171. data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
  172. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -103
  173. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -83
  174. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
  175. data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
  176. data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +0 -4
  177. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
  178. data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
  179. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
  180. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
  181. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
  182. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
  183. data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
  184. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
  185. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
  186. data/lib/rails_generator/lookup.rb +0 -249
  187. data/lib/rails_generator/manifest.rb +0 -53
  188. data/lib/rails_generator/options.rb +0 -150
  189. data/lib/rails_generator/scripts.rb +0 -89
  190. data/lib/rails_generator/scripts/destroy.rb +0 -29
  191. data/lib/rails_generator/scripts/generate.rb +0 -7
  192. data/lib/rails_generator/scripts/update.rb +0 -12
  193. data/lib/rails_generator/secret_key_generator.rb +0 -24
  194. data/lib/rails_generator/simple_logger.rb +0 -46
  195. data/lib/rails_generator/spec.rb +0 -44
  196. data/lib/railties_path.rb +0 -1
  197. data/lib/ruby_version_check.rb +0 -17
  198. data/lib/rubyprof_ext.rb +0 -35
  199. data/lib/source_annotation_extractor.rb +0 -102
  200. data/lib/tasks/annotations.rake +0 -20
  201. data/lib/tasks/databases.rake +0 -436
  202. data/lib/tasks/documentation.rake +0 -93
  203. data/lib/tasks/framework.rake +0 -146
  204. data/lib/tasks/gems.rake +0 -78
  205. data/lib/tasks/log.rake +0 -9
  206. data/lib/tasks/middleware.rake +0 -7
  207. data/lib/tasks/misc.rake +0 -63
  208. data/lib/tasks/rails.rb +0 -14
  209. data/lib/tasks/routes.rake +0 -18
  210. data/lib/tasks/statistics.rake +0 -17
  211. data/lib/tasks/testing.rake +0 -139
  212. data/lib/tasks/tmp.rake +0 -37
  213. data/lib/test_help.rb +0 -38
  214. data/lib/webrick_server.rb +0 -156
  215. data/railties.gemspec +0 -22
@@ -1,5 +0,0 @@
1
- require 'action_controller/performance_test'
2
-
3
- ActionController::Base.perform_caching = true
4
- ActiveSupport::Dependencies.mechanism = :require
5
- Rails.logger.level = ActiveSupport::BufferedLogger::INFO
@@ -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
@@ -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
@@ -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.rb DELETED
@@ -1,179 +0,0 @@
1
- module Rails
2
- # The Plugin class should be an object which provides the following methods:
3
- #
4
- # * +name+ - Used during initialisation to order the plugin (based on name and
5
- # the contents of <tt>config.plugins</tt>).
6
- # * +valid?+ - Returns true if this plugin can be loaded.
7
- # * +load_paths+ - Each path within the returned array will be added to the <tt>$LOAD_PATH</tt>.
8
- # * +load+ - Finally 'load' the plugin.
9
- #
10
- # These methods are expected by the Rails::Plugin::Locator and Rails::Plugin::Loader classes.
11
- # The default implementation returns the <tt>lib</tt> directory as its <tt>load_paths</tt>,
12
- # and evaluates <tt>init.rb</tt> when <tt>load</tt> is called.
13
- #
14
- # You can also inspect the about.yml data programmatically:
15
- #
16
- # plugin = Rails::Plugin.new(path_to_my_plugin)
17
- # plugin.about["author"] # => "James Adam"
18
- # plugin.about["url"] # => "http://interblah.net"
19
- class Plugin
20
- include Comparable
21
-
22
- attr_reader :directory, :name
23
-
24
- def initialize(directory)
25
- @directory = directory
26
- @name = File.basename(@directory) rescue nil
27
- @loaded = false
28
- end
29
-
30
- def valid?
31
- File.directory?(directory) && (has_app_directory? || has_lib_directory? || has_init_file?)
32
- end
33
-
34
- # Returns a list of paths this plugin wishes to make available in <tt>$LOAD_PATH</tt>.
35
- def load_paths
36
- report_nonexistant_or_empty_plugin! unless valid?
37
-
38
- [].tap do |load_paths|
39
- load_paths << lib_path if has_lib_directory?
40
- load_paths << app_paths if has_app_directory?
41
- end.flatten
42
- end
43
-
44
- # Evaluates a plugin's init.rb file.
45
- def load(initializer)
46
- return if loaded?
47
- report_nonexistant_or_empty_plugin! unless valid?
48
- evaluate_init_rb(initializer)
49
- @loaded = true
50
- end
51
-
52
- def loaded?
53
- @loaded
54
- end
55
-
56
- def <=>(other_plugin)
57
- name <=> other_plugin.name
58
- end
59
-
60
- def about
61
- @about ||= load_about_information
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
- # Returns true if there is any localization file in locale_path
75
- def localized?
76
- locale_files.any?
77
- end
78
-
79
- def view_path
80
- File.join(directory, 'app', 'views')
81
- end
82
-
83
- def controller_path
84
- File.join(directory, 'app', 'controllers')
85
- end
86
-
87
- def metal_path
88
- File.join(directory, 'app', 'metal')
89
- end
90
-
91
- def routing_file
92
- File.join(directory, 'config', 'routes.rb')
93
- end
94
-
95
- def locale_path
96
- File.join(directory, 'config', 'locales')
97
- end
98
-
99
- def locale_files
100
- Dir[ File.join(locale_path, '*.{rb,yml}') ]
101
- end
102
-
103
-
104
- private
105
- def load_about_information
106
- about_yml_path = File.join(@directory, "about.yml")
107
- parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {}
108
- parsed_yml || {}
109
- rescue Exception
110
- {}
111
- end
112
-
113
- def report_nonexistant_or_empty_plugin!
114
- raise LoadError, "Can not find the plugin named: #{name}"
115
- end
116
-
117
-
118
- def app_paths
119
- [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ]
120
- end
121
-
122
- def lib_path
123
- File.join(directory, 'lib')
124
- end
125
-
126
- def classic_init_path
127
- File.join(directory, 'init.rb')
128
- end
129
-
130
- def gem_init_path
131
- File.join(directory, 'rails', 'init.rb')
132
- end
133
-
134
- def init_path
135
- File.file?(gem_init_path) ? gem_init_path : classic_init_path
136
- end
137
-
138
-
139
- def has_app_directory?
140
- File.directory?(File.join(directory, 'app'))
141
- end
142
-
143
- def has_lib_directory?
144
- File.directory?(lib_path)
145
- end
146
-
147
- def has_init_file?
148
- File.file?(init_path)
149
- end
150
-
151
-
152
- def evaluate_init_rb(initializer)
153
- if has_init_file?
154
- silence_warnings do
155
- # Allow plugins to reference the current configuration object
156
- config = initializer.configuration
157
-
158
- eval(IO.read(init_path), binding, init_path)
159
- end
160
- end
161
- end
162
- end
163
-
164
- # This Plugin subclass represents a Gem plugin. Although RubyGems has already
165
- # taken care of $LOAD_PATHs, it exposes its load_paths to add them
166
- # to Dependencies.load_paths.
167
- class GemPlugin < Plugin
168
- # Initialize this plugin from a Gem::Specification.
169
- def initialize(spec, gem)
170
- directory = spec.full_gem_path
171
- super(directory)
172
- @name = spec.name
173
- end
174
-
175
- def init_path
176
- File.join(directory, 'rails', 'init.rb')
177
- end
178
- end
179
- end