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,10 +0,0 @@
1
- Description:
2
- Creates a migration to add the sessions table used by the Active Record
3
- session store. Pass the migration name, either CamelCased or under_scored,
4
- as an argument.
5
-
6
- Example:
7
- `./script/generate session_migration CreateSessionTable`
8
-
9
- With 4 existing migrations, this creates the AddSessionTable migration
10
- in db/migrate/005_add_session_table.rb
@@ -1,18 +0,0 @@
1
- class SessionMigrationGenerator < Rails::Generator::NamedBase
2
- def initialize(runtime_args, runtime_options = {})
3
- runtime_args << 'add_session_table' if runtime_args.empty?
4
- super
5
- end
6
-
7
- def manifest
8
- record do |m|
9
- m.migration_template 'migration.rb', 'db/migrate',
10
- :assigns => { :session_table_name => default_session_table_name }
11
- end
12
- end
13
-
14
- protected
15
- def default_session_table_name
16
- ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session'
17
- end
18
- end
@@ -1,16 +0,0 @@
1
- class <%= class_name %> < ActiveRecord::Migration
2
- def self.up
3
- create_table :<%= session_table_name %> do |t|
4
- t.string :session_id, :null => false
5
- t.text :data
6
- t.timestamps
7
- end
8
-
9
- add_index :<%= session_table_name %>, :session_id
10
- add_index :<%= session_table_name %>, :updated_at
11
- end
12
-
13
- def self.down
14
- drop_table :<%= session_table_name %>
15
- end
16
- end
@@ -1,249 +0,0 @@
1
- require 'pathname'
2
-
3
- require File.dirname(__FILE__) + '/spec'
4
-
5
- class Object
6
- class << self
7
- # Lookup missing generators using const_missing. This allows any
8
- # generator to reference another without having to know its location:
9
- # RubyGems, ~/.rails/generators, and RAILS_ROOT/generators.
10
- def lookup_missing_generator(class_id)
11
- if md = /(.+)Generator$/.match(class_id.to_s)
12
- name = md.captures.first.demodulize.underscore
13
- Rails::Generator::Base.lookup(name).klass
14
- else
15
- const_missing_before_generators(class_id)
16
- end
17
- end
18
-
19
- unless respond_to?(:const_missing_before_generators)
20
- alias_method :const_missing_before_generators, :const_missing
21
- alias_method :const_missing, :lookup_missing_generator
22
- end
23
- end
24
- end
25
-
26
- # User home directory lookup adapted from RubyGems.
27
- def Dir.user_home
28
- if ENV['HOME']
29
- ENV['HOME']
30
- elsif ENV['USERPROFILE']
31
- ENV['USERPROFILE']
32
- elsif ENV['HOMEDRIVE'] and ENV['HOMEPATH']
33
- "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
34
- else
35
- File.expand_path '~'
36
- end
37
- end
38
-
39
-
40
- module Rails
41
- module Generator
42
-
43
- # Generator lookup is managed by a list of sources which return specs
44
- # describing where to find and how to create generators. This module
45
- # provides class methods for manipulating the source list and looking up
46
- # generator specs, and an #instance wrapper for quickly instantiating
47
- # generators by name.
48
- #
49
- # A spec is not a generator: it's a description of where to find
50
- # the generator and how to create it. A source is anything that
51
- # yields generators from #each. PathSource and GemGeneratorSource are provided.
52
- module Lookup
53
- def self.included(base)
54
- base.extend(ClassMethods)
55
- base.use_component_sources!
56
- end
57
-
58
- # Convenience method to instantiate another generator.
59
- def instance(generator_name, args, runtime_options = {})
60
- self.class.instance(generator_name, args, runtime_options)
61
- end
62
-
63
- module ClassMethods
64
- # The list of sources where we look, in order, for generators.
65
- def sources
66
- read_inheritable_attribute(:sources) or use_component_sources!
67
- end
68
-
69
- # Add a source to the end of the list.
70
- def append_sources(*args)
71
- sources.concat(args.flatten)
72
- invalidate_cache!
73
- end
74
-
75
- # Add a source to the beginning of the list.
76
- def prepend_sources(*args)
77
- write_inheritable_array(:sources, args.flatten + sources)
78
- invalidate_cache!
79
- end
80
-
81
- # Reset the source list.
82
- def reset_sources
83
- write_inheritable_attribute(:sources, [])
84
- invalidate_cache!
85
- end
86
-
87
- # Use application generators (app, ?).
88
- def use_application_sources!
89
- reset_sources
90
- sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/applications")
91
- end
92
-
93
- # Use component generators (model, controller, etc).
94
- # 1. Rails application. If RAILS_ROOT is defined we know we're
95
- # generating in the context of a Rails application, so search
96
- # RAILS_ROOT/generators.
97
- # 2. Look in plugins, either for generators/ or rails_generators/
98
- # directories within each plugin
99
- # 3. User home directory. Search ~/.rails/generators.
100
- # 4. RubyGems. Search for gems named *_generator, and look for
101
- # generators within any RubyGem's
102
- # /rails_generators/<generator_name>_generator.rb file.
103
- # 5. Builtins. Model, controller, mailer, scaffold, and so on.
104
- def use_component_sources!
105
- reset_sources
106
- if defined? ::RAILS_ROOT
107
- sources << PathSource.new(:lib, "#{::RAILS_ROOT}/lib/generators")
108
- sources << PathSource.new(:vendor, "#{::RAILS_ROOT}/vendor/generators")
109
- Rails.configuration.plugin_paths.each do |path|
110
- relative_path = Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(::RAILS_ROOT))
111
- sources << PathSource.new(:"plugins (#{relative_path})", "#{path}/*/**/{,rails_}generators")
112
- end
113
- end
114
- sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
115
- if Object.const_defined?(:Gem)
116
- sources << GemGeneratorSource.new
117
- sources << GemPathSource.new
118
- end
119
- sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components")
120
- end
121
-
122
- # Lookup knows how to find generators' Specs from a list of Sources.
123
- # Searches the sources, in order, for the first matching name.
124
- def lookup(generator_name)
125
- @found ||= {}
126
- generator_name = generator_name.to_s.downcase
127
- @found[generator_name] ||= cache.find { |spec| spec.name == generator_name }
128
- unless @found[generator_name]
129
- chars = generator_name.scan(/./).map{|c|"#{c}.*?"}
130
- rx = /^#{chars}$/
131
- gns = cache.select{|spec| spec.name =~ rx }
132
- @found[generator_name] ||= gns.first if gns.length == 1
133
- raise GeneratorError, "Pattern '#{generator_name}' matches more than one generator: #{gns.map{|sp|sp.name}.join(', ')}" if gns.length > 1
134
- end
135
- @found[generator_name] or raise GeneratorError, "Couldn't find '#{generator_name}' generator"
136
- end
137
-
138
- # Convenience method to lookup and instantiate a generator.
139
- def instance(generator_name, args = [], runtime_options = {})
140
- lookup(generator_name).klass.new(args, full_options(runtime_options))
141
- end
142
-
143
- private
144
- # Lookup and cache every generator from the source list.
145
- def cache
146
- @cache ||= sources.inject([]) { |cache, source| cache + source.to_a }
147
- end
148
-
149
- # Clear the cache whenever the source list changes.
150
- def invalidate_cache!
151
- @cache = nil
152
- end
153
- end
154
- end
155
-
156
- # Sources enumerate (yield from #each) generator specs which describe
157
- # where to find and how to create generators. Enumerable is mixed in so,
158
- # for example, source.collect will retrieve every generator.
159
- # Sources may be assigned a label to distinguish them.
160
- class Source
161
- include Enumerable
162
-
163
- attr_reader :label
164
- def initialize(label)
165
- @label = label
166
- end
167
-
168
- # The each method must be implemented in subclasses.
169
- # The base implementation raises an error.
170
- def each
171
- raise NotImplementedError
172
- end
173
-
174
- # Return a convenient sorted list of all generator names.
175
- def names
176
- map { |spec| spec.name }.sort
177
- end
178
- end
179
-
180
-
181
- # PathSource looks for generators in a filesystem directory.
182
- class PathSource < Source
183
- attr_reader :path
184
-
185
- def initialize(label, path)
186
- super label
187
- @path = path
188
- end
189
-
190
- # Yield each eligible subdirectory.
191
- def each
192
- Dir["#{path}/[a-z]*"].each do |dir|
193
- if File.directory?(dir)
194
- yield Spec.new(File.basename(dir), dir, label)
195
- end
196
- end
197
- end
198
- end
199
-
200
- class AbstractGemSource < Source
201
- def initialize
202
- super :RubyGems
203
- end
204
- end
205
-
206
- # GemGeneratorSource hits the mines to quarry for generators. The latest versions
207
- # of gems named *_generator are selected.
208
- class GemGeneratorSource < AbstractGemSource
209
- # Yield latest versions of generator gems.
210
- def each
211
- dependency = Gem::Dependency.new(/_generator$/, Gem::Requirement.default)
212
- Gem::cache.search(dependency).inject({}) { |latest, gem|
213
- hem = latest[gem.name]
214
- latest[gem.name] = gem if hem.nil? or gem.version > hem.version
215
- latest
216
- }.values.each { |gem|
217
- yield Spec.new(gem.name.sub(/_generator$/, ''), gem.full_gem_path, label)
218
- }
219
- end
220
- end
221
-
222
- # GemPathSource looks for generators within any RubyGem's /rails_generators/<generator_name>_generator.rb file.
223
- class GemPathSource < AbstractGemSource
224
- # Yield each generator within rails_generator subdirectories.
225
- def each
226
- generator_full_paths.each do |generator|
227
- yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
228
- end
229
- end
230
-
231
- private
232
- def generator_full_paths
233
- @generator_full_paths ||=
234
- Gem::cache.inject({}) do |latest, name_gem|
235
- name, gem = name_gem
236
- hem = latest[gem.name]
237
- latest[gem.name] = gem if hem.nil? or gem.version > hem.version
238
- latest
239
- end.values.inject([]) do |mem, gem|
240
- Dir[gem.full_gem_path + '/{rails_,}generators/**/*_generator.rb'].each do |generator|
241
- mem << generator
242
- end
243
- mem
244
- end
245
- end
246
- end
247
-
248
- end
249
- end
@@ -1,53 +0,0 @@
1
- module Rails
2
- module Generator
3
-
4
- # Manifest captures the actions a generator performs. Instantiate
5
- # a manifest with an optional target object, hammer it with actions,
6
- # then replay or rewind on the object of your choice.
7
- #
8
- # Example:
9
- # manifest = Manifest.new { |m|
10
- # m.make_directory '/foo'
11
- # m.create_file '/foo/bar.txt'
12
- # }
13
- # manifest.replay(creator)
14
- # manifest.rewind(destroyer)
15
- class Manifest
16
- attr_reader :target
17
-
18
- # Take a default action target. Yield self if block given.
19
- def initialize(target = nil)
20
- @target, @actions = target, []
21
- yield self if block_given?
22
- end
23
-
24
- # Record an action.
25
- def method_missing(action, *args, &block)
26
- @actions << [action, args, block]
27
- end
28
-
29
- # Replay recorded actions.
30
- def replay(target = nil)
31
- send_actions(target || @target, @actions)
32
- end
33
-
34
- # Rewind recorded actions.
35
- def rewind(target = nil)
36
- send_actions(target || @target, @actions.reverse)
37
- end
38
-
39
- # Erase recorded actions.
40
- def erase
41
- @actions = []
42
- end
43
-
44
- private
45
- def send_actions(target, actions)
46
- actions.each do |method, args, block|
47
- target.send(method, *args, &block)
48
- end
49
- end
50
- end
51
-
52
- end
53
- end
@@ -1,150 +0,0 @@
1
- require 'optparse'
2
-
3
- module Rails
4
- module Generator
5
- module Options
6
- def self.included(base)
7
- base.extend(ClassMethods)
8
- class << base
9
- if respond_to?(:inherited)
10
- alias_method :inherited_without_options, :inherited
11
- end
12
- alias_method :inherited, :inherited_with_options
13
- end
14
- end
15
-
16
- module ClassMethods
17
- def inherited_with_options(sub)
18
- inherited_without_options(sub) if respond_to?(:inherited_without_options)
19
- sub.extend(Rails::Generator::Options::ClassMethods)
20
- end
21
-
22
- def mandatory_options(options = nil)
23
- if options
24
- write_inheritable_attribute(:mandatory_options, options)
25
- else
26
- read_inheritable_attribute(:mandatory_options) or write_inheritable_attribute(:mandatory_options, {})
27
- end
28
- end
29
-
30
- def default_options(options = nil)
31
- if options
32
- write_inheritable_attribute(:default_options, options)
33
- else
34
- read_inheritable_attribute(:default_options) or write_inheritable_attribute(:default_options, {})
35
- end
36
- end
37
-
38
- # Merge together our class options. In increasing precedence:
39
- # default_options (class default options)
40
- # runtime_options (provided as argument)
41
- # mandatory_options (class mandatory options)
42
- def full_options(runtime_options = {})
43
- default_options.merge(runtime_options).merge(mandatory_options)
44
- end
45
-
46
- end
47
-
48
- # Each instance has an options hash that's populated by #parse.
49
- def options
50
- @options ||= {}
51
- end
52
- attr_writer :options
53
-
54
- protected
55
- # Convenient access to class mandatory options.
56
- def mandatory_options
57
- self.class.mandatory_options
58
- end
59
-
60
- # Convenient access to class default options.
61
- def default_options
62
- self.class.default_options
63
- end
64
-
65
- # Merge together our instance options. In increasing precedence:
66
- # default_options (class default options)
67
- # options (instance options)
68
- # runtime_options (provided as argument)
69
- # mandatory_options (class mandatory options)
70
- def full_options(runtime_options = {})
71
- self.class.full_options(options.merge(runtime_options))
72
- end
73
-
74
- # Parse arguments into the options hash. Classes may customize
75
- # parsing behavior by overriding these methods:
76
- # #banner Usage: ./script/generate [options]
77
- # #add_options! Options:
78
- # some options..
79
- # #add_general_options! General Options:
80
- # general options..
81
- def parse!(args, runtime_options = {})
82
- self.options = {}
83
-
84
- @option_parser = OptionParser.new do |opt|
85
- opt.banner = banner
86
- add_options!(opt)
87
- add_general_options!(opt)
88
- opt.parse!(args)
89
- end
90
-
91
- return args
92
- ensure
93
- self.options = full_options(runtime_options)
94
- end
95
-
96
- # Raise a usage error. Override usage_message to provide a blurb
97
- # after the option parser summary.
98
- def usage(message = usage_message)
99
- raise UsageError, "#{@option_parser}\n#{message}"
100
- end
101
-
102
- def usage_message
103
- ''
104
- end
105
-
106
- # Override with your own usage banner.
107
- def banner
108
- "Usage: #{$0} [options]"
109
- end
110
-
111
- # Override to add your options to the parser:
112
- # def add_options!(opt)
113
- # opt.on('-v', '--verbose') { |value| options[:verbose] = value }
114
- # end
115
- def add_options!(opt)
116
- end
117
-
118
- # Adds general options like -h and --quiet. Usually don't override.
119
- def add_general_options!(opt)
120
- opt.separator ''
121
- opt.separator 'Rails Info:'
122
- opt.on('-v', '--version', 'Show the Rails version number and quit.')
123
- opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
124
-
125
- opt.separator ''
126
- opt.separator 'General Options:'
127
-
128
- opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
129
- opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
130
- opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
131
- opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
132
- opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
133
- opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
134
- options[:svn] = {}
135
- `svn status`.each_line do |line|
136
- options[:svn][line.chomp[7..-1]] = true
137
- end
138
- end
139
- opt.on('-g', '--git', 'Modify files with git. (Note: git must be in path)') do
140
- options[:git] = {:new => {}, :modified => {}}
141
- `git status`.each_line do |line|
142
- options[:git][:new][line.chomp[14..-1]] = true if line =~ /new file:/
143
- options[:git][:modified][line.chomp[14..-1]] = true if line =~ /modified:/
144
- end
145
- end
146
- end
147
-
148
- end
149
- end
150
- end