railties 4.2.11.3 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +262 -206
- data/MIT-LICENSE +20 -0
- data/README.rdoc +1 -1
- data/{bin → exe}/rails +0 -0
- data/lib/rails.rb +19 -1
- data/lib/rails/all.rb +10 -9
- data/lib/rails/api/task.rb +7 -14
- data/lib/rails/{app_rails_loader.rb → app_loader.rb} +4 -3
- data/lib/rails/application.rb +31 -41
- data/lib/rails/application/bootstrap.rb +1 -14
- data/lib/rails/application/configuration.rb +94 -95
- data/lib/rails/application/default_middleware_stack.rb +30 -16
- data/lib/rails/application/finisher.rb +11 -2
- data/lib/rails/application/routes_reloader.rb +1 -3
- data/lib/rails/application_controller.rb +1 -1
- data/lib/rails/cli.rb +2 -2
- data/lib/rails/code_statistics.rb +6 -8
- data/lib/rails/code_statistics_calculator.rb +8 -1
- data/lib/rails/command.rb +70 -0
- data/lib/rails/commands.rb +5 -3
- data/lib/rails/commands/commands_tasks.rb +25 -14
- data/lib/rails/commands/console.rb +7 -52
- data/lib/rails/commands/console_helper.rb +34 -0
- data/lib/rails/commands/dbconsole.rb +59 -78
- data/lib/rails/commands/dev_cache.rb +21 -0
- data/lib/rails/commands/plugin.rb +1 -1
- data/lib/rails/commands/rake_proxy.rb +34 -0
- data/lib/rails/commands/runner.rb +0 -1
- data/lib/rails/commands/server.rb +29 -36
- data/lib/rails/commands/test.rb +9 -0
- data/lib/rails/configuration.rb +21 -5
- data/lib/rails/console/app.rb +5 -0
- data/lib/rails/console/helpers.rb +1 -1
- data/lib/rails/engine.rb +68 -58
- data/lib/rails/engine/commands.rb +4 -2
- data/lib/rails/engine/configuration.rb +4 -10
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +30 -7
- data/lib/rails/generators/.named_base.rb.swp +0 -0
- data/lib/rails/generators/actions.rb +19 -5
- data/lib/rails/generators/app_base.rb +65 -45
- data/lib/rails/generators/base.rb +6 -6
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +5 -8
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +9 -7
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +2 -2
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +5 -1
- data/lib/rails/generators/migration.rb +7 -7
- data/lib/rails/generators/named_base.rb +21 -5
- data/lib/rails/generators/rails/app/USAGE +0 -1
- data/lib/rails/generators/rails/app/app_generator.rb +75 -11
- data/lib/rails/generators/rails/app/templates/Gemfile +17 -13
- data/lib/rails/generators/rails/app/templates/{README.rdoc → README.md} +1 -5
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +7 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +11 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +3 -3
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +5 -0
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +20 -17
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
- data/lib/rails/generators/{erb/mailer/templates/layout.text.erb → rails/app/templates/app/views/layouts/mailer.text.erb.tt} +0 -0
- data/lib/rails/generators/rails/app/templates/bin/setup +17 -12
- data/lib/rails/generators/rails/app/templates/bin/update +28 -0
- data/lib/rails/generators/rails/app/templates/config.ru.tt +11 -0
- data/lib/rails/generators/rails/app/templates/config/application.rb +9 -14
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +20 -3
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +18 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +7 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +6 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/request_forgery_protection.rb +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +9 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb +3 -53
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/gitignore +7 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +6 -4
- data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
- data/lib/rails/generators/rails/model/USAGE +6 -1
- data/lib/rails/generators/rails/model/model_generator.rb +1 -1
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +88 -35
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +6 -9
- data/lib/rails/generators/rails/plugin/templates/Gemfile +3 -7
- data/lib/rails/generators/rails/plugin/templates/README.md +3 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/plugin/templates/app/models/application_record.rb.tt +6 -0
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/test.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore +2 -3
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +5 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/{%name%_tasks.rake → %namespaced_name%_tasks.rake} +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb +3 -3
- data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +11 -0
- data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
- data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
- data/lib/rails/generators/rails/plugin/templates/rails/routes.rb +1 -2
- data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +3 -3
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +4 -2
- data/lib/rails/generators/rails/resource/resource_generator.rb +0 -1
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -1
- data/lib/rails/generators/rails/scaffold/USAGE +1 -1
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +35 -7
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +4 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_unit/controller/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +3 -5
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +8 -3
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb +4 -4
- data/lib/rails/generators/test_unit/model/model_generator.rb +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -0
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
- data/lib/rails/generators/test_unit/scaffold/templates/.api_functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/.functional_test.rb.swp +0 -0
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +44 -0
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +14 -14
- data/lib/rails/generators/testing/assertions.rb +0 -2
- data/lib/rails/generators/testing/behaviour.rb +4 -17
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +23 -2
- data/lib/rails/mailers_controller.rb +2 -2
- data/lib/rails/paths.rb +14 -6
- data/lib/rails/rack.rb +1 -3
- data/lib/rails/rack/debugger.rb +2 -23
- data/lib/rails/rack/logger.rb +4 -0
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/source_annotation_extractor.rb +1 -1
- data/lib/rails/tasks.rb +4 -1
- data/lib/rails/tasks/engine.rake +1 -1
- data/lib/rails/tasks/framework.rake +18 -16
- data/lib/rails/tasks/initializers.rake +6 -0
- data/lib/rails/tasks/restart.rake +5 -0
- data/lib/rails/tasks/statistics.rake +5 -6
- data/lib/rails/tasks/tmp.rake +4 -12
- data/lib/rails/templates/rails/mailers/email.html.erb +17 -3
- data/lib/rails/templates/rails/welcome/index.html.erb +10 -3
- data/lib/rails/test_help.rb +7 -8
- data/lib/rails/test_unit/minitest_plugin.rb +91 -0
- data/lib/rails/test_unit/reporter.rb +74 -0
- data/lib/rails/test_unit/test_requirer.rb +28 -0
- data/lib/rails/test_unit/testing.rake +18 -39
- metadata +80 -33
- data/lib/rails/deprecation.rb +0 -19
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb +0 -5
- data/lib/rails/generators/rails/app/templates/config.ru +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/lib/rails/generators/rails/plugin/templates/README.rdoc +0 -3
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -5
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
- data/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +0 -6
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +0 -7
- data/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +0 -3
- data/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +0 -7
- data/lib/rails/rack/log_tailer.rb +0 -38
- data/lib/rails/tasks/documentation.rake +0 -70
- data/lib/rails/test_unit/sub_test_task.rb +0 -126
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'open-uri'
|
2
2
|
|
3
3
|
module Rails
|
4
4
|
module Generators
|
@@ -63,12 +63,26 @@ module Rails
|
|
63
63
|
|
64
64
|
# Add the given source to +Gemfile+
|
65
65
|
#
|
66
|
+
# If block is given, gem entries in block are wrapped into the source group.
|
67
|
+
#
|
66
68
|
# add_source "http://gems.github.com/"
|
67
|
-
|
69
|
+
#
|
70
|
+
# add_source "http://gems.github.com/" do
|
71
|
+
# gem "rspec-rails"
|
72
|
+
# end
|
73
|
+
def add_source(source, options={}, &block)
|
68
74
|
log :source, source
|
69
75
|
|
70
76
|
in_root do
|
71
|
-
|
77
|
+
if block
|
78
|
+
append_file "Gemfile", "source #{quote(source)} do", force: true
|
79
|
+
@in_group = true
|
80
|
+
instance_eval(&block)
|
81
|
+
@in_group = false
|
82
|
+
append_file "Gemfile", "\nend\n", force: true
|
83
|
+
else
|
84
|
+
prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false
|
85
|
+
end
|
72
86
|
end
|
73
87
|
end
|
74
88
|
|
@@ -188,7 +202,7 @@ module Rails
|
|
188
202
|
# generate(:authenticated, "user session")
|
189
203
|
def generate(what, *args)
|
190
204
|
log :generate, what
|
191
|
-
argument = args.flat_map
|
205
|
+
argument = args.flat_map(&:to_s).join(" ")
|
192
206
|
|
193
207
|
in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) }
|
194
208
|
end
|
@@ -221,7 +235,7 @@ module Rails
|
|
221
235
|
sentinel = /\.routes\.draw do\s*\n/m
|
222
236
|
|
223
237
|
in_root do
|
224
|
-
inject_into_file 'config/routes.rb', " #{routing_code}\n", { after: sentinel, verbose: false, force:
|
238
|
+
inject_into_file 'config/routes.rb', " #{routing_code}\n", { after: sentinel, verbose: false, force: false }
|
225
239
|
end
|
226
240
|
end
|
227
241
|
|
@@ -26,6 +26,12 @@ module Rails
|
|
26
26
|
class_option :template, type: :string, aliases: '-m',
|
27
27
|
desc: "Path to some #{name} template (can be a filesystem path or URL)"
|
28
28
|
|
29
|
+
class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
|
30
|
+
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
31
|
+
|
32
|
+
class_option :javascript, type: :string, aliases: '-j', default: 'jquery',
|
33
|
+
desc: 'Preconfigure for selected JavaScript library'
|
34
|
+
|
29
35
|
class_option :skip_gemfile, type: :boolean, default: false,
|
30
36
|
desc: "Don't create a Gemfile"
|
31
37
|
|
@@ -38,37 +44,38 @@ module Rails
|
|
38
44
|
class_option :skip_keeps, type: :boolean, default: false,
|
39
45
|
desc: 'Skip source control .keep files'
|
40
46
|
|
47
|
+
class_option :skip_action_mailer, type: :boolean, aliases: "-M",
|
48
|
+
default: false,
|
49
|
+
desc: "Skip Action Mailer files"
|
50
|
+
|
41
51
|
class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
|
42
52
|
desc: 'Skip Active Record files'
|
43
53
|
|
54
|
+
class_option :skip_action_cable, type: :boolean, aliases: '-C', default: false,
|
55
|
+
desc: 'Skip Action Cable files'
|
56
|
+
|
44
57
|
class_option :skip_sprockets, type: :boolean, aliases: '-S', default: false,
|
45
58
|
desc: 'Skip Sprockets files'
|
46
59
|
|
47
60
|
class_option :skip_spring, type: :boolean, default: false,
|
48
61
|
desc: "Don't install Spring application preloader"
|
49
62
|
|
50
|
-
class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
|
51
|
-
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
52
|
-
|
53
|
-
class_option :javascript, type: :string, aliases: '-j', default: 'jquery',
|
54
|
-
desc: 'Preconfigure for selected JavaScript library'
|
55
|
-
|
56
63
|
class_option :skip_javascript, type: :boolean, aliases: '-J', default: false,
|
57
64
|
desc: 'Skip JavaScript files'
|
58
65
|
|
66
|
+
class_option :skip_turbolinks, type: :boolean, default: false,
|
67
|
+
desc: 'Skip turbolinks gem'
|
68
|
+
|
69
|
+
class_option :skip_test, type: :boolean, aliases: '-T', default: false,
|
70
|
+
desc: 'Skip test files'
|
71
|
+
|
59
72
|
class_option :dev, type: :boolean, default: false,
|
60
73
|
desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
|
61
74
|
|
62
75
|
class_option :edge, type: :boolean, default: false,
|
63
76
|
desc: "Setup the #{name} with Gemfile pointing to Rails repository"
|
64
77
|
|
65
|
-
class_option :
|
66
|
-
desc: 'Skip turbolinks gem'
|
67
|
-
|
68
|
-
class_option :skip_test_unit, type: :boolean, aliases: '-T', default: false,
|
69
|
-
desc: 'Skip Test::Unit files'
|
70
|
-
|
71
|
-
class_option :rc, type: :string, default: nil,
|
78
|
+
class_option :rc, type: :string, default: false,
|
72
79
|
desc: "Path to file containing extra configuration options for rails command"
|
73
80
|
|
74
81
|
class_option :no_rc, type: :boolean, default: false,
|
@@ -109,9 +116,7 @@ module Rails
|
|
109
116
|
assets_gemfile_entry,
|
110
117
|
javascript_gemfile_entry,
|
111
118
|
jbuilder_gemfile_entry,
|
112
|
-
sdoc_gemfile_entry,
|
113
119
|
psych_gemfile_entry,
|
114
|
-
mime_type_gemfile_entry,
|
115
120
|
@extra_entries].flatten.find_all(&@gem_filter)
|
116
121
|
end
|
117
122
|
|
@@ -124,7 +129,7 @@ module Rails
|
|
124
129
|
def builder
|
125
130
|
@builder ||= begin
|
126
131
|
builder_class = get_builder_class
|
127
|
-
builder_class.
|
132
|
+
builder_class.include(ActionMethods)
|
128
133
|
builder_class.new(self)
|
129
134
|
end
|
130
135
|
end
|
@@ -166,13 +171,17 @@ module Rails
|
|
166
171
|
end
|
167
172
|
|
168
173
|
def include_all_railties?
|
169
|
-
|
174
|
+
options.values_at(:skip_active_record, :skip_action_mailer, :skip_test, :skip_sprockets, :skip_action_cable).none?
|
170
175
|
end
|
171
176
|
|
172
177
|
def comment_if(value)
|
173
178
|
options[value] ? '# ' : ''
|
174
179
|
end
|
175
180
|
|
181
|
+
def keeps?
|
182
|
+
!options[:skip_keeps]
|
183
|
+
end
|
184
|
+
|
176
185
|
def sqlite3?
|
177
186
|
!options[:skip_active_record] && options[:database] == 'sqlite3'
|
178
187
|
end
|
@@ -210,24 +219,44 @@ module Rails
|
|
210
219
|
end
|
211
220
|
|
212
221
|
def rails_gemfile_entry
|
222
|
+
dev_edge_common = [
|
223
|
+
]
|
213
224
|
if options.dev?
|
214
|
-
[
|
225
|
+
[
|
226
|
+
GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH)
|
227
|
+
] + dev_edge_common
|
215
228
|
elsif options.edge?
|
216
|
-
[
|
229
|
+
[
|
230
|
+
GemfileEntry.github('rails', 'rails/rails')
|
231
|
+
] + dev_edge_common
|
217
232
|
else
|
218
233
|
[GemfileEntry.version('rails',
|
219
|
-
|
234
|
+
rails_version_specifier,
|
220
235
|
"Bundle edge Rails instead: gem 'rails', github: 'rails/rails'")]
|
221
236
|
end
|
222
237
|
end
|
223
238
|
|
239
|
+
def rails_version_specifier(gem_version = Rails.gem_version)
|
240
|
+
if gem_version.prerelease?
|
241
|
+
next_series = gem_version
|
242
|
+
next_series = next_series.bump while next_series.segments.size > 2
|
243
|
+
|
244
|
+
[">= #{gem_version}", "< #{next_series}"]
|
245
|
+
elsif gem_version.segments.size == 3
|
246
|
+
"~> #{gem_version}"
|
247
|
+
else
|
248
|
+
patch = gem_version.segments[0, 3].join(".")
|
249
|
+
["~> #{patch}", ">= #{gem_version}"]
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
224
253
|
def gem_for_database
|
225
254
|
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
|
226
255
|
case options[:database]
|
227
256
|
when "oracle" then ["ruby-oci8", nil]
|
228
|
-
when "postgresql" then ["pg", ["~> 0.
|
257
|
+
when "postgresql" then ["pg", ["~> 0.18"]]
|
229
258
|
when "frontbase" then ["ruby-frontbase", nil]
|
230
|
-
when "mysql" then ["mysql2", [">= 0.3.
|
259
|
+
when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
|
231
260
|
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
|
232
261
|
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
|
233
262
|
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
|
@@ -252,8 +281,6 @@ module Rails
|
|
252
281
|
return [] if options[:skip_sprockets]
|
253
282
|
|
254
283
|
gems = []
|
255
|
-
gems << GemfileEntry.version('sass-rails', '~> 5.0',
|
256
|
-
'Use SCSS for stylesheets')
|
257
284
|
|
258
285
|
gems << GemfileEntry.version('uglifier',
|
259
286
|
'>= 1.3.0',
|
@@ -264,17 +291,16 @@ module Rails
|
|
264
291
|
|
265
292
|
def jbuilder_gemfile_entry
|
266
293
|
comment = 'Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder'
|
267
|
-
GemfileEntry.
|
268
|
-
end
|
269
|
-
|
270
|
-
def sdoc_gemfile_entry
|
271
|
-
comment = 'bundle exec rake doc:rails generates the API under doc/api.'
|
272
|
-
GemfileEntry.new('sdoc', '~> 0.4.0', comment, group: :doc)
|
294
|
+
GemfileEntry.new 'jbuilder', '~> 2.0', comment, {}, options[:api]
|
273
295
|
end
|
274
296
|
|
275
297
|
def coffee_gemfile_entry
|
276
298
|
comment = 'Use CoffeeScript for .coffee assets and views'
|
277
|
-
|
299
|
+
if options.dev? || options.edge?
|
300
|
+
GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, comment
|
301
|
+
else
|
302
|
+
GemfileEntry.version 'coffee-rails', '~> 4.1.0', comment
|
303
|
+
end
|
278
304
|
end
|
279
305
|
|
280
306
|
def javascript_gemfile_entry
|
@@ -311,12 +337,6 @@ module Rails
|
|
311
337
|
GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
|
312
338
|
end
|
313
339
|
|
314
|
-
def mime_type_gemfile_entry
|
315
|
-
return [] unless RUBY_VERSION < '2'
|
316
|
-
|
317
|
-
GemfileEntry.new('mime-types', '< 3', nil, require: false)
|
318
|
-
end
|
319
|
-
|
320
340
|
def bundle_command(command)
|
321
341
|
say_status :run, "bundle #{command}"
|
322
342
|
|
@@ -325,10 +345,6 @@ module Rails
|
|
325
345
|
# its own vendored Thor, which could be a different version. Running both
|
326
346
|
# things in the same process is a recipe for a night with paracetamol.
|
327
347
|
#
|
328
|
-
# We use backticks and #print here instead of vanilla #system because it
|
329
|
-
# is easier to silence stdout in the existing test suite this way. The
|
330
|
-
# end-user gets the bundler commands called anyway, so no big deal.
|
331
|
-
#
|
332
348
|
# We unset temporary bundler variables to load proper bundler and Gemfile.
|
333
349
|
#
|
334
350
|
# Thanks to James Tucker for the Gem tricks involved in this call.
|
@@ -336,8 +352,12 @@ module Rails
|
|
336
352
|
|
337
353
|
require 'bundler'
|
338
354
|
Bundler.with_clean_env do
|
339
|
-
|
340
|
-
|
355
|
+
full_command = %Q["#{Gem.ruby}" "#{_bundle_command}" #{command}]
|
356
|
+
if options[:quiet]
|
357
|
+
system(full_command, out: File::NULL)
|
358
|
+
else
|
359
|
+
system(full_command)
|
360
|
+
end
|
341
361
|
end
|
342
362
|
end
|
343
363
|
|
@@ -346,7 +366,7 @@ module Rails
|
|
346
366
|
end
|
347
367
|
|
348
368
|
def spring_install?
|
349
|
-
!options[:skip_spring] && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")
|
369
|
+
!options[:skip_spring] && !options.dev? && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")
|
350
370
|
end
|
351
371
|
|
352
372
|
def run_bundle
|
@@ -365,7 +385,7 @@ module Rails
|
|
365
385
|
end
|
366
386
|
|
367
387
|
def keep_file(destination)
|
368
|
-
create_file("#{destination}/.keep")
|
388
|
+
create_file("#{destination}/.keep") if keeps?
|
369
389
|
end
|
370
390
|
end
|
371
391
|
end
|
@@ -103,12 +103,12 @@ module Rails
|
|
103
103
|
# hook_for :test_framework, as: :controller
|
104
104
|
# end
|
105
105
|
#
|
106
|
-
# And now it will
|
106
|
+
# And now it will look up at:
|
107
107
|
#
|
108
108
|
# "test_unit:controller", "test_unit"
|
109
109
|
#
|
110
|
-
# Similarly, if you want it to also
|
111
|
-
# need to provide the :in value:
|
110
|
+
# Similarly, if you want it to also look up in the rails namespace, you
|
111
|
+
# just need to provide the :in value:
|
112
112
|
#
|
113
113
|
# class AwesomeGenerator < Rails::Generators::Base
|
114
114
|
# hook_for :test_framework, in: :rails, as: :controller
|
@@ -273,7 +273,7 @@ module Rails
|
|
273
273
|
|
274
274
|
# Use Rails default banner.
|
275
275
|
def self.banner
|
276
|
-
"rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map
|
276
|
+
"rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, ' ')
|
277
277
|
end
|
278
278
|
|
279
279
|
# Sets the base_name taking into account the current class namespace.
|
@@ -302,13 +302,13 @@ module Rails
|
|
302
302
|
default_for_option(Rails::Generators.options, name, options, options[:default])
|
303
303
|
end
|
304
304
|
|
305
|
-
#
|
305
|
+
# Returns default aliases for the option name given doing a lookup in
|
306
306
|
# Rails::Generators.aliases.
|
307
307
|
def self.default_aliases_for_option(name, options)
|
308
308
|
default_for_option(Rails::Generators.aliases, name, options, options[:aliases])
|
309
309
|
end
|
310
310
|
|
311
|
-
#
|
311
|
+
# Returns default for the option name given doing a lookup in config.
|
312
312
|
def self.default_for_option(config, name, options, default)
|
313
313
|
if generator_name and c = config[generator_name.to_sym] and c.key?(name)
|
314
314
|
c[name]
|
@@ -6,16 +6,9 @@ module Erb # :nodoc:
|
|
6
6
|
argument :actions, type: :array, default: [], banner: "method method"
|
7
7
|
|
8
8
|
def copy_view_files
|
9
|
-
view_base_path = File.join("app/views", class_path, file_name)
|
9
|
+
view_base_path = File.join("app/views", class_path, file_name + '_mailer')
|
10
10
|
empty_directory view_base_path
|
11
11
|
|
12
|
-
if self.behavior == :invoke
|
13
|
-
formats.each do |format|
|
14
|
-
layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format))
|
15
|
-
template filename_with_extensions(:layout, format), layout_path
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
12
|
actions.each do |action|
|
20
13
|
@action = action
|
21
14
|
|
@@ -31,6 +24,10 @@ module Erb # :nodoc:
|
|
31
24
|
def formats
|
32
25
|
[:text, :html]
|
33
26
|
end
|
27
|
+
|
28
|
+
def file_name
|
29
|
+
@_file_name ||= super.gsub(/\_mailer/i, '')
|
30
|
+
end
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<%%= form_for(
|
2
|
-
<%% if
|
1
|
+
<%%= form_for(<%= singular_table_name %>) do |f| %>
|
2
|
+
<%% if <%= singular_table_name %>.errors.any? %>
|
3
3
|
<div id="error_explanation">
|
4
|
-
<h2><%%= pluralize(
|
4
|
+
<h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
5
|
|
6
6
|
<ul>
|
7
|
-
<%%
|
7
|
+
<%% <%= singular_table_name %>.errors.full_messages.each do |message| %>
|
8
8
|
<li><%%= message %></li>
|
9
9
|
<%% end %>
|
10
10
|
</ul>
|
@@ -14,17 +14,19 @@
|
|
14
14
|
<% attributes.each do |attribute| -%>
|
15
15
|
<div class="field">
|
16
16
|
<% if attribute.password_digest? -%>
|
17
|
-
<%%= f.label :password
|
17
|
+
<%%= f.label :password %>
|
18
18
|
<%%= f.password_field :password %>
|
19
19
|
</div>
|
20
|
+
|
20
21
|
<div class="field">
|
21
|
-
<%%= f.label :password_confirmation
|
22
|
+
<%%= f.label :password_confirmation %>
|
22
23
|
<%%= f.password_field :password_confirmation %>
|
23
24
|
<% else -%>
|
24
|
-
<%%= f.label :<%= attribute.column_name %>
|
25
|
+
<%%= f.label :<%= attribute.column_name %> %>
|
25
26
|
<%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %>
|
26
27
|
<% end -%>
|
27
28
|
</div>
|
29
|
+
|
28
30
|
<% end -%>
|
29
31
|
<div class="actions">
|
30
32
|
<%%= f.submit %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h1>Editing <%= singular_table_name.titleize %></h1>
|
2
2
|
|
3
|
-
<%%= render 'form' %>
|
3
|
+
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>
|
4
4
|
|
5
5
|
<%%= link_to 'Show', @<%= singular_table_name %> %> |
|
6
6
|
<%%= link_to 'Back', <%= index_helper %>_path %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<p id="notice"><%%= notice %></p>
|
2
2
|
|
3
|
-
<h1
|
3
|
+
<h1><%= plural_table_name.titleize %></h1>
|
4
4
|
|
5
5
|
<table>
|
6
6
|
<thead>
|
@@ -28,4 +28,4 @@
|
|
28
28
|
|
29
29
|
<br>
|
30
30
|
|
31
|
-
<%%= link_to 'New <%=
|
31
|
+
<%%= link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_table_name %>_path %>
|
@@ -3,29 +3,29 @@ require 'rails/generators/actions/create_migration'
|
|
3
3
|
|
4
4
|
module Rails
|
5
5
|
module Generators
|
6
|
-
# Holds common methods for migrations. It assumes that migrations
|
7
|
-
# [0-9]*_name format and can be used by
|
6
|
+
# Holds common methods for migrations. It assumes that migrations have the
|
7
|
+
# [0-9]*_name format and can be used by other frameworks (like Sequel)
|
8
8
|
# just by implementing the next migration version method.
|
9
9
|
module Migration
|
10
10
|
extend ActiveSupport::Concern
|
11
11
|
attr_reader :migration_number, :migration_file_name, :migration_class_name
|
12
12
|
|
13
|
-
module ClassMethods
|
14
|
-
def migration_lookup_at(dirname)
|
13
|
+
module ClassMethods #:nodoc:
|
14
|
+
def migration_lookup_at(dirname)
|
15
15
|
Dir.glob("#{dirname}/[0-9]*_*.rb")
|
16
16
|
end
|
17
17
|
|
18
|
-
def migration_exists?(dirname, file_name)
|
18
|
+
def migration_exists?(dirname, file_name)
|
19
19
|
migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
|
20
20
|
end
|
21
21
|
|
22
|
-
def current_migration_number(dirname)
|
22
|
+
def current_migration_number(dirname)
|
23
23
|
migration_lookup_at(dirname).collect do |file|
|
24
24
|
File.basename(file).split("_").first.to_i
|
25
25
|
end.max.to_i
|
26
26
|
end
|
27
27
|
|
28
|
-
def next_migration_number(dirname)
|
28
|
+
def next_migration_number(dirname)
|
29
29
|
raise NotImplementedError
|
30
30
|
end
|
31
31
|
end
|