rails 1.0.0 → 7.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 (156) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +103 -0
  3. metadata +228 -294
  4. data/CHANGELOG +0 -865
  5. data/MIT-LICENSE +0 -20
  6. data/README +0 -153
  7. data/Rakefile +0 -422
  8. data/bin/about +0 -3
  9. data/bin/breakpointer +0 -3
  10. data/bin/console +0 -3
  11. data/bin/destroy +0 -3
  12. data/bin/generate +0 -3
  13. data/bin/performance/benchmarker +0 -3
  14. data/bin/performance/profiler +0 -3
  15. data/bin/plugin +0 -3
  16. data/bin/process/reaper +0 -3
  17. data/bin/process/spawner +0 -3
  18. data/bin/process/spinner +0 -3
  19. data/bin/rails +0 -21
  20. data/bin/runner +0 -3
  21. data/bin/server +0 -3
  22. data/builtin/controllers/rails_info_controller.rb +0 -11
  23. data/configs/apache.conf +0 -40
  24. data/configs/database.yml +0 -85
  25. data/configs/empty.log +0 -0
  26. data/configs/lighttpd.conf +0 -40
  27. data/configs/routes.rb +0 -19
  28. data/dispatches/dispatch.fcgi +0 -24
  29. data/dispatches/dispatch.rb +0 -10
  30. data/dispatches/gateway.cgi +0 -97
  31. data/doc/README_FOR_APP +0 -2
  32. data/environments/boot.rb +0 -19
  33. data/environments/development.rb +0 -19
  34. data/environments/environment.rb +0 -53
  35. data/environments/production.rb +0 -19
  36. data/environments/test.rb +0 -19
  37. data/fresh_rakefile +0 -10
  38. data/helpers/application.rb +0 -4
  39. data/helpers/application_helper.rb +0 -3
  40. data/helpers/test_helper.rb +0 -28
  41. data/html/404.html +0 -8
  42. data/html/500.html +0 -8
  43. data/html/favicon.ico +0 -0
  44. data/html/images/rails.png +0 -0
  45. data/html/index.html +0 -277
  46. data/html/javascripts/controls.js +0 -750
  47. data/html/javascripts/dragdrop.js +0 -584
  48. data/html/javascripts/effects.js +0 -854
  49. data/html/javascripts/prototype.js +0 -1785
  50. data/html/robots.txt +0 -1
  51. data/lib/binding_of_caller.rb +0 -85
  52. data/lib/breakpoint.rb +0 -523
  53. data/lib/breakpoint_client.rb +0 -196
  54. data/lib/code_statistics.rb +0 -107
  55. data/lib/commands/about.rb +0 -2
  56. data/lib/commands/breakpointer.rb +0 -1
  57. data/lib/commands/console.rb +0 -23
  58. data/lib/commands/destroy.rb +0 -6
  59. data/lib/commands/generate.rb +0 -6
  60. data/lib/commands/ncgi/listener +0 -86
  61. data/lib/commands/ncgi/tracker +0 -69
  62. data/lib/commands/performance/benchmarker.rb +0 -24
  63. data/lib/commands/performance/profiler.rb +0 -34
  64. data/lib/commands/plugin.rb +0 -823
  65. data/lib/commands/process/reaper.rb +0 -130
  66. data/lib/commands/process/spawner.rb +0 -52
  67. data/lib/commands/process/spinner.rb +0 -57
  68. data/lib/commands/runner.rb +0 -27
  69. data/lib/commands/server.rb +0 -28
  70. data/lib/commands/servers/lighttpd.rb +0 -60
  71. data/lib/commands/servers/webrick.rb +0 -59
  72. data/lib/commands/update.rb +0 -4
  73. data/lib/commands.rb +0 -17
  74. data/lib/console_sandbox.rb +0 -6
  75. data/lib/dispatcher.rb +0 -99
  76. data/lib/fcgi_handler.rb +0 -189
  77. data/lib/initializer.rb +0 -553
  78. data/lib/rails_generator/base.rb +0 -203
  79. data/lib/rails_generator/commands.rb +0 -509
  80. data/lib/rails_generator/generators/applications/app/USAGE +0 -16
  81. data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -140
  82. data/lib/rails_generator/generators/components/controller/USAGE +0 -30
  83. data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -38
  84. data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -10
  85. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -18
  86. data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
  87. data/lib/rails_generator/generators/components/controller/templates/view.rhtml +0 -2
  88. data/lib/rails_generator/generators/components/mailer/USAGE +0 -18
  89. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -32
  90. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -3
  91. data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -13
  92. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -37
  93. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -3
  94. data/lib/rails_generator/generators/components/migration/USAGE +0 -14
  95. data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -7
  96. data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -7
  97. data/lib/rails_generator/generators/components/model/USAGE +0 -17
  98. data/lib/rails_generator/generators/components/model/model_generator.rb +0 -18
  99. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -5
  100. data/lib/rails_generator/generators/components/model/templates/model.rb +0 -2
  101. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -10
  102. data/lib/rails_generator/generators/components/plugin/USAGE +0 -33
  103. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -33
  104. data/lib/rails_generator/generators/components/plugin/templates/README +0 -4
  105. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -22
  106. data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
  107. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
  108. data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
  109. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
  110. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
  111. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
  112. data/lib/rails_generator/generators/components/scaffold/USAGE +0 -32
  113. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -184
  114. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -54
  115. data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +0 -3
  116. data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +0 -1
  117. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -98
  118. data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
  119. data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +0 -13
  120. data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -74
  121. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +0 -9
  122. data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +0 -27
  123. data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +0 -8
  124. data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +0 -8
  125. data/lib/rails_generator/generators/components/session_migration/USAGE +0 -15
  126. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -12
  127. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -15
  128. data/lib/rails_generator/generators/components/web_service/USAGE +0 -28
  129. data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +0 -5
  130. data/lib/rails_generator/generators/components/web_service/templates/controller.rb +0 -8
  131. data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +0 -19
  132. data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +0 -29
  133. data/lib/rails_generator/lookup.rb +0 -210
  134. data/lib/rails_generator/manifest.rb +0 -53
  135. data/lib/rails_generator/options.rb +0 -140
  136. data/lib/rails_generator/scripts/destroy.rb +0 -7
  137. data/lib/rails_generator/scripts/generate.rb +0 -7
  138. data/lib/rails_generator/scripts/update.rb +0 -12
  139. data/lib/rails_generator/scripts.rb +0 -83
  140. data/lib/rails_generator/simple_logger.rb +0 -46
  141. data/lib/rails_generator/spec.rb +0 -44
  142. data/lib/rails_generator.rb +0 -43
  143. data/lib/rails_info.rb +0 -104
  144. data/lib/rails_version.rb +0 -9
  145. data/lib/railties_path.rb +0 -1
  146. data/lib/rubyprof_ext.rb +0 -35
  147. data/lib/tasks/databases.rake +0 -158
  148. data/lib/tasks/documentation.rake +0 -76
  149. data/lib/tasks/framework.rake +0 -71
  150. data/lib/tasks/javascripts.rake +0 -6
  151. data/lib/tasks/misc.rake +0 -19
  152. data/lib/tasks/rails.rb +0 -8
  153. data/lib/tasks/statistics.rake +0 -16
  154. data/lib/tasks/testing.rake +0 -50
  155. data/lib/test_help.rb +0 -17
  156. data/lib/webrick_server.rb +0 -170
@@ -1,509 +0,0 @@
1
- require 'delegate'
2
- require 'optparse'
3
- require 'fileutils'
4
- require 'erb'
5
-
6
- module Rails
7
- module Generator
8
- module Commands
9
- # Here's a convenient way to get a handle on generator commands.
10
- # Command.instance('destroy', my_generator) instantiates a Destroy
11
- # delegate of my_generator ready to do your dirty work.
12
- def self.instance(command, generator)
13
- const_get(command.to_s.camelize).new(generator)
14
- end
15
-
16
- # Even more convenient access to commands. Include Commands in
17
- # the generator Base class to get a nice #command instance method
18
- # which returns a delegate for the requested command.
19
- def self.append_features(base)
20
- base.send(:define_method, :command) do |command|
21
- Commands.instance(command, self)
22
- end
23
- end
24
-
25
-
26
- # Generator commands delegate Rails::Generator::Base and implement
27
- # a standard set of actions. Their behavior is defined by the way
28
- # they respond to these actions: Create brings life; Destroy brings
29
- # death; List passively observes.
30
- #
31
- # Commands are invoked by replaying (or rewinding) the generator's
32
- # manifest of actions. See Rails::Generator::Manifest and
33
- # Rails::Generator::Base#manifest method that generator subclasses
34
- # are required to override.
35
- #
36
- # Commands allows generators to "plug in" invocation behavior, which
37
- # corresponds to the GoF Strategy pattern.
38
- class Base < DelegateClass(Rails::Generator::Base)
39
- # Replay action manifest. RewindBase subclass rewinds manifest.
40
- def invoke!
41
- manifest.replay(self)
42
- end
43
-
44
- def dependency(generator_name, args, runtime_options = {})
45
- logger.dependency(generator_name) do
46
- self.class.new(instance(generator_name, args, full_options(runtime_options))).invoke!
47
- end
48
- end
49
-
50
- # Does nothing for all commands except Create.
51
- def class_collisions(*class_names)
52
- end
53
-
54
- # Does nothing for all commands except Create.
55
- def readme(*args)
56
- end
57
-
58
- protected
59
- def migration_directory(relative_path)
60
- directory(@migration_directory = relative_path)
61
- end
62
-
63
- def existing_migrations(file_name)
64
- Dir.glob("#{@migration_directory}/[0-9]*_#{file_name}.rb")
65
- end
66
-
67
- def migration_exists?(file_name)
68
- not existing_migrations(file_name).empty?
69
- end
70
-
71
- def current_migration_number
72
- Dir.glob("#{@migration_directory}/[0-9]*.rb").inject(0) do |max, file_path|
73
- n = File.basename(file_path).split('_', 2).first.to_i
74
- if n > max then n else max end
75
- end
76
- end
77
-
78
- def next_migration_number
79
- current_migration_number + 1
80
- end
81
-
82
- def next_migration_string(padding = 3)
83
- "%.#{padding}d" % next_migration_number
84
- end
85
-
86
- private
87
- # Ask the user interactively whether to force collision.
88
- def force_file_collision?(destination)
89
- $stdout.print "overwrite #{destination}? [Ynaq] "
90
- case $stdin.gets
91
- when /a/i
92
- $stdout.puts "forcing #{spec.name}"
93
- options[:collision] = :force
94
- when /q/i
95
- $stdout.puts "aborting #{spec.name}"
96
- raise SystemExit
97
- when /n/i then :skip
98
- else :force
99
- end
100
- rescue
101
- retry
102
- end
103
-
104
- def render_template_part(template_options)
105
- # Getting Sandbox to evaluate part template in it
106
- part_binding = template_options[:sandbox].call.sandbox_binding
107
- part_rel_path = template_options[:insert]
108
- part_path = source_path(part_rel_path)
109
-
110
- # Render inner template within Sandbox binding
111
- rendered_part = ERB.new(File.readlines(part_path).join, nil, '-').result(part_binding)
112
- begin_mark = template_part_mark(template_options[:begin_mark], template_options[:mark_id])
113
- end_mark = template_part_mark(template_options[:end_mark], template_options[:mark_id])
114
- begin_mark + rendered_part + end_mark
115
- end
116
-
117
- def template_part_mark(name, id)
118
- "<!--[#{name}:#{id}]-->\n"
119
- end
120
- end
121
-
122
- # Base class for commands which handle generator actions in reverse, such as Destroy.
123
- class RewindBase < Base
124
- # Rewind action manifest.
125
- def invoke!
126
- manifest.rewind(self)
127
- end
128
- end
129
-
130
-
131
- # Create is the premier generator command. It copies files, creates
132
- # directories, renders templates, and more.
133
- class Create < Base
134
-
135
- # Check whether the given class names are already taken by
136
- # Ruby or Rails. In the future, expand to check other namespaces
137
- # such as the rest of the user's app.
138
- def class_collisions(*class_names)
139
- class_names.flatten.each do |class_name|
140
- # Convert to string to allow symbol arguments.
141
- class_name = class_name.to_s
142
-
143
- # Skip empty strings.
144
- next if class_name.strip.empty?
145
-
146
- # Split the class from its module nesting.
147
- nesting = class_name.split('::')
148
- name = nesting.pop
149
-
150
- # Extract the last Module in the nesting.
151
- last = nesting.inject(Object) { |last, nest|
152
- break unless last.const_defined?(nest)
153
- last.const_get(nest)
154
- }
155
-
156
- # If the last Module exists, check whether the given
157
- # class exists and raise a collision if so.
158
- if last and last.const_defined?(name.camelize)
159
- raise_class_collision(class_name)
160
- end
161
- end
162
- end
163
-
164
- # Copy a file from source to destination with collision checking.
165
- #
166
- # The file_options hash accepts :chmod and :shebang options.
167
- # :chmod sets the permissions of the destination file:
168
- # file 'config/empty.log', 'log/test.log', :chmod => 0664
169
- # :shebang sets the #!/usr/bin/ruby line for scripts
170
- # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby'
171
- #
172
- # Collisions are handled by checking whether the destination file
173
- # exists and either skipping the file, forcing overwrite, or asking
174
- # the user what to do.
175
- def file(relative_source, relative_destination, file_options = {}, &block)
176
- # Determine full paths for source and destination files.
177
- source = source_path(relative_source)
178
- destination = destination_path(relative_destination)
179
- destination_exists = File.exists?(destination)
180
-
181
- # If source and destination are identical then we're done.
182
- if destination_exists and identical?(source, destination, &block)
183
- return logger.identical(relative_destination)
184
- end
185
-
186
- # Check for and resolve file collisions.
187
- if destination_exists
188
-
189
- # Make a choice whether to overwrite the file. :force and
190
- # :skip already have their mind made up, but give :ask a shot.
191
- choice = case options[:collision].to_sym #|| :ask
192
- when :ask then force_file_collision?(relative_destination)
193
- when :force then :force
194
- when :skip then :skip
195
- else raise "Invalid collision option: #{options[:collision].inspect}"
196
- end
197
-
198
- # Take action based on our choice. Bail out if we chose to
199
- # skip the file; otherwise, log our transgression and continue.
200
- case choice
201
- when :force then logger.force(relative_destination)
202
- when :skip then return(logger.skip(relative_destination))
203
- else raise "Invalid collision choice: #{choice}.inspect"
204
- end
205
-
206
- # File doesn't exist so log its unbesmirched creation.
207
- else
208
- logger.create relative_destination
209
- end
210
-
211
- # If we're pretending, back off now.
212
- return if options[:pretend]
213
-
214
- # Write destination file with optional shebang. Yield for content
215
- # if block given so templaters may render the source file. If a
216
- # shebang is requested, replace the existing shebang or insert a
217
- # new one.
218
- File.open(destination, 'wb') do |df|
219
- File.open(source, 'rb') do |sf|
220
- if block_given?
221
- df.write(yield(sf))
222
- else
223
- if file_options[:shebang]
224
- df.puts("#!#{file_options[:shebang]}")
225
- if line = sf.gets
226
- df.puts(line) if line !~ /^#!/
227
- end
228
- end
229
- df.write(sf.read)
230
- end
231
- end
232
- end
233
-
234
- # Optionally change permissions.
235
- if file_options[:chmod]
236
- FileUtils.chmod(file_options[:chmod], destination)
237
- end
238
-
239
- # Optionally add file to subversion
240
- system("svn add #{destination}") if options[:svn]
241
- end
242
-
243
- # Checks if the source and the destination file are identical. If
244
- # passed a block then the source file is a template that needs to first
245
- # be evaluated before being compared to the destination.
246
- def identical?(source, destination, &block)
247
- return false if File.directory? destination
248
- source = block_given? ? File.open(source) {|sf| yield(sf)} : IO.read(source)
249
- destination = IO.read(destination)
250
- source == destination
251
- end
252
-
253
- # Generate a file for a Rails application using an ERuby template.
254
- # Looks up and evalutes a template by name and writes the result.
255
- #
256
- # The ERB template uses explicit trim mode to best control the
257
- # proliferation of whitespace in generated code. <%- trims leading
258
- # whitespace; -%> trims trailing whitespace including one newline.
259
- #
260
- # A hash of template options may be passed as the last argument.
261
- # The options accepted by the file are accepted as well as :assigns,
262
- # a hash of variable bindings. Example:
263
- # template 'foo', 'bar', :assigns => { :action => 'view' }
264
- #
265
- # Template is implemented in terms of file. It calls file with a
266
- # block which takes a file handle and returns its rendered contents.
267
- def template(relative_source, relative_destination, template_options = {})
268
- file(relative_source, relative_destination, template_options) do |file|
269
- # Evaluate any assignments in a temporary, throwaway binding.
270
- vars = template_options[:assigns] || {}
271
- b = binding
272
- vars.each { |k,v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b }
273
-
274
- # Render the source file with the temporary binding.
275
- ERB.new(file.read, nil, '-').result(b)
276
- end
277
- end
278
-
279
- def complex_template(relative_source, relative_destination, template_options = {})
280
- options = template_options.dup
281
- options[:assigns] ||= {}
282
- options[:assigns]['template_for_inclusion'] = render_template_part(template_options)
283
- template(relative_source, relative_destination, options)
284
- end
285
-
286
- # Create a directory including any missing parent directories.
287
- # Always directories which exist.
288
- def directory(relative_path)
289
- path = destination_path(relative_path)
290
- if File.exists?(path)
291
- logger.exists relative_path
292
- else
293
- logger.create relative_path
294
- FileUtils.mkdir_p(path) unless options[:pretend]
295
-
296
- # Optionally add file to subversion
297
- system("svn add #{path}") if options[:svn]
298
- end
299
- end
300
-
301
- # Display a README.
302
- def readme(*relative_sources)
303
- relative_sources.flatten.each do |relative_source|
304
- logger.readme relative_source
305
- puts File.read(source_path(relative_source)) unless options[:pretend]
306
- end
307
- end
308
-
309
- # When creating a migration, it knows to find the first available file in db/migrate and use the migration.rb template.
310
- def migration_template(relative_source, relative_destination, template_options = {})
311
- migration_directory relative_destination
312
- raise "Another migration is already named #{file_name}: #{existing_migrations(file_name).first}" if migration_exists?(file_name)
313
- template(relative_source, "#{relative_destination}/#{next_migration_string}_#{file_name}.rb", template_options)
314
- end
315
-
316
- private
317
- # Raise a usage error with an informative WordNet suggestion.
318
- # Thanks to Florian Gross (flgr).
319
- def raise_class_collision(class_name)
320
- message = <<end_message
321
- The name '#{class_name}' is reserved by Ruby on Rails.
322
- Please choose an alternative and run this generator again.
323
- end_message
324
- if suggest = find_synonyms(class_name)
325
- message << "\n Suggestions: \n\n"
326
- message << suggest.join("\n")
327
- end
328
- raise UsageError, message
329
- end
330
-
331
- SYNONYM_LOOKUP_URI = "http://wordnet.princeton.edu/cgi-bin/webwn2.0?stage=2&word=%s&posnumber=1&searchtypenumber=2&senses=&showglosses=1"
332
-
333
- # Look up synonyms on WordNet. Thanks to Florian Gross (flgr).
334
- def find_synonyms(word)
335
- require 'open-uri'
336
- require 'timeout'
337
- timeout(5) do
338
- open(SYNONYM_LOOKUP_URI % word) do |stream|
339
- data = stream.read.gsub("&nbsp;", " ").gsub("<BR>", "")
340
- data.scan(/^Sense \d+\n.+?\n\n/m)
341
- end
342
- end
343
- rescue Exception
344
- return nil
345
- end
346
- end
347
-
348
-
349
- # Undo the actions performed by a generator. Rewind the action
350
- # manifest and attempt to completely erase the results of each action.
351
- class Destroy < RewindBase
352
- # Remove a file if it exists and is a file.
353
- def file(relative_source, relative_destination, file_options = {})
354
- destination = destination_path(relative_destination)
355
- if File.exists?(destination)
356
- logger.rm relative_destination
357
- unless options[:pretend]
358
- if options[:svn]
359
- # If the file has been marked to be added
360
- # but has not yet been checked in, revert and delete
361
- if options[:svn][relative_destination]
362
- system("svn revert #{destination}")
363
- FileUtils.rm(destination)
364
- else
365
- # If the directory is not in the status list, it
366
- # has no modifications so we can simply remove it
367
- system("svn rm #{destination}")
368
- end
369
- else
370
- FileUtils.rm(destination)
371
- end
372
- end
373
- else
374
- logger.missing relative_destination
375
- return
376
- end
377
- end
378
-
379
- # Templates are deleted just like files and the actions take the
380
- # same parameters, so simply alias the file method.
381
- alias_method :template, :file
382
-
383
- # Remove each directory in the given path from right to left.
384
- # Remove each subdirectory if it exists and is a directory.
385
- def directory(relative_path)
386
- parts = relative_path.split('/')
387
- until parts.empty?
388
- partial = File.join(parts)
389
- path = destination_path(partial)
390
- if File.exists?(path)
391
- if Dir[File.join(path, '*')].empty?
392
- logger.rmdir partial
393
- unless options[:pretend]
394
- if options[:svn]
395
- # If the directory has been marked to be added
396
- # but has not yet been checked in, revert and delete
397
- if options[:svn][relative_path]
398
- system("svn revert #{path}")
399
- FileUtils.rmdir(path)
400
- else
401
- # If the directory is not in the status list, it
402
- # has no modifications so we can simply remove it
403
- system("svn rm #{path}")
404
- end
405
- else
406
- FileUtils.rmdir(path)
407
- end
408
- end
409
- else
410
- logger.notempty partial
411
- end
412
- else
413
- logger.missing partial
414
- end
415
- parts.pop
416
- end
417
- end
418
-
419
- def complex_template(*args)
420
- # nothing should be done here
421
- end
422
-
423
- # When deleting a migration, it knows to delete every file named "[0-9]*_#{file_name}".
424
- def migration_template(relative_source, relative_destination, template_options = {})
425
- migration_directory relative_destination
426
- raise "There is no migration named #{file_name}" unless migration_exists?(file_name)
427
- existing_migrations(file_name).each do |file_path|
428
- file(relative_source, file_path, template_options)
429
- end
430
- end
431
- end
432
-
433
-
434
- # List a generator's action manifest.
435
- class List < Base
436
- def dependency(generator_name, args, options = {})
437
- logger.dependency "#{generator_name}(#{args.join(', ')}, #{options.inspect})"
438
- end
439
-
440
- def class_collisions(*class_names)
441
- logger.class_collisions class_names.join(', ')
442
- end
443
-
444
- def file(relative_source, relative_destination, options = {})
445
- logger.file relative_destination
446
- end
447
-
448
- def template(relative_source, relative_destination, options = {})
449
- logger.template relative_destination
450
- end
451
-
452
- def complex_template(relative_source, relative_destination, options = {})
453
- logger.template "#{options[:insert]} inside #{relative_destination}"
454
- end
455
-
456
- def directory(relative_path)
457
- logger.directory "#{destination_path(relative_path)}/"
458
- end
459
-
460
- def readme(*args)
461
- logger.readme args.join(', ')
462
- end
463
-
464
- def migration_template(relative_source, relative_destination, options = {})
465
- migration_directory relative_destination
466
- logger.migration_template file_name
467
- end
468
- end
469
-
470
- # Update generator's action manifest.
471
- class Update < Create
472
- def file(relative_source, relative_destination, options = {})
473
- # logger.file relative_destination
474
- end
475
-
476
- def template(relative_source, relative_destination, options = {})
477
- # logger.template relative_destination
478
- end
479
-
480
- def complex_template(relative_source, relative_destination, template_options = {})
481
-
482
- begin
483
- dest_file = destination_path(relative_destination)
484
- source_to_update = File.readlines(dest_file).join
485
- rescue Errno::ENOENT
486
- logger.missing relative_destination
487
- return
488
- end
489
-
490
- logger.refreshing "#{template_options[:insert].gsub(/\.rhtml/,'')} inside #{relative_destination}"
491
-
492
- begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id]))
493
- end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id]))
494
-
495
- # Refreshing inner part of the template with freshly rendered part.
496
- rendered_part = render_template_part(template_options)
497
- source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part)
498
-
499
- File.open(dest_file, 'w') { |file| file.write(source_to_update) }
500
- end
501
-
502
- def directory(relative_path)
503
- # logger.directory "#{destination_path(relative_path)}/"
504
- end
505
- end
506
-
507
- end
508
- end
509
- end
@@ -1,16 +0,0 @@
1
- Description:
2
- The 'rails' command creates a new Rails application with a default
3
- directory structure and configuration at the path you specify.
4
-
5
- Example:
6
- rails ~/Code/Ruby/weblog
7
-
8
- This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
9
- See the README in the newly created application to get going.
10
-
11
- WARNING:
12
- Only specify --without-gems if you did not use gems to install Rails.
13
- Your application will expect to find activerecord, actionpack, and
14
- actionmailer directories in the vendor directory. A popular way to track
15
- the bleeding edge of Rails development is to checkout from source control
16
- directly to the vendor directory. See http://dev.rubyonrails.com
@@ -1,140 +0,0 @@
1
- require 'rbconfig'
2
-
3
- class AppGenerator < Rails::Generator::Base
4
- DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
5
- Config::CONFIG['ruby_install_name'])
6
-
7
- default_options :gem => true, :shebang => DEFAULT_SHEBANG
8
- mandatory_options :source => "#{File.dirname(__FILE__)}/../../../../.."
9
-
10
- def initialize(runtime_args, runtime_options = {})
11
- super
12
- usage if args.empty?
13
- @destination_root = args.shift
14
- @socket = MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) }
15
- @socket = '/path/to/your/mysql.sock' if @socket.blank?
16
- end
17
-
18
- def manifest
19
- script_options = { :chmod => 0755 }
20
- dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }
21
-
22
- record do |m|
23
- # Root directory and all subdirectories.
24
- m.directory ''
25
- BASEDIRS.each { |path| m.directory path }
26
-
27
- # Root
28
- m.file "fresh_rakefile", "Rakefile"
29
- m.file "README", "README"
30
-
31
- # Application
32
- m.template "helpers/application.rb", "app/controllers/application.rb"
33
- m.template "helpers/application_helper.rb", "app/helpers/application_helper.rb"
34
- m.template "helpers/test_helper.rb", "test/test_helper.rb"
35
-
36
- # database.yml and .htaccess
37
- m.template "configs/database.yml", "config/database.yml", :assigns => {
38
- :app_name => File.basename(File.expand_path(@destination_root)),
39
- :socket => @socket
40
- }
41
- m.template "configs/routes.rb", "config/routes.rb"
42
- m.template "configs/apache.conf", "public/.htaccess"
43
-
44
- # Environments
45
- m.file "environments/boot.rb", "config/boot.rb"
46
- m.file "environments/environment.rb", "config/environment.rb"
47
- m.file "environments/production.rb", "config/environments/production.rb"
48
- m.file "environments/development.rb", "config/environments/development.rb"
49
- m.file "environments/test.rb", "config/environments/test.rb"
50
-
51
- # Scripts
52
- %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin ).each do |file|
53
- m.file "bin/#{file}", "script/#{file}", script_options
54
- end
55
-
56
- # Dispatches
57
- m.file "dispatches/dispatch.rb", "public/dispatch.rb", dispatcher_options
58
- m.file "dispatches/dispatch.rb", "public/dispatch.cgi", dispatcher_options
59
- m.file "dispatches/dispatch.fcgi", "public/dispatch.fcgi", dispatcher_options
60
-
61
- # HTML files
62
- %w(404 500 index).each do |file|
63
- m.template "html/#{file}.html", "public/#{file}.html"
64
- end
65
-
66
- m.template "html/favicon.ico", "public/favicon.ico"
67
- m.template "html/robots.txt", "public/robots.txt"
68
- m.file "html/images/rails.png", "public/images/rails.png"
69
-
70
- # Javascripts
71
- m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
72
- m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
73
- m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
74
- m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
75
-
76
- # Docs
77
- m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
78
-
79
- # Logs
80
- %w(server production development test).each { |file|
81
- m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
82
- }
83
- end
84
- end
85
-
86
- protected
87
- def banner
88
- "Usage: #{$0} /path/to/your/app [options]"
89
- end
90
-
91
- def add_options!(opt)
92
- opt.separator ''
93
- opt.separator 'Options:'
94
- opt.on("--ruby [#{DEFAULT_SHEBANG}]",
95
- "Path to the Ruby binary of your choice.") { |options[:shebang]| }
96
- opt.on("--without-gems",
97
- "Don't use the Rails gems for your app.",
98
- "WARNING: see note below.") { |options[:gem]| }
99
- end
100
-
101
-
102
- # Installation skeleton. Intermediate directories are automatically
103
- # created so don't sweat their absence here.
104
- BASEDIRS = %w(
105
- app/controllers
106
- app/helpers
107
- app/models
108
- app/views/layouts
109
- config/environments
110
- components
111
- db
112
- doc
113
- lib
114
- lib/tasks
115
- log
116
- public/images
117
- public/javascripts
118
- public/stylesheets
119
- script/performance
120
- script/process
121
- test/fixtures
122
- test/functional
123
- test/mocks/development
124
- test/mocks/test
125
- test/unit
126
- vendor
127
- vendor/plugins
128
- )
129
-
130
- MYSQL_SOCKET_LOCATIONS = [
131
- "/tmp/mysql.sock", # default
132
- "/var/run/mysqld/mysqld.sock", # debian/gentoo
133
- "/var/tmp/mysql.sock", # freebsd
134
- "/var/lib/mysql/mysql.sock", # fedora
135
- "/opt/local/lib/mysql/mysql.sock", # fedora
136
- "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
137
- "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
138
- "/opt/local/var/run/mysql5/mysqld.sock" # mac + darwinports + mysql5
139
- ]
140
- end
@@ -1,30 +0,0 @@
1
- Description:
2
- The controller generator creates stubs for a new controller and its views.
3
-
4
- The generator takes a controller name and a list of views as arguments.
5
- The controller name may be given in CamelCase or under_score and should
6
- not be suffixed with 'Controller'. To create a controller within a
7
- module, specify the controller name as 'module/controller'.
8
-
9
- The generator creates a controller class in app/controllers with view
10
- templates in app/views/controller_name, a helper class in app/helpers,
11
- and a functional test suite in test/functional.
12
-
13
- Example:
14
- ./script/generate controller CreditCard open debit credit close
15
-
16
- Credit card controller with URLs like /credit_card/debit.
17
- Controller: app/controllers/credit_card_controller.rb
18
- Views: app/views/credit_card/debit.rhtml [...]
19
- Helper: app/helpers/credit_card_helper.rb
20
- Test: test/functional/credit_card_controller_test.rb
21
-
22
- Modules Example:
23
- ./script/generate controller 'admin/credit_card' suspend late_fee
24
-
25
- Credit card admin controller with URLs /admin/credit_card/suspend.
26
- Controller: app/controllers/admin/credit_card_controller.rb
27
- Views: app/views/admin/credit_card/debit.rhtml [...]
28
- Helper: app/helpers/admin/credit_card_helper.rb
29
- Test: test/functional/admin/credit_card_controller_test.rb
30
-