railties 4.1.0.beta2 → 4.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -4
- data/lib/rails/app_rails_loader.rb +1 -1
- data/lib/rails/application.rb +11 -9
- data/lib/rails/application/bootstrap.rb +5 -1
- data/lib/rails/application/configuration.rb +13 -5
- data/lib/rails/commands/dbconsole.rb +11 -5
- data/lib/rails/commands/runner.rb +14 -5
- data/lib/rails/engine.rb +0 -1
- data/lib/rails/generators/actions.rb +8 -8
- data/lib/rails/generators/actions/create_migration.rb +68 -0
- data/lib/rails/generators/app_base.rb +7 -67
- data/lib/rails/generators/base.rb +1 -1
- data/lib/rails/generators/erb.rb +5 -1
- data/lib/rails/generators/erb/controller/controller_generator.rb +4 -2
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +2 -2
- data/lib/rails/generators/erb/mailer/templates/view.html.erb +5 -0
- data/lib/rails/generators/erb/mailer/templates/view.text.erb +1 -1
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +4 -2
- data/lib/rails/generators/migration.rb +22 -16
- data/lib/rails/generators/rails/app/app_generator.rb +5 -7
- data/lib/rails/generators/rails/app/templates/Gemfile +2 -4
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +12 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +8 -3
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +16 -4
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +7 -2
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml +3 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +8 -0
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +7 -2
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +4 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +3 -0
- data/lib/rails/generators/rails/app/templates/config/secrets.yml +3 -1
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb +1 -3
- data/lib/rails/generators/rails/controller/controller_generator.rb +3 -3
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -4
- data/lib/rails/generators/rails/plugin/templates/Gemfile +2 -4
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +4 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +1 -1
- data/lib/rails/generators/resource_helpers.rb +1 -3
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb +2 -0
- data/lib/rails/paths.rb +1 -1
- data/lib/rails/railtie.rb +3 -3
- data/lib/rails/test_help.rb +3 -1
- data/lib/rails/test_unit/testing.rake +0 -1
- data/lib/rails/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce4536fa348e7d6d6750a17491f11d5c23a3bd6
|
4
|
+
data.tar.gz: 8c6d2d1f10c3e1778a864c263d97a28d7aa50840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b972003890b7eb3341beb81b9afbc2eba44cef4eb36364100dfe676e64c3a5ad94902e442959f4eccabd19b8d371a4e1a0e87eee63cc829d5191c854a9c184bd
|
7
|
+
data.tar.gz: c5cdda3a97d9aa9871503c3043b8f22dec1052c34dfd5e7624d9d24a6658b0601e6c846facb2151d0a899090b8b6f06024fca535152dd23cdd95dc15f3656390
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,64 @@
|
|
1
|
+
* Do not crash when `config/secrets.yml` is empty.
|
2
|
+
|
3
|
+
*Yves Senn*
|
4
|
+
|
5
|
+
* Set `dump_schema_after_migration` config values in production.
|
6
|
+
|
7
|
+
Set `config.active_record.dump_schema_after_migration` as false
|
8
|
+
in the generated `config/environments/production.rb` file.
|
9
|
+
|
10
|
+
*Emil Soman*
|
11
|
+
|
12
|
+
* Added Thor-action for creation of migrations.
|
13
|
+
|
14
|
+
Fixes #13588, #12674.
|
15
|
+
|
16
|
+
*Gert Goet*
|
17
|
+
|
18
|
+
* Ensure that `bin/rails` is a file before trying to execute it.
|
19
|
+
|
20
|
+
Fixes #13825.
|
21
|
+
|
22
|
+
*bronzle*
|
23
|
+
|
24
|
+
* Use single quotes in generated files.
|
25
|
+
|
26
|
+
*Cristian Mircea Messel*, *Chulki Lee*
|
27
|
+
|
28
|
+
* Only lookup `config.log_level` for stdlib `::Logger` instances.
|
29
|
+
Assign it as is for third party loggers like `Log4r::Logger`.
|
30
|
+
|
31
|
+
Fixes #13421.
|
32
|
+
|
33
|
+
*Yves Senn*
|
34
|
+
|
35
|
+
* The `Gemfile` of new applications depends on SDoc ~> 0.4.0.
|
36
|
+
|
37
|
+
*Xavier Noria*
|
38
|
+
|
39
|
+
* `test_help.rb` now automatically checks/maintains your test database
|
40
|
+
schema. (Use `config.active_record.maintain_test_schema = false` to
|
41
|
+
disable.)
|
42
|
+
|
43
|
+
*Jon Leighton*
|
44
|
+
|
45
|
+
* Configure `secrets.yml` and `database.yml` to read configuration
|
46
|
+
from the system environment by default for production.
|
47
|
+
|
48
|
+
*José Valim*
|
49
|
+
|
50
|
+
* `config.assets.raise_runtime_errors` is set to true by default
|
51
|
+
|
52
|
+
This option has been introduced in
|
53
|
+
[sprockets-rails#100][https://github.com/rails/sprockets-rails/pull/100]
|
54
|
+
and defaults to true in new applications in development.
|
55
|
+
|
56
|
+
*Richard Schneeman*
|
57
|
+
|
58
|
+
* Generates `html` and `text` templates for mailers by default.
|
59
|
+
|
60
|
+
*Kassio Borges*
|
61
|
+
|
1
62
|
* Move `secret_key_base` from `config/initializers/secret_token.rb`
|
2
63
|
to `config/secrets.yml`.
|
3
64
|
|
@@ -35,21 +96,21 @@
|
|
35
96
|
|
36
97
|
This verifier can be used to generate and verify signed messages in the application.
|
37
98
|
|
38
|
-
message = Rails.application.message_verifier(
|
39
|
-
Rails.application.message_verifier(
|
99
|
+
message = Rails.application.message_verifier(:sensitive_data).generate('my sensible data')
|
100
|
+
Rails.application.message_verifier(:sensitive_data).verify(message)
|
40
101
|
# => 'my sensible data'
|
41
102
|
|
42
103
|
It is recommended not to use the same verifier for different things, so you can get different
|
43
104
|
verifiers passing the name argument.
|
44
105
|
|
45
|
-
message = Rails.application.message_verifier(
|
106
|
+
message = Rails.application.message_verifier(:cookies).generate('my sensible cookie data')
|
46
107
|
|
47
108
|
See the `ActiveSupport::MessageVerifier` documentation for more information.
|
48
109
|
|
49
110
|
*Rafael Mendonça França*
|
50
111
|
|
51
112
|
* The [Spring application
|
52
|
-
preloader](https://github.com/
|
113
|
+
preloader](https://github.com/rails/spring) is now installed
|
53
114
|
by default for new applications. It uses the development group of
|
54
115
|
the Gemfile, so will not be installed in production.
|
55
116
|
|
data/lib/rails/application.rb
CHANGED
@@ -170,18 +170,18 @@ module Rails
|
|
170
170
|
#
|
171
171
|
# ==== Parameters
|
172
172
|
#
|
173
|
-
# * +
|
173
|
+
# * +verifier_name+ - the name of the message verifier.
|
174
174
|
#
|
175
175
|
# ==== Examples
|
176
176
|
#
|
177
|
-
# message = Rails.application.message_verifier('
|
178
|
-
# Rails.application.message_verifier('
|
177
|
+
# message = Rails.application.message_verifier('sensitive_data').generate('my sensible data')
|
178
|
+
# Rails.application.message_verifier('sensitive_data').verify(message)
|
179
179
|
# # => 'my sensible data'
|
180
180
|
#
|
181
181
|
# See the +ActiveSupport::MessageVerifier+ documentation for more information.
|
182
|
-
def message_verifier(
|
183
|
-
@message_verifiers[
|
184
|
-
secret = key_generator.generate_key(
|
182
|
+
def message_verifier(verifier_name)
|
183
|
+
@message_verifiers[verifier_name] ||= begin
|
184
|
+
secret = key_generator.generate_key(verifier_name.to_s)
|
185
185
|
ActiveSupport::MessageVerifier.new(secret)
|
186
186
|
end
|
187
187
|
end
|
@@ -205,7 +205,8 @@ module Rails
|
|
205
205
|
"action_dispatch.http_auth_salt" => config.action_dispatch.http_auth_salt,
|
206
206
|
"action_dispatch.signed_cookie_salt" => config.action_dispatch.signed_cookie_salt,
|
207
207
|
"action_dispatch.encrypted_cookie_salt" => config.action_dispatch.encrypted_cookie_salt,
|
208
|
-
"action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt
|
208
|
+
"action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt,
|
209
|
+
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer
|
209
210
|
})
|
210
211
|
end
|
211
212
|
end
|
@@ -307,7 +308,8 @@ module Rails
|
|
307
308
|
yaml = config.paths["config/secrets"].first
|
308
309
|
if File.exist?(yaml)
|
309
310
|
require "erb"
|
310
|
-
|
311
|
+
all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {}
|
312
|
+
env_secrets = all_secrets[Rails.env]
|
311
313
|
secrets.merge!(env_secrets.symbolize_keys) if env_secrets
|
312
314
|
end
|
313
315
|
|
@@ -414,7 +416,7 @@ module Rails
|
|
414
416
|
|
415
417
|
def validate_secret_key_config! #:nodoc:
|
416
418
|
if secrets.secret_key_base.blank? && config.secret_token.blank?
|
417
|
-
raise "
|
419
|
+
raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
|
418
420
|
end
|
419
421
|
end
|
420
422
|
end
|
@@ -53,7 +53,11 @@ INFO
|
|
53
53
|
logger
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
if ::Logger === Rails.logger
|
57
|
+
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
|
58
|
+
else
|
59
|
+
Rails.logger.level = config.log_level
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
# Initialize cache early in the stack so railties can make use of it.
|
@@ -88,21 +88,29 @@ module Rails
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
# Loads and returns the configuration of
|
91
|
+
# Loads and returns the entire raw configuration of database from
|
92
|
+
# values stored in `config/database.yml`.
|
92
93
|
def database_configuration
|
93
|
-
yaml = paths["config/database"].first
|
94
|
-
|
94
|
+
yaml = Pathname.new(paths["config/database"].first || "")
|
95
|
+
|
96
|
+
config = if yaml.exist?
|
95
97
|
require "erb"
|
96
|
-
YAML.load
|
98
|
+
YAML.load(ERB.new(yaml.read).result) || {}
|
97
99
|
elsif ENV['DATABASE_URL']
|
98
|
-
|
100
|
+
# Value from ENV['DATABASE_URL'] is set to default database connection
|
101
|
+
# by Active Record.
|
102
|
+
{}
|
99
103
|
else
|
100
104
|
raise "Could not load database configuration. No such file - #{yaml}"
|
101
105
|
end
|
106
|
+
|
107
|
+
config
|
102
108
|
rescue Psych::SyntaxError => e
|
103
109
|
raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
|
104
110
|
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
105
111
|
"Error: #{e.message}"
|
112
|
+
rescue => e
|
113
|
+
raise e, "Cannot load `Rails.application.database_configuration`:\n#{e.message}", e.backtrace
|
106
114
|
end
|
107
115
|
|
108
116
|
def log_level
|
@@ -81,11 +81,11 @@ module Rails
|
|
81
81
|
|
82
82
|
def config
|
83
83
|
@config ||= begin
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
if configurations[environment].blank?
|
85
|
+
raise ActiveRecord::AdapterNotSpecified, "'#{environment}' database is not configured. Available configuration: #{configurations.inspect}"
|
86
|
+
else
|
87
|
+
configurations[environment]
|
88
|
+
end
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -99,6 +99,12 @@ module Rails
|
|
99
99
|
|
100
100
|
protected
|
101
101
|
|
102
|
+
def configurations
|
103
|
+
require APP_PATH
|
104
|
+
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
|
105
|
+
ActiveRecord::Base.configurations
|
106
|
+
end
|
107
|
+
|
102
108
|
def parse_arguments(arguments)
|
103
109
|
options = {}
|
104
110
|
|
@@ -9,7 +9,7 @@ if ARGV.first.nil?
|
|
9
9
|
end
|
10
10
|
|
11
11
|
ARGV.clone.options do |opts|
|
12
|
-
opts.banner = "Usage: rails runner [options]
|
12
|
+
opts.banner = "Usage: rails runner [options] [<'Some.ruby(code)'> | <filename.rb>]"
|
13
13
|
|
14
14
|
opts.separator ""
|
15
15
|
|
@@ -22,14 +22,23 @@ ARGV.clone.options do |opts|
|
|
22
22
|
opts.on("-h", "--help",
|
23
23
|
"Show this help message.") { $stdout.puts opts; exit }
|
24
24
|
|
25
|
+
opts.separator ""
|
26
|
+
opts.separator "Examples: "
|
27
|
+
|
28
|
+
opts.separator " rails runner 'puts Rails.env'"
|
29
|
+
opts.separator " This runs the code `puts Rails.env` after loading the app"
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator " rails runner path/to/filename.rb"
|
32
|
+
opts.separator " This runs the Ruby file located at `path/to/filename.rb` after loading the app"
|
33
|
+
|
25
34
|
if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
|
26
35
|
opts.separator ""
|
27
36
|
opts.separator "You can also use runner as a shebang line for your executables:"
|
28
|
-
opts.separator "-------------------------------------------------------------"
|
29
|
-
opts.separator "#!/usr/bin/env #{File.expand_path($0)} runner"
|
37
|
+
opts.separator " -------------------------------------------------------------"
|
38
|
+
opts.separator " #!/usr/bin/env #{File.expand_path($0)} runner"
|
30
39
|
opts.separator ""
|
31
|
-
opts.separator "Product.all.each { |p| p.price *= 2 ; p.save! }"
|
32
|
-
opts.separator "-------------------------------------------------------------"
|
40
|
+
opts.separator " Product.all.each { |p| p.price *= 2 ; p.save! }"
|
41
|
+
opts.separator " -------------------------------------------------------------"
|
33
42
|
end
|
34
43
|
|
35
44
|
opts.order! { |o| code_or_file ||= o } rescue retry
|
data/lib/rails/engine.rb
CHANGED
@@ -9,7 +9,7 @@ module Rails
|
|
9
9
|
@in_group = nil
|
10
10
|
end
|
11
11
|
|
12
|
-
# Adds an entry into Gemfile for the supplied gem.
|
12
|
+
# Adds an entry into +Gemfile+ for the supplied gem.
|
13
13
|
#
|
14
14
|
# gem "rspec", group: :test
|
15
15
|
# gem "technoweenie-restful-authentication", lib: "restful-authentication", source: "http://gems.github.com/"
|
@@ -61,7 +61,7 @@ module Rails
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
# Add the given source to Gemfile
|
64
|
+
# Add the given source to +Gemfile+
|
65
65
|
#
|
66
66
|
# add_source "http://gems.github.com/"
|
67
67
|
def add_source(source, options={})
|
@@ -72,10 +72,10 @@ module Rails
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
# Adds a line inside the Application class for config/application.rb
|
75
|
+
# Adds a line inside the Application class for <tt>config/application.rb</tt>.
|
76
76
|
#
|
77
|
-
# If options
|
78
|
-
# file in config/environments
|
77
|
+
# If options <tt>:env</tt> is specified, the line is appended to the corresponding
|
78
|
+
# file in <tt>config/environments</tt>.
|
79
79
|
#
|
80
80
|
# environment do
|
81
81
|
# "config.autoload_paths += %W(#{config.root}/extras)"
|
@@ -116,7 +116,7 @@ module Rails
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
# Create a new file in the vendor
|
119
|
+
# Create a new file in the <tt>vendor/</tt> directory. Code can be specified
|
120
120
|
# in a block or a data string can be given.
|
121
121
|
#
|
122
122
|
# vendor("sekrit.rb") do
|
@@ -143,7 +143,7 @@ module Rails
|
|
143
143
|
create_file("lib/#{filename}", data, verbose: false, &block)
|
144
144
|
end
|
145
145
|
|
146
|
-
# Create a new Rakefile with the provided code (either in a block or a string).
|
146
|
+
# Create a new +Rakefile+ with the provided code (either in a block or a string).
|
147
147
|
#
|
148
148
|
# rakefile("bootstrap.rake") do
|
149
149
|
# project = ask("What is the UNIX name of your project?")
|
@@ -213,7 +213,7 @@ module Rails
|
|
213
213
|
in_root { run("#{extify(:capify)} .", verbose: false) }
|
214
214
|
end
|
215
215
|
|
216
|
-
# Make an entry in Rails routing file config/routes.rb
|
216
|
+
# Make an entry in Rails routing file <tt>config/routes.rb</tt>
|
217
217
|
#
|
218
218
|
# route "root 'welcome#index'"
|
219
219
|
def route(routing_code)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'thor/actions/create_file'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generators
|
5
|
+
module Actions
|
6
|
+
class CreateMigration < Thor::Actions::CreateFile
|
7
|
+
|
8
|
+
def migration_dir
|
9
|
+
File.dirname(@destination)
|
10
|
+
end
|
11
|
+
|
12
|
+
def migration_file_name
|
13
|
+
@base.migration_file_name
|
14
|
+
end
|
15
|
+
|
16
|
+
def identical?
|
17
|
+
exists? && File.binread(existing_migration) == render
|
18
|
+
end
|
19
|
+
|
20
|
+
def revoke!
|
21
|
+
say_destination = exists? ? relative_existing_migration : relative_destination
|
22
|
+
say_status :remove, :red, say_destination
|
23
|
+
return unless exists?
|
24
|
+
::FileUtils.rm_rf(existing_migration) unless pretend?
|
25
|
+
existing_migration
|
26
|
+
end
|
27
|
+
|
28
|
+
def relative_existing_migration
|
29
|
+
base.relative_to_original_destination_root(existing_migration)
|
30
|
+
end
|
31
|
+
|
32
|
+
def existing_migration
|
33
|
+
@existing_migration ||= begin
|
34
|
+
@base.class.migration_exists?(migration_dir, migration_file_name) ||
|
35
|
+
File.exist?(@destination) && @destination
|
36
|
+
end
|
37
|
+
end
|
38
|
+
alias :exists? :existing_migration
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def on_conflict_behavior(&block)
|
43
|
+
options = base.options.merge(config)
|
44
|
+
if identical?
|
45
|
+
say_status :identical, :blue, relative_existing_migration
|
46
|
+
elsif options[:force]
|
47
|
+
say_status :remove, :green, relative_existing_migration
|
48
|
+
say_status :create, :green
|
49
|
+
unless pretend?
|
50
|
+
::FileUtils.rm_rf(existing_migration)
|
51
|
+
block.call
|
52
|
+
end
|
53
|
+
elsif options[:skip]
|
54
|
+
say_status :skip, :yellow
|
55
|
+
else
|
56
|
+
say_status :conflict, :red
|
57
|
+
raise Error, "Another migration is already named #{migration_file_name}: " +
|
58
|
+
"#{existing_migration}. Use --force to replace this migration file."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def say_status(status, color, message = relative_destination)
|
63
|
+
base.shell.say_status(status, message, color) if config[:verbose]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -141,73 +141,12 @@ module Rails
|
|
141
141
|
FileUtils.cd(destination_root) unless options[:pretend]
|
142
142
|
end
|
143
143
|
|
144
|
-
class TemplateRecorder < ::BasicObject # :nodoc:
|
145
|
-
attr_reader :gems
|
146
|
-
|
147
|
-
def initialize(target)
|
148
|
-
@target = target
|
149
|
-
# unfortunately, instance eval has access to these ivars
|
150
|
-
@app_const = target.send :app_const if target.respond_to?(:app_const, true)
|
151
|
-
@app_const_base = target.send :app_const_base if target.respond_to?(:app_const_base, true)
|
152
|
-
@app_name = target.send :app_name if target.respond_to?(:app_name, true)
|
153
|
-
@commands = []
|
154
|
-
@gems = []
|
155
|
-
end
|
156
|
-
|
157
|
-
def gemfile_entry(*args)
|
158
|
-
@target.send :gemfile_entry, *args
|
159
|
-
end
|
160
|
-
|
161
|
-
def add_gem_entry_filter(*args, &block)
|
162
|
-
@target.send :add_gem_entry_filter, *args, &block
|
163
|
-
end
|
164
|
-
|
165
|
-
def method_missing(name, *args, &block)
|
166
|
-
@commands << [name, args, block]
|
167
|
-
end
|
168
|
-
|
169
|
-
def respond_to_missing?(method, priv = false)
|
170
|
-
super || @target.respond_to?(method, priv)
|
171
|
-
end
|
172
|
-
|
173
|
-
def replay!
|
174
|
-
@commands.each do |name, args, block|
|
175
|
-
@target.send name, *args, &block
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
144
|
def apply_rails_template
|
181
|
-
|
182
|
-
|
183
|
-
apply(rails_template, target: @recorder) if rails_template
|
145
|
+
apply rails_template if rails_template
|
184
146
|
rescue Thor::Error, LoadError, Errno::ENOENT => e
|
185
147
|
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
|
186
148
|
end
|
187
149
|
|
188
|
-
def replay_template
|
189
|
-
@recorder.replay! if @recorder
|
190
|
-
end
|
191
|
-
|
192
|
-
def apply(path, config={})
|
193
|
-
verbose = config.fetch(:verbose, true)
|
194
|
-
target = config.fetch(:target, self)
|
195
|
-
is_uri = path =~ /^https?\:\/\//
|
196
|
-
path = find_in_source_paths(path) unless is_uri
|
197
|
-
|
198
|
-
say_status :apply, path, verbose
|
199
|
-
shell.padding += 1 if verbose
|
200
|
-
|
201
|
-
if is_uri
|
202
|
-
contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read }
|
203
|
-
else
|
204
|
-
contents = open(path) {|io| io.read }
|
205
|
-
end
|
206
|
-
|
207
|
-
target.instance_eval(contents, path)
|
208
|
-
shell.padding -= 1 if verbose
|
209
|
-
end
|
210
|
-
|
211
150
|
def set_default_accessors!
|
212
151
|
self.destination_root = File.expand_path(app_path, destination_root)
|
213
152
|
self.rails_template = case options[:template]
|
@@ -308,7 +247,7 @@ module Rails
|
|
308
247
|
'Use SCSS for stylesheets')
|
309
248
|
else
|
310
249
|
gems << GemfileEntry.version('sass-rails',
|
311
|
-
'~> 4.0.
|
250
|
+
'~> 4.0.1',
|
312
251
|
'Use SCSS for stylesheets')
|
313
252
|
end
|
314
253
|
|
@@ -329,12 +268,12 @@ module Rails
|
|
329
268
|
|
330
269
|
def jbuilder_gemfile_entry
|
331
270
|
comment = 'Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder'
|
332
|
-
GemfileEntry.version('jbuilder', '~>
|
271
|
+
GemfileEntry.version('jbuilder', '~> 2.0', comment)
|
333
272
|
end
|
334
273
|
|
335
274
|
def sdoc_gemfile_entry
|
336
275
|
comment = 'bundle exec rake doc:rails generates the API under doc/api.'
|
337
|
-
GemfileEntry.new('sdoc',
|
276
|
+
GemfileEntry.new('sdoc', '~> 0.4.0', comment, group: :doc)
|
338
277
|
end
|
339
278
|
|
340
279
|
def coffee_gemfile_entry
|
@@ -371,7 +310,7 @@ module Rails
|
|
371
310
|
|
372
311
|
def spring_gemfile_entry
|
373
312
|
return [] unless spring_install?
|
374
|
-
comment = 'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/
|
313
|
+
comment = 'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring'
|
375
314
|
GemfileEntry.new('spring', nil, comment, group: :development)
|
376
315
|
end
|
377
316
|
|
@@ -394,7 +333,8 @@ module Rails
|
|
394
333
|
|
395
334
|
require 'bundler'
|
396
335
|
Bundler.with_clean_env do
|
397
|
-
|
336
|
+
output = `"#{Gem.ruby}" "#{_bundle_command}" #{command}`
|
337
|
+
print output unless options[:quiet]
|
398
338
|
end
|
399
339
|
end
|
400
340
|
|