railties 3.0.20 → 3.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +36 -49
- data/README.rdoc +2 -1
- data/guides/assets/stylesheets/fixes.css +16 -0
- data/guides/rails_guides.rb +2 -2
- data/guides/rails_guides/generator.rb +8 -3
- data/guides/rails_guides/textile_extensions.rb +4 -2
- data/guides/source/2_2_release_notes.textile +3 -3
- data/guides/source/2_3_release_notes.textile +2 -2
- data/guides/source/3_0_release_notes.textile +14 -14
- data/guides/source/action_controller_overview.textile +54 -79
- data/guides/source/action_mailer_basics.textile +39 -9
- data/guides/source/action_view_overview.textile +257 -211
- data/guides/source/active_record_basics.textile +1 -1
- data/guides/source/active_record_querying.textile +217 -27
- data/guides/source/active_record_validations_callbacks.textile +94 -25
- data/guides/source/active_support_core_extensions.textile +109 -77
- data/guides/source/ajax_on_rails.textile +15 -150
- data/guides/source/api_documentation_guidelines.textile +12 -12
- data/guides/source/association_basics.textile +74 -60
- data/guides/source/caching_with_rails.textile +59 -60
- data/guides/source/command_line.textile +46 -47
- data/guides/source/configuring.textile +55 -37
- data/guides/source/contribute.textile +7 -7
- data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
- data/guides/source/credits.html.erb +3 -3
- data/guides/source/debugging_rails_applications.textile +59 -46
- data/guides/source/form_helpers.textile +76 -31
- data/guides/source/generators.textile +39 -40
- data/guides/source/getting_started.textile +73 -94
- data/guides/source/i18n.textile +64 -58
- data/guides/source/index.html.erb +3 -3
- data/guides/source/initialization.textile +634 -3284
- data/guides/source/layout.html.erb +6 -7
- data/guides/source/layouts_and_rendering.textile +59 -60
- data/guides/source/migrations.textile +63 -59
- data/guides/source/nested_model_forms.textile +2 -2
- data/guides/source/performance_testing.textile +16 -16
- data/guides/source/plugins.textile +236 -1280
- data/guides/source/rails_application_templates.textile +37 -29
- data/guides/source/rails_on_rack.textile +4 -9
- data/guides/source/routing.textile +96 -75
- data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
- data/guides/source/security.textile +57 -30
- data/guides/source/testing.textile +26 -24
- data/guides/w3c_validator.rb +2 -2
- data/lib/rails.rb +1 -7
- data/lib/rails/application.rb +46 -76
- data/lib/rails/application/bootstrap.rb +6 -11
- data/lib/rails/application/configuration.rb +43 -40
- data/lib/rails/application/finisher.rb +16 -4
- data/lib/rails/application/railties.rb +6 -24
- data/lib/rails/application/routes_reloader.rb +45 -0
- data/lib/rails/backtrace_cleaner.rb +1 -1
- data/lib/rails/cli.rb +7 -5
- data/lib/rails/commands.rb +27 -2
- data/lib/rails/commands/application.rb +14 -1
- data/lib/rails/commands/benchmarker.rb +3 -1
- data/lib/rails/commands/dbconsole.rb +2 -2
- data/lib/rails/commands/destroy.rb +3 -1
- data/lib/rails/commands/generate.rb +3 -1
- data/lib/rails/commands/plugin.rb +2 -7
- data/lib/rails/commands/plugin_new.rb +10 -0
- data/lib/rails/commands/profiler.rb +3 -1
- data/lib/rails/commands/server.rb +4 -0
- data/lib/rails/configuration.rb +8 -81
- data/lib/rails/console/app.rb +2 -2
- data/lib/rails/engine.rb +460 -78
- data/lib/rails/engine/configuration.rb +46 -49
- data/lib/rails/engine/railties.rb +33 -0
- data/lib/rails/generators.rb +11 -5
- data/lib/rails/generators/actions.rb +2 -27
- data/lib/rails/generators/app_base.rb +216 -0
- data/lib/rails/generators/base.rb +3 -2
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +2 -1
- data/lib/rails/generators/migration.rb +6 -2
- data/lib/rails/generators/named_base.rb +79 -3
- data/lib/rails/generators/rails/app/app_generator.rb +44 -209
- data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
- data/lib/rails/generators/rails/app/templates/README +2 -2
- data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
- data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
- data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
- data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/rails/generators/rails/assets/USAGE +20 -0
- data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
- data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
- data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
- data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
- data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
- data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
- data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
- data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_case.rb +2 -20
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
- data/lib/rails/info.rb +0 -1
- data/lib/rails/paths.rb +119 -65
- data/lib/rails/plugin.rb +18 -19
- data/lib/rails/rack/log_tailer.rb +1 -1
- data/lib/rails/railtie.rb +50 -47
- data/lib/rails/railtie/configurable.rb +20 -10
- data/lib/rails/railtie/configuration.rb +20 -19
- data/lib/rails/source_annotation_extractor.rb +5 -5
- data/lib/rails/tasks.rb +1 -0
- data/lib/rails/tasks/assets.rake +10 -0
- data/lib/rails/tasks/documentation.rake +2 -8
- data/lib/rails/tasks/engine.rake +69 -0
- data/lib/rails/tasks/framework.rake +4 -21
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/routes.rake +2 -1
- data/lib/rails/test_help.rb +17 -1
- data/lib/rails/test_unit/railtie.rb +1 -1
- data/lib/rails/test_unit/testing.rake +8 -3
- data/lib/rails/version.rb +3 -3
- metadata +128 -100
- checksums.yaml +0 -7
- data/lib/rails/application/configurable.rb +0 -19
- data/lib/rails/console/sandbox.rb +0 -6
- data/lib/rails/deprecation.rb +0 -41
- data/lib/rails/engine/configurable.rb +0 -25
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
- data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
- data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
- data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
- data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
- data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
- data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
- data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
- data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
- data/lib/rails/info_routes.rb +0 -3
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new asset placeholders. Pass the asset name, either CamelCased
|
3
|
+
or under_scored.
|
4
|
+
|
5
|
+
To create assets within a folder, specify the assets name as a
|
6
|
+
path like 'parent/name'.
|
7
|
+
|
8
|
+
This generates a JavaScript stub in app/assets/javascripts and a stylesheet
|
9
|
+
stub in app/assets/stylesheets.
|
10
|
+
|
11
|
+
If CoffeeScript is available, JavaScripts will be generated with the .coffee extension.
|
12
|
+
If Sass 3 is available, stylesheets will be generated with the .scss extension.
|
13
|
+
|
14
|
+
Example:
|
15
|
+
`rails generate assets posts`
|
16
|
+
|
17
|
+
Posts assets.
|
18
|
+
Javascript: app/assets/javascripts/posts.js
|
19
|
+
Stylesheet: app/assets/stylesheets/posts.css
|
20
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
class AssetsGenerator < NamedBase
|
4
|
+
class_option :javascripts, :type => :boolean, :desc => "Generate javascripts"
|
5
|
+
class_option :stylesheets, :type => :boolean, :desc => "Generate stylesheets"
|
6
|
+
|
7
|
+
class_option :javascript_engine, :desc => "Engine for javascripts"
|
8
|
+
class_option :stylesheet_engine, :desc => "Engine for stylesheets"
|
9
|
+
|
10
|
+
def create_javascript_files
|
11
|
+
return unless options.javascripts?
|
12
|
+
copy_file "javascript.#{javascript_extension}",
|
13
|
+
File.join('app/assets/javascripts', class_path, "#{asset_name}.#{javascript_extension}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_stylesheet_files
|
17
|
+
return unless options.stylesheets?
|
18
|
+
copy_file "stylesheet.#{stylesheet_extension}",
|
19
|
+
File.join('app/assets/stylesheets', class_path, "#{asset_name}.#{stylesheet_extension}")
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def asset_name
|
25
|
+
file_name
|
26
|
+
end
|
27
|
+
|
28
|
+
def javascript_extension
|
29
|
+
options.javascript_engine.present? ?
|
30
|
+
"js.#{options.javascript_engine}" : "js"
|
31
|
+
end
|
32
|
+
|
33
|
+
def stylesheet_extension
|
34
|
+
options.stylesheet_engine.present? ?
|
35
|
+
"css.#{options.stylesheet_engine}" : "css"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -14,9 +14,9 @@ module Rails
|
|
14
14
|
|
15
15
|
def generator_dir
|
16
16
|
if options[:namespace]
|
17
|
-
File.join("lib", "generators", file_name)
|
17
|
+
File.join("lib", "generators", regular_class_path, file_name)
|
18
18
|
else
|
19
|
-
File.join("lib", "generators")
|
19
|
+
File.join("lib", "generators", regular_class_path)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
File without changes
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require 'rails/generators/rails/generator/generator_generator'
|
2
3
|
|
3
4
|
module Rails
|
@@ -5,6 +6,12 @@ module Rails
|
|
5
6
|
class PluginGenerator < NamedBase
|
6
7
|
class_option :tasks, :desc => "When supplied creates tasks base files."
|
7
8
|
|
9
|
+
def show_deprecation
|
10
|
+
return unless behavior == :invoke
|
11
|
+
message = "Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure."
|
12
|
+
ActiveSupport::Deprecation.warn message
|
13
|
+
end
|
14
|
+
|
8
15
|
check_class_collision
|
9
16
|
|
10
17
|
def create_root_files
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
2
|
require 'rake/testtask'
|
3
|
-
require '
|
3
|
+
require 'rake/rdoctask'
|
4
4
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
6
|
task :default => :test
|
@@ -14,10 +14,10 @@ Rake::TestTask.new(:test) do |t|
|
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Generate documentation for the <%= file_name %> plugin.'
|
17
|
-
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
18
|
rdoc.rdoc_dir = 'rdoc'
|
19
19
|
rdoc.title = '<%= class_name %>'
|
20
20
|
rdoc.options << '--line-numbers' << '--inline-source'
|
21
21
|
rdoc.rdoc_files.include('README')
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
-
end
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
The 'rails plugin new' command creates a skeleton for developing any
|
3
|
+
kind of Rails extension with ability to run tests using dummy Rails
|
4
|
+
application.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
rails plugin new ~/Code/Ruby/blog
|
8
|
+
|
9
|
+
This generates a skeletal Rails plugin in ~/Code/Ruby/blog.
|
10
|
+
See the README in the newly created plugin to get going.
|
@@ -0,0 +1,303 @@
|
|
1
|
+
require 'active_support/core_ext/hash/slice'
|
2
|
+
require "rails/generators/rails/app/app_generator"
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
class PluginBuilder
|
7
|
+
def rakefile
|
8
|
+
template "Rakefile"
|
9
|
+
end
|
10
|
+
|
11
|
+
def app
|
12
|
+
if mountable?
|
13
|
+
directory "app"
|
14
|
+
template "#{app_templates_dir}/app/views/layouts/application.html.erb.tt",
|
15
|
+
"app/views/layouts/#{name}/application.html.erb"
|
16
|
+
empty_directory_with_gitkeep "app/assets/images"
|
17
|
+
elsif full?
|
18
|
+
empty_directory_with_gitkeep "app/models"
|
19
|
+
empty_directory_with_gitkeep "app/controllers"
|
20
|
+
empty_directory_with_gitkeep "app/views"
|
21
|
+
empty_directory_with_gitkeep "app/helpers"
|
22
|
+
empty_directory_with_gitkeep "app/assets/images"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def readme
|
27
|
+
template "README.rdoc"
|
28
|
+
end
|
29
|
+
|
30
|
+
def gemfile
|
31
|
+
template "Gemfile"
|
32
|
+
end
|
33
|
+
|
34
|
+
def license
|
35
|
+
template "MIT-LICENSE"
|
36
|
+
end
|
37
|
+
|
38
|
+
def gemspec
|
39
|
+
template "%name%.gemspec"
|
40
|
+
end
|
41
|
+
|
42
|
+
def gitignore
|
43
|
+
copy_file "gitignore", ".gitignore"
|
44
|
+
end
|
45
|
+
|
46
|
+
def lib
|
47
|
+
template "lib/%name%.rb"
|
48
|
+
template "lib/tasks/%name%_tasks.rake"
|
49
|
+
if full?
|
50
|
+
template "lib/%name%/engine.rb"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def config
|
55
|
+
template "config/routes.rb" if full?
|
56
|
+
end
|
57
|
+
|
58
|
+
def test
|
59
|
+
template "test/test_helper.rb"
|
60
|
+
template "test/%name%_test.rb"
|
61
|
+
append_file "Rakefile", <<-EOF
|
62
|
+
#{rakefile_test_tasks}
|
63
|
+
|
64
|
+
task :default => :test
|
65
|
+
EOF
|
66
|
+
if full?
|
67
|
+
template "test/integration/navigation_test.rb"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
PASSTHROUGH_OPTIONS = [
|
72
|
+
:skip_active_record, :skip_javascript, :database, :javascript, :quiet, :pretend, :force, :skip
|
73
|
+
]
|
74
|
+
|
75
|
+
def generate_test_dummy(force = false)
|
76
|
+
opts = (options || {}).slice(*PASSTHROUGH_OPTIONS)
|
77
|
+
opts[:force] = force
|
78
|
+
|
79
|
+
invoke Rails::Generators::AppGenerator,
|
80
|
+
[ File.expand_path(dummy_path, destination_root) ], opts
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_dummy_config
|
84
|
+
template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
|
85
|
+
template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
|
86
|
+
if mountable?
|
87
|
+
template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_dummy_clean
|
92
|
+
inside dummy_path do
|
93
|
+
remove_file ".gitignore"
|
94
|
+
remove_file "db/seeds.rb"
|
95
|
+
remove_file "doc"
|
96
|
+
remove_file "Gemfile"
|
97
|
+
remove_file "lib/tasks"
|
98
|
+
remove_file "app/assets/images/rails.png"
|
99
|
+
remove_file "public/index.html"
|
100
|
+
remove_file "public/robots.txt"
|
101
|
+
remove_file "README"
|
102
|
+
remove_file "test"
|
103
|
+
remove_file "vendor"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def stylesheets
|
108
|
+
if mountable?
|
109
|
+
copy_file "#{app_templates_dir}/app/assets/stylesheets/application.css",
|
110
|
+
"app/assets/stylesheets/application.css"
|
111
|
+
elsif full?
|
112
|
+
empty_directory_with_gitkeep "app/assets/stylesheets"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def javascripts
|
117
|
+
return if options.skip_javascript?
|
118
|
+
|
119
|
+
if mountable?
|
120
|
+
copy_file "#{app_templates_dir}/app/assets/javascripts/application.js.tt",
|
121
|
+
"app/assets/javascripts/application.js"
|
122
|
+
elsif full?
|
123
|
+
empty_directory_with_gitkeep "app/assets/javascripts"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def script(force = false)
|
128
|
+
directory "script", :force => force do |content|
|
129
|
+
"#{shebang}\n" + content
|
130
|
+
end
|
131
|
+
chmod "script", 0755, :verbose => false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
module Generators
|
136
|
+
class PluginNewGenerator < AppBase
|
137
|
+
add_shared_options_for "plugin"
|
138
|
+
|
139
|
+
alias_method :plugin_path, :app_path
|
140
|
+
|
141
|
+
class_option :dummy_path, :type => :string, :default => "test/dummy",
|
142
|
+
:desc => "Create dummy application at given path"
|
143
|
+
|
144
|
+
class_option :full, :type => :boolean, :default => false,
|
145
|
+
:desc => "Generate rails engine with integration tests"
|
146
|
+
|
147
|
+
class_option :mountable, :type => :boolean, :default => false,
|
148
|
+
:desc => "Generate mountable isolated application"
|
149
|
+
|
150
|
+
class_option :skip_gemspec, :type => :boolean, :default => false,
|
151
|
+
:desc => "Skip gemspec file"
|
152
|
+
|
153
|
+
def initialize(*args)
|
154
|
+
raise Error, "Options should be given after the plugin name. For details run: rails plugin --help" if args[0].blank?
|
155
|
+
|
156
|
+
@dummy_path = nil
|
157
|
+
super
|
158
|
+
end
|
159
|
+
|
160
|
+
public_task :create_root
|
161
|
+
|
162
|
+
def create_root_files
|
163
|
+
build(:readme)
|
164
|
+
build(:rakefile)
|
165
|
+
build(:gemspec) unless options[:skip_gemspec]
|
166
|
+
build(:license)
|
167
|
+
build(:gitignore) unless options[:skip_git]
|
168
|
+
build(:gemfile) unless options[:skip_gemfile]
|
169
|
+
end
|
170
|
+
|
171
|
+
def create_app_files
|
172
|
+
build(:app)
|
173
|
+
end
|
174
|
+
|
175
|
+
def create_config_files
|
176
|
+
build(:config)
|
177
|
+
end
|
178
|
+
|
179
|
+
def create_lib_files
|
180
|
+
build(:lib)
|
181
|
+
end
|
182
|
+
|
183
|
+
def create_public_stylesheets_files
|
184
|
+
build(:stylesheets)
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_javascript_files
|
188
|
+
build(:javascripts)
|
189
|
+
end
|
190
|
+
|
191
|
+
def create_images_directory
|
192
|
+
build(:images)
|
193
|
+
end
|
194
|
+
|
195
|
+
def create_script_files
|
196
|
+
build(:script)
|
197
|
+
end
|
198
|
+
|
199
|
+
def create_test_files
|
200
|
+
build(:test) unless options[:skip_test_unit]
|
201
|
+
end
|
202
|
+
|
203
|
+
def create_test_dummy_files
|
204
|
+
return if options[:skip_test_unit]
|
205
|
+
create_dummy_app
|
206
|
+
end
|
207
|
+
|
208
|
+
def finish_template
|
209
|
+
build(:leftovers)
|
210
|
+
end
|
211
|
+
|
212
|
+
public_task :apply_rails_template, :bundle_if_dev_or_edge
|
213
|
+
|
214
|
+
protected
|
215
|
+
|
216
|
+
def app_templates_dir
|
217
|
+
"../../app/templates"
|
218
|
+
end
|
219
|
+
|
220
|
+
def create_dummy_app(path = nil)
|
221
|
+
dummy_path(path) if path
|
222
|
+
|
223
|
+
say_status :vendor_app, dummy_path
|
224
|
+
mute do
|
225
|
+
build(:generate_test_dummy)
|
226
|
+
store_application_definition!
|
227
|
+
build(:test_dummy_config)
|
228
|
+
build(:test_dummy_clean)
|
229
|
+
# ensure that script/rails has proper dummy_path
|
230
|
+
build(:script, true)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def full?
|
235
|
+
options[:full] || options[:mountable]
|
236
|
+
end
|
237
|
+
|
238
|
+
def mountable?
|
239
|
+
options[:mountable]
|
240
|
+
end
|
241
|
+
|
242
|
+
def self.banner
|
243
|
+
"rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
|
244
|
+
end
|
245
|
+
|
246
|
+
def name
|
247
|
+
@name ||= File.basename(destination_root)
|
248
|
+
end
|
249
|
+
|
250
|
+
def camelized
|
251
|
+
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
|
252
|
+
end
|
253
|
+
|
254
|
+
def valid_const?
|
255
|
+
if camelized =~ /^\d/
|
256
|
+
raise Error, "Invalid plugin name #{name}. Please give a name which does not start with numbers."
|
257
|
+
elsif RESERVED_NAMES.include?(name)
|
258
|
+
raise Error, "Invalid plugin name #{name}. Please give a name which does not match one of the reserved rails words."
|
259
|
+
elsif Object.const_defined?(camelized)
|
260
|
+
raise Error, "Invalid plugin name #{name}, constant #{camelized} is already in use. Please choose another application name."
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def application_definition
|
265
|
+
@application_definition ||= begin
|
266
|
+
|
267
|
+
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
|
268
|
+
unless options[:pretend] || !File.exists?(dummy_application_path)
|
269
|
+
contents = File.read(dummy_application_path)
|
270
|
+
contents[(contents.index("module Dummy"))..-1]
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
alias :store_application_definition! :application_definition
|
275
|
+
|
276
|
+
def get_builder_class
|
277
|
+
defined?(::PluginBuilder) ? ::PluginBuilder : Rails::PluginBuilder
|
278
|
+
end
|
279
|
+
|
280
|
+
def rakefile_test_tasks
|
281
|
+
<<-RUBY
|
282
|
+
require 'rake/testtask'
|
283
|
+
|
284
|
+
Rake::TestTask.new(:test) do |t|
|
285
|
+
t.libs << 'lib'
|
286
|
+
t.libs << 'test'
|
287
|
+
t.pattern = 'test/**/*_test.rb'
|
288
|
+
t.verbose = false
|
289
|
+
end
|
290
|
+
RUBY
|
291
|
+
end
|
292
|
+
|
293
|
+
def dummy_path(path = nil)
|
294
|
+
@dummy_path = path if path
|
295
|
+
@dummy_path || options[:dummy_path]
|
296
|
+
end
|
297
|
+
|
298
|
+
def mute(&block)
|
299
|
+
shell.mute(&block)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|