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
@@ -4,41 +4,65 @@ module Rails
|
|
4
4
|
class Engine
|
5
5
|
class Configuration < ::Rails::Railtie::Configuration
|
6
6
|
attr_reader :root
|
7
|
-
attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths
|
7
|
+
attr_writer :middleware, :eager_load_paths, :autoload_once_paths, :autoload_paths
|
8
|
+
attr_accessor :plugins
|
8
9
|
|
9
10
|
def initialize(root=nil)
|
10
11
|
super()
|
11
12
|
@root = root
|
13
|
+
@generators = app_generators.dup
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the middleware stack for the engine.
|
17
|
+
def middleware
|
18
|
+
@middleware ||= Rails::Configuration::MiddlewareStackProxy.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# Holds generators configuration:
|
22
|
+
#
|
23
|
+
# config.generators do |g|
|
24
|
+
# g.orm :datamapper, :migration => true
|
25
|
+
# g.template_engine :haml
|
26
|
+
# g.test_framework :rspec
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# If you want to disable color in console, do:
|
30
|
+
#
|
31
|
+
# config.generators.colorize_logging = false
|
32
|
+
#
|
33
|
+
def generators #:nodoc
|
34
|
+
@generators ||= Rails::Configuration::Generators.new
|
35
|
+
yield(@generators) if block_given?
|
36
|
+
@generators
|
12
37
|
end
|
13
38
|
|
14
39
|
def paths
|
15
40
|
@paths ||= begin
|
16
41
|
paths = Rails::Paths::Root.new(@root)
|
17
|
-
paths.
|
18
|
-
paths.
|
19
|
-
paths.
|
20
|
-
paths.
|
21
|
-
paths.
|
22
|
-
paths.
|
23
|
-
paths.
|
24
|
-
paths.
|
25
|
-
paths.
|
26
|
-
paths.
|
27
|
-
paths.
|
28
|
-
paths.
|
29
|
-
paths.
|
30
|
-
paths.
|
31
|
-
paths.
|
42
|
+
paths.add "app", :eager_load => true, :glob => "*"
|
43
|
+
paths.add "app/assets", :glob => "*"
|
44
|
+
paths.add "app/controllers", :eager_load => true
|
45
|
+
paths.add "app/helpers", :eager_load => true
|
46
|
+
paths.add "app/models", :eager_load => true
|
47
|
+
paths.add "app/mailers", :eager_load => true
|
48
|
+
paths.add "app/views"
|
49
|
+
paths.add "lib", :load_path => true
|
50
|
+
paths.add "lib/tasks", :glob => "**/*.rake"
|
51
|
+
paths.add "config"
|
52
|
+
paths.add "config/environments", :glob => "#{Rails.env}.rb"
|
53
|
+
paths.add "config/initializers", :glob => "**/*.rb"
|
54
|
+
paths.add "config/locales", :glob => "*.{rb,yml}"
|
55
|
+
paths.add "config/routes", :with => "config/routes.rb"
|
56
|
+
paths.add "db"
|
57
|
+
paths.add "db/migrate"
|
58
|
+
paths.add "db/seeds", :with => "db/seeds.rb"
|
59
|
+
paths.add "vendor", :load_path => true
|
60
|
+
paths.add "vendor/assets", :glob => "*"
|
61
|
+
paths.add "vendor/plugins"
|
32
62
|
paths
|
33
63
|
end
|
34
64
|
end
|
35
65
|
|
36
|
-
def generators #:nodoc:
|
37
|
-
ActiveSupport::Deprecation.warn "config.generators in Rails::Engine is deprecated. " <<
|
38
|
-
"Please use config.app_generators instead."
|
39
|
-
super
|
40
|
-
end
|
41
|
-
|
42
66
|
def root=(value)
|
43
67
|
@root = paths.path = Pathname.new(value).expand_path
|
44
68
|
end
|
@@ -54,33 +78,6 @@ module Rails
|
|
54
78
|
def autoload_paths
|
55
79
|
@autoload_paths ||= paths.autoload_paths
|
56
80
|
end
|
57
|
-
|
58
|
-
def load_paths
|
59
|
-
ActiveSupport::Deprecation.warn "config.load_paths is deprecated. Please use config.autoload_paths instead."
|
60
|
-
autoload_paths
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_paths=(paths)
|
64
|
-
ActiveSupport::Deprecation.warn "config.load_paths= is deprecated. Please use config.autoload_paths instead."
|
65
|
-
self.autoload_paths = paths
|
66
|
-
end
|
67
|
-
|
68
|
-
# Rails 3, by default, uses bundler, which shims the Kernel#gem method so that it should
|
69
|
-
# behave correctly for this deprecation.
|
70
|
-
def gem(name, options = {})
|
71
|
-
super name, options[:version] || ">= 0"
|
72
|
-
require options[:lib] || name
|
73
|
-
rescue Gem::LoadError
|
74
|
-
msg = "config.gem is deprecated, and you tried to activate the '#{name}' gem (#{options.inspect}) using it.\n"
|
75
|
-
|
76
|
-
if File.exist?("#{Rails.root}/Gemfile")
|
77
|
-
msg << "Please add '#{name}' to your Gemfile."
|
78
|
-
else
|
79
|
-
msg << "Please update your application to use bundler."
|
80
|
-
end
|
81
|
-
ActiveSupport::Deprecation.warn(msg, caller)
|
82
|
-
exit
|
83
|
-
end
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Rails
|
2
|
+
class Engine < Railtie
|
3
|
+
class Railties
|
4
|
+
# TODO Write tests for this behavior extracted from Application
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def all(&block)
|
10
|
+
@all ||= plugins
|
11
|
+
@all.each(&block) if block
|
12
|
+
@all
|
13
|
+
end
|
14
|
+
|
15
|
+
def plugins
|
16
|
+
@plugins ||= begin
|
17
|
+
plugin_names = (@config.plugins || [:all]).map { |p| p.to_sym }
|
18
|
+
Plugin.all(plugin_names, @config.paths["vendor/plugins"].existent)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.railties
|
23
|
+
@railties ||= ::Rails::Railtie.subclasses.map(&:instance)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.engines
|
27
|
+
@engines ||= ::Rails::Engine.subclasses.map(&:instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
delegate :railties, :engines, :to => "self.class"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/rails/generators.rb
CHANGED
@@ -24,9 +24,12 @@ module Rails
|
|
24
24
|
:rails => {
|
25
25
|
:actions => '-a',
|
26
26
|
:orm => '-o',
|
27
|
+
:javascripts => '-j',
|
28
|
+
:javascript_engine => '-je',
|
27
29
|
:resource_controller => '-c',
|
28
30
|
:scaffold_controller => '-c',
|
29
31
|
:stylesheets => '-y',
|
32
|
+
:stylesheet_engine => '-se',
|
30
33
|
:template_engine => '-e',
|
31
34
|
:test_framework => '-t'
|
32
35
|
},
|
@@ -43,14 +46,18 @@ module Rails
|
|
43
46
|
|
44
47
|
DEFAULT_OPTIONS = {
|
45
48
|
:rails => {
|
49
|
+
:assets => true,
|
46
50
|
:force_plural => false,
|
47
51
|
:helper => true,
|
48
|
-
:orm => nil,
|
49
52
|
:integration_tool => nil,
|
53
|
+
:javascripts => true,
|
54
|
+
:javascript_engine => nil,
|
55
|
+
:orm => nil,
|
50
56
|
:performance_tool => nil,
|
51
57
|
:resource_controller => :controller,
|
52
58
|
:scaffold_controller => :scaffold_controller,
|
53
59
|
:stylesheets => true,
|
60
|
+
:stylesheet_engine => nil,
|
54
61
|
:test_framework => nil,
|
55
62
|
:template_engine => :erb
|
56
63
|
},
|
@@ -140,10 +147,7 @@ module Rails
|
|
140
147
|
|
141
148
|
lookup(lookups)
|
142
149
|
|
143
|
-
namespaces = subclasses.
|
144
|
-
hash[klass.namespace] = klass
|
145
|
-
hash
|
146
|
-
end
|
150
|
+
namespaces = Hash[subclasses.map { |klass| [klass.namespace, klass] }]
|
147
151
|
|
148
152
|
lookups.each do |namespace|
|
149
153
|
klass = namespaces[namespace]
|
@@ -231,6 +235,7 @@ module Rails
|
|
231
235
|
rails = groups.delete("rails")
|
232
236
|
rails.map! { |n| n.sub(/^rails:/, '') }
|
233
237
|
rails.delete("app")
|
238
|
+
rails.delete("plugin_new")
|
234
239
|
print_list("rails", rails)
|
235
240
|
|
236
241
|
hidden_namespaces.each {|n| groups.delete(n.to_s) }
|
@@ -304,6 +309,7 @@ module Rails
|
|
304
309
|
$LOAD_PATH.each do |base|
|
305
310
|
Dir[File.join(base, "{rails/generators,generators}", "**", "*_generator.rb")].each do |path|
|
306
311
|
begin
|
312
|
+
path = path.sub("#{base}/", "")
|
307
313
|
require path
|
308
314
|
rescue Exception => e
|
309
315
|
# No problem
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'open-uri'
|
2
|
-
require 'active_support/deprecation'
|
3
2
|
require 'rbconfig'
|
4
3
|
|
5
4
|
module Rails
|
@@ -53,20 +52,6 @@ module Rails
|
|
53
52
|
options = args.extract_options!
|
54
53
|
name, version = args
|
55
54
|
|
56
|
-
# Deal with deprecated options
|
57
|
-
{ :env => :group, :only => :group,
|
58
|
-
:lib => :require, :require_as => :require }.each do |old, new|
|
59
|
-
next unless options[old]
|
60
|
-
options[new] = options.delete(old)
|
61
|
-
ActiveSupport::Deprecation.warn "#{old.inspect} option in gem is deprecated, use #{new.inspect} instead"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Deal with deprecated source
|
65
|
-
if source = options.delete(:source)
|
66
|
-
ActiveSupport::Deprecation.warn ":source option in gem is deprecated, use add_source method instead"
|
67
|
-
add_source(source)
|
68
|
-
end
|
69
|
-
|
70
55
|
# Set the message to be shown in logs. Uses the git repo if one is given,
|
71
56
|
# otherwise use name (version).
|
72
57
|
parts, message = [ name.inspect ], name
|
@@ -202,8 +187,8 @@ module Rails
|
|
202
187
|
# initializer("globals.rb") do
|
203
188
|
# data = ""
|
204
189
|
#
|
205
|
-
# ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do
|
206
|
-
# data << "#{const} = :entp"
|
190
|
+
# ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do |const|
|
191
|
+
# data << "#{const} = :entp\n"
|
207
192
|
# end
|
208
193
|
#
|
209
194
|
# data
|
@@ -257,16 +242,6 @@ module Rails
|
|
257
242
|
in_root { run("#{extify(:capify)} .", :verbose => false) }
|
258
243
|
end
|
259
244
|
|
260
|
-
# Add Rails to /vendor/rails
|
261
|
-
#
|
262
|
-
# ==== Example
|
263
|
-
#
|
264
|
-
# freeze!
|
265
|
-
#
|
266
|
-
def freeze!(args={})
|
267
|
-
ActiveSupport::Deprecation.warn "freeze! is deprecated since your rails app now comes bundled with Rails by default, please check your Gemfile"
|
268
|
-
end
|
269
|
-
|
270
245
|
# Make an entry in Rails routing file config/routes.rb
|
271
246
|
#
|
272
247
|
# === Example
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'active_support/secure_random'
|
3
|
+
require 'active_support/core_ext/string/strip'
|
4
|
+
require 'rails/version' unless defined?(Rails::VERSION)
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
module Rails
|
10
|
+
module Generators
|
11
|
+
class AppBase < Base
|
12
|
+
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
13
|
+
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql )
|
14
|
+
DATABASES.concat(JDBC_DATABASES)
|
15
|
+
|
16
|
+
attr_accessor :rails_template
|
17
|
+
add_shebang_option!
|
18
|
+
|
19
|
+
argument :app_path, :type => :string
|
20
|
+
|
21
|
+
def self.add_shared_options_for(name)
|
22
|
+
class_option :builder, :type => :string, :aliases => "-b",
|
23
|
+
:desc => "Path to a #{name} builder (can be a filesystem path or URL)"
|
24
|
+
|
25
|
+
class_option :template, :type => :string, :aliases => "-m",
|
26
|
+
:desc => "Path to an #{name} template (can be a filesystem path or URL)"
|
27
|
+
|
28
|
+
class_option :skip_gemfile, :type => :boolean, :default => false,
|
29
|
+
:desc => "Don't create a Gemfile"
|
30
|
+
|
31
|
+
class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
|
32
|
+
:desc => "Skip Git ignores and keeps"
|
33
|
+
|
34
|
+
class_option :skip_active_record, :type => :boolean, :aliases => "-O", :default => false,
|
35
|
+
:desc => "Skip Active Record files"
|
36
|
+
|
37
|
+
class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3",
|
38
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
39
|
+
|
40
|
+
class_option :javascript, :type => :string, :aliases => '-j', :default => 'jquery',
|
41
|
+
:desc => 'Preconfigure for selected JavaScript library'
|
42
|
+
|
43
|
+
class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false,
|
44
|
+
:desc => "Skip JavaScript files"
|
45
|
+
|
46
|
+
class_option :dev, :type => :boolean, :default => false,
|
47
|
+
:desc => "Setup the #{name} with Gemfile pointing to your Rails checkout"
|
48
|
+
|
49
|
+
class_option :edge, :type => :boolean, :default => false,
|
50
|
+
:desc => "Setup the #{name} with Gemfile pointing to Rails repository"
|
51
|
+
|
52
|
+
class_option :skip_test_unit, :type => :boolean, :aliases => "-T", :default => false,
|
53
|
+
:desc => "Skip Test::Unit files"
|
54
|
+
|
55
|
+
class_option :help, :type => :boolean, :aliases => "-h", :group => :rails,
|
56
|
+
:desc => "Show this help message and quit"
|
57
|
+
|
58
|
+
class_option :old_style_hash, :type => :boolean, :default => false,
|
59
|
+
:desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
|
60
|
+
end
|
61
|
+
|
62
|
+
def initialize(*args)
|
63
|
+
@original_wd = Dir.pwd
|
64
|
+
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
def builder
|
71
|
+
@builder ||= begin
|
72
|
+
if path = options[:builder]
|
73
|
+
if URI(path).is_a?(URI::HTTP)
|
74
|
+
contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read }
|
75
|
+
else
|
76
|
+
contents = open(File.expand_path(path, @original_wd)) {|io| io.read }
|
77
|
+
end
|
78
|
+
|
79
|
+
prok = eval("proc { #{contents} }", TOPLEVEL_BINDING, path, 1)
|
80
|
+
instance_eval(&prok)
|
81
|
+
end
|
82
|
+
|
83
|
+
builder_class = get_builder_class
|
84
|
+
builder_class.send(:include, ActionMethods)
|
85
|
+
builder_class.new(self)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def build(meth, *args)
|
90
|
+
builder.send(meth, *args) if builder.respond_to?(meth)
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_root
|
94
|
+
self.destination_root = File.expand_path(app_path, destination_root)
|
95
|
+
valid_const?
|
96
|
+
|
97
|
+
empty_directory '.'
|
98
|
+
set_default_accessors!
|
99
|
+
FileUtils.cd(destination_root) unless options[:pretend]
|
100
|
+
end
|
101
|
+
|
102
|
+
def apply_rails_template
|
103
|
+
apply rails_template if rails_template
|
104
|
+
rescue Thor::Error, LoadError, Errno::ENOENT => e
|
105
|
+
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_default_accessors!
|
109
|
+
self.rails_template = case options[:template]
|
110
|
+
when /^https?:\/\//
|
111
|
+
options[:template]
|
112
|
+
when String
|
113
|
+
File.expand_path(options[:template], Dir.pwd)
|
114
|
+
else
|
115
|
+
options[:template]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def database_gemfile_entry
|
120
|
+
entry = options[:skip_active_record] ? "" : "gem '#{gem_for_database}'"
|
121
|
+
if options[:database] == 'mysql'
|
122
|
+
if options.dev? || options.edge?
|
123
|
+
entry += ", :git => 'git://github.com/brianmario/mysql2.git'"
|
124
|
+
else
|
125
|
+
entry += "\n# gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
entry + "\n"
|
129
|
+
end
|
130
|
+
|
131
|
+
def rails_gemfile_entry
|
132
|
+
if options.dev?
|
133
|
+
<<-GEMFILE.strip_heredoc
|
134
|
+
gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}'
|
135
|
+
GEMFILE
|
136
|
+
elsif options.edge?
|
137
|
+
<<-GEMFILE.strip_heredoc
|
138
|
+
gem 'rails', :git => 'git://github.com/rails/rails.git'
|
139
|
+
GEMFILE
|
140
|
+
else
|
141
|
+
<<-GEMFILE.strip_heredoc
|
142
|
+
gem 'rails', '#{Rails::VERSION::STRING}'
|
143
|
+
|
144
|
+
# Bundle edge Rails instead:
|
145
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
146
|
+
GEMFILE
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def gem_for_database
|
151
|
+
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3 jdbcpostgresql )
|
152
|
+
case options[:database]
|
153
|
+
when "oracle" then "ruby-oci8"
|
154
|
+
when "postgresql" then "pg"
|
155
|
+
when "frontbase" then "ruby-frontbase"
|
156
|
+
when "mysql" then "mysql2"
|
157
|
+
when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
|
158
|
+
when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
|
159
|
+
when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
|
160
|
+
else options[:database]
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def gem_for_ruby_debugger
|
165
|
+
if RUBY_VERSION < "1.9.2"
|
166
|
+
"gem 'ruby-debug'"
|
167
|
+
else
|
168
|
+
"gem 'ruby-debug19', :require => 'ruby-debug'"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def gem_for_turn
|
173
|
+
unless RUBY_VERSION < "1.9.2"
|
174
|
+
<<-GEMFILE.strip_heredoc
|
175
|
+
group :test do
|
176
|
+
# Pretty printed test output
|
177
|
+
gem 'turn', :require => false
|
178
|
+
end
|
179
|
+
GEMFILE
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def gem_for_javascript
|
184
|
+
"gem '#{options[:javascript]}-rails'" unless options[:skip_javascript]
|
185
|
+
end
|
186
|
+
|
187
|
+
def bundle_if_dev_or_edge
|
188
|
+
bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
|
189
|
+
run "#{bundle_command} install" if dev_or_edge?
|
190
|
+
end
|
191
|
+
|
192
|
+
def dev_or_edge?
|
193
|
+
options.dev? || options.edge?
|
194
|
+
end
|
195
|
+
|
196
|
+
def empty_directory_with_gitkeep(destination, config = {})
|
197
|
+
empty_directory(destination, config)
|
198
|
+
git_keep(destination)
|
199
|
+
end
|
200
|
+
|
201
|
+
def git_keep(destination)
|
202
|
+
create_file("#{destination}/.gitkeep") unless options[:skip_git]
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns Ruby 1.9 style key-value pair if current code is running on
|
206
|
+
# Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise.
|
207
|
+
def key_value(key, value)
|
208
|
+
if options[:old_style_hash] || RUBY_VERSION < '1.9'
|
209
|
+
":#{key} => #{value}"
|
210
|
+
else
|
211
|
+
"#{key}: #{value}"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|