railties 4.0.0.beta1 → 4.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +120 -27
  3. data/RDOC_MAIN.rdoc +73 -0
  4. data/bin/rails +3 -1
  5. data/lib/rails/api/task.rb +158 -0
  6. data/lib/rails/app_rails_loader.rb +44 -20
  7. data/lib/rails/application.rb +55 -32
  8. data/lib/rails/application/configuration.rb +9 -7
  9. data/lib/rails/commands.rb +2 -0
  10. data/lib/rails/commands/console.rb +3 -1
  11. data/lib/rails/commands/server.rb +6 -2
  12. data/lib/rails/engine.rb +4 -3
  13. data/lib/rails/generators/actions.rb +1 -1
  14. data/lib/rails/generators/app_base.rb +52 -30
  15. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
  16. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +9 -9
  17. data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -2
  18. data/lib/rails/generators/generated_attribute.rb +4 -0
  19. data/lib/rails/generators/named_base.rb +2 -1
  20. data/lib/rails/generators/rails/app/templates/Gemfile +9 -4
  21. data/lib/rails/generators/rails/app/templates/config.ru +1 -1
  22. data/lib/rails/generators/rails/app/templates/config/application.rb +3 -2
  23. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -0
  24. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
  25. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
  26. data/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +1 -1
  27. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  28. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  29. data/lib/rails/generators/rails/app/templates/public/404.html +41 -10
  30. data/lib/rails/generators/rails/app/templates/public/422.html +42 -10
  31. data/lib/rails/generators/rails/app/templates/public/500.html +41 -10
  32. data/lib/rails/generators/rails/app/templates/test/test_helper.rb +1 -1
  33. data/lib/rails/generators/rails/model/USAGE +16 -10
  34. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +9 -5
  35. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +0 -3
  36. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +0 -8
  37. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +4 -8
  38. data/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js +13 -0
  39. data/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css +13 -0
  40. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +1 -0
  41. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
  42. data/lib/rails/generators/test_case.rb +6 -211
  43. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +7 -9
  44. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
  45. data/lib/rails/generators/testing/assertions.rb +121 -0
  46. data/lib/rails/generators/testing/behaviour.rb +106 -0
  47. data/lib/rails/generators/testing/setup_and_teardown.rb +18 -0
  48. data/lib/rails/info.rb +2 -2
  49. data/lib/rails/tasks/documentation.rake +2 -46
  50. data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
  51. data/lib/rails/test_unit/railtie.rb +4 -0
  52. data/lib/rails/test_unit/sub_test_task.rb +78 -1
  53. data/lib/rails/test_unit/testing.rake +32 -42
  54. data/lib/rails/version.rb +3 -3
  55. metadata +15 -23
  56. data/lib/rails/generators/rails/app/templates/app/assets/images/rails.png +0 -0
@@ -4,34 +4,58 @@ module Rails
4
4
  module AppRailsLoader
5
5
  RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
6
6
  EXECUTABLES = ['bin/rails', 'script/rails']
7
+ BUNDLER_WARNING = <<EOS
8
+ Looks like your app's ./bin/rails is a stub that was generated by Bundler.
9
+
10
+ In Rails 4, your app's bin/ directory contains executables that are versioned
11
+ like any other source code, rather than stubs that are generated on demand.
12
+
13
+ Here's how to upgrade:
14
+
15
+ bundle config --delete bin # Turn off Bundler's stub generator
16
+ rake rails:update:bin # Use the new Rails 4 executables
17
+ git add bin # Add bin/ to source control
18
+
19
+ You may need to remove bin/ from your .gitignore as well.
20
+
21
+ When you install a gem whose executable you want to use in your app,
22
+ generate it and add it to source control:
23
+
24
+ bundle binstubs some-gem-name
25
+ git add bin/new-executable
26
+
27
+ EOS
7
28
 
8
29
  def self.exec_app_rails
9
- cwd = Dir.pwd
30
+ original_cwd = Dir.pwd
10
31
 
11
- exe = find_executable
12
- exe ||= find_executable_in_parent_path
13
- return unless exe
32
+ loop do
33
+ if exe = find_executable
34
+ contents = File.read(exe)
14
35
 
15
- exec RUBY, exe, *ARGV if find_executable
16
- Dir.chdir("..") do
17
- # Recurse in a chdir block: if the search fails we want to be sure
18
- # the application is generated in the original working directory.
19
- exec_app_rails unless cwd == Dir.pwd
20
- end
21
- rescue SystemCallError
22
- # could not chdir, no problem just return
23
- end
36
+ if contents =~ /(APP|ENGINE)_PATH/
37
+ exec RUBY, exe, *ARGV
38
+ break # non reachable, hack to be able to stub exec in the test suite
39
+ elsif exe.end_with?('bin/rails') && contents.include?('This file was generated by Bundler')
40
+ $stderr.puts(BUNDLER_WARNING)
41
+ Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd))
42
+ require File.expand_path('../boot', APP_PATH)
43
+ require 'rails/commands'
44
+ break
45
+ end
46
+ end
24
47
 
25
- def self.find_executable
26
- EXECUTABLES.find do |exe|
27
- File.exists?(exe) && File.read(exe) =~ /(APP|ENGINE)_PATH/
48
+ # If we exhaust the search there is no executable, this could be a
49
+ # call to generate a new application, so restore the original cwd.
50
+ Dir.chdir(original_cwd) and return if Pathname.new(Dir.pwd).root?
51
+
52
+ # Otherwise keep moving upwards in search of a executable.
53
+ Dir.chdir('..')
28
54
  end
29
55
  end
30
56
 
31
- def self.find_executable_in_parent_path(path = Pathname.new(Dir.pwd))
32
- EXECUTABLES.find do |exe|
33
- File.exists?(File.join(path, exe)) || !path.root? && find_executable_in_parent_path(path.parent)
34
- end
57
+ def self.find_executable
58
+ EXECUTABLES.find { |exe| File.exists?(exe) }
35
59
  end
36
60
  end
37
61
  end
@@ -1,5 +1,5 @@
1
1
  require 'fileutils'
2
- # FIXME remove DummyKeyGenerator and this require in 4.1
2
+ require 'active_support/core_ext/object/blank'
3
3
  require 'active_support/key_generator'
4
4
  require 'rails/engine'
5
5
 
@@ -46,10 +46,10 @@ module Rails
46
46
  # 6) Run config.before_initialize callbacks
47
47
  # 7) Run Railtie#initializer defined by railties, engines and application.
48
48
  # One by one, each engine sets up its load paths, routes and runs its config/initializers/* files.
49
- # 9) Custom Railtie#initializers added by railties, engines and applications are executed
50
- # 10) Build the middleware stack and run to_prepare callbacks
51
- # 11) Run config.before_eager_load and eager_load! if eager_load is true
52
- # 12) Run config.after_initialize callbacks
49
+ # 8) Custom Railtie#initializers added by railties, engines and applications are executed
50
+ # 9) Build the middleware stack and run to_prepare callbacks
51
+ # 10) Run config.before_eager_load and eager_load! if eager_load is true
52
+ # 11) Run config.after_initialize callbacks
53
53
  #
54
54
  class Application < Engine
55
55
  autoload :Bootstrap, 'rails/application/bootstrap'
@@ -79,7 +79,7 @@ module Rails
79
79
  @initialized = false
80
80
  @reloaders = []
81
81
  @routes_reloader = nil
82
- @env_config = nil
82
+ @app_env_config = nil
83
83
  @ordered_railties = nil
84
84
  @railties = nil
85
85
  end
@@ -111,7 +111,7 @@ module Rails
111
111
  key_generator = ActiveSupport::KeyGenerator.new(config.secret_key_base, iterations: 1000)
112
112
  ActiveSupport::CachingKeyGenerator.new(key_generator)
113
113
  else
114
- ActiveSupport::DummyKeyGenerator.new(config.secret_token)
114
+ ActiveSupport::LegacyKeyGenerator.new(config.secret_token)
115
115
  end
116
116
  end
117
117
  end
@@ -122,7 +122,8 @@ module Rails
122
122
  #
123
123
  # * "action_dispatch.parameter_filter" => config.filter_parameters
124
124
  # * "action_dispatch.redirect_filter" => config.filter_redirect
125
- # * "action_dispatch.secret_token" => config.secret_token,
125
+ # * "action_dispatch.secret_token" => config.secret_token
126
+ # * "action_dispatch.secret_key_base" => config.secret_key_base
126
127
  # * "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions
127
128
  # * "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local
128
129
  # * "action_dispatch.logger" => Rails.logger
@@ -134,14 +135,13 @@ module Rails
134
135
  # * "action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt
135
136
  #
136
137
  def env_config
137
- @env_config ||= begin
138
- if config.secret_key_base.nil?
139
- ActiveSupport::Deprecation.warn "You didn't set config.secret_key_base in config/initializers/secret_token.rb file. " +
140
- "This should be used instead of the old deprecated config.secret_token in order to use the new EncryptedCookieStore. " +
141
- "To convert safely to the encrypted store (without losing existing cookies and sessions), see http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#action-pack"
138
+ @app_env_config ||= begin
139
+ if config.secret_key_base.blank?
140
+ ActiveSupport::Deprecation.warn "You didn't set config.secret_key_base. " +
141
+ "Read the upgrade documentation to learn more about this new config option."
142
142
 
143
143
  if config.secret_token.blank?
144
- raise "You must set config.secret_key_base in your app's config"
144
+ raise "You must set config.secret_key_base in your app's config."
145
145
  end
146
146
  end
147
147
 
@@ -149,6 +149,7 @@ module Rails
149
149
  "action_dispatch.parameter_filter" => config.filter_parameters,
150
150
  "action_dispatch.redirect_filter" => config.filter_redirect,
151
151
  "action_dispatch.secret_token" => config.secret_token,
152
+ "action_dispatch.secret_key_base" => config.secret_key_base,
152
153
  "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
153
154
  "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
154
155
  "action_dispatch.logger" => Rails.logger,
@@ -305,22 +306,8 @@ module Rails
305
306
  def default_middleware_stack #:nodoc:
306
307
  ActionDispatch::MiddlewareStack.new.tap do |middleware|
307
308
  app = self
308
- if rack_cache = config.action_dispatch.rack_cache
309
- begin
310
- require 'rack/cache'
311
- rescue LoadError => error
312
- error.message << ' Be sure to add rack-cache to your Gemfile'
313
- raise
314
- end
315
-
316
- if rack_cache == true
317
- rack_cache = {
318
- metastore: "rails:/",
319
- entitystore: "rails:/",
320
- verbose: false
321
- }
322
- end
323
309
 
310
+ if rack_cache = load_rack_cache
324
311
  require "action_dispatch/http/rack_cache"
325
312
  middleware.use ::Rack::Cache, rack_cache
326
313
  end
@@ -337,12 +324,14 @@ module Rails
337
324
  middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
338
325
  end
339
326
 
340
- middleware.use ::Rack::Lock unless config.cache_classes
327
+ middleware.use ::Rack::Lock unless allow_concurrency?
341
328
  middleware.use ::Rack::Runtime
342
329
  middleware.use ::Rack::MethodOverride
343
330
  middleware.use ::ActionDispatch::RequestId
344
- middleware.use ::Rails::Rack::Logger, config.log_tags # must come after Rack::MethodOverride to properly log overridden methods
345
- middleware.use ::ActionDispatch::ShowExceptions, config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
331
+
332
+ # Must come after Rack::MethodOverride to properly log overridden methods
333
+ middleware.use ::Rails::Rack::Logger, config.log_tags
334
+ middleware.use ::ActionDispatch::ShowExceptions, show_exceptions_app
346
335
  middleware.use ::ActionDispatch::DebugExceptions, app
347
336
  middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
348
337
 
@@ -368,6 +357,40 @@ module Rails
368
357
  end
369
358
  end
370
359
 
360
+ def allow_concurrency?
361
+ if config.allow_concurrency.nil?
362
+ config.cache_classes
363
+ else
364
+ config.allow_concurrency
365
+ end
366
+ end
367
+
368
+ def load_rack_cache
369
+ rack_cache = config.action_dispatch.rack_cache
370
+ return unless rack_cache
371
+
372
+ begin
373
+ require 'rack/cache'
374
+ rescue LoadError => error
375
+ error.message << ' Be sure to add rack-cache to your Gemfile'
376
+ raise
377
+ end
378
+
379
+ if rack_cache == true
380
+ {
381
+ metastore: "rails:/",
382
+ entitystore: "rails:/",
383
+ verbose: false
384
+ }
385
+ else
386
+ rack_cache
387
+ end
388
+ end
389
+
390
+ def show_exceptions_app
391
+ config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
392
+ end
393
+
371
394
  def build_original_fullpath(env) #:nodoc:
372
395
  path_info = env["PATH_INFO"]
373
396
  query_string = env["QUERY_STRING"]
@@ -5,7 +5,7 @@ require 'rails/engine/configuration'
5
5
  module Rails
6
6
  class Application
7
7
  class Configuration < ::Rails::Engine::Configuration
8
- attr_accessor :asset_host, :assets, :autoflush_log,
8
+ attr_accessor :allow_concurrency, :asset_host, :assets, :autoflush_log,
9
9
  :cache_classes, :cache_store, :consider_all_requests_local, :console,
10
10
  :eager_load, :exceptions_app, :file_watcher, :filter_parameters,
11
11
  :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,
@@ -20,6 +20,7 @@ module Rails
20
20
  def initialize(*)
21
21
  super
22
22
  self.encoding = "utf-8"
23
+ @allow_concurrency = nil
23
24
  @consider_all_requests_local = false
24
25
  @filter_parameters = []
25
26
  @filter_redirect = []
@@ -98,14 +99,15 @@ module Rails
98
99
  end
99
100
 
100
101
  # Loads and returns the configuration of the database.
101
- # First, looks at If ENV['DATABASE_URL'] if it's not present it uses the #paths["config/database"]
102
- # The contents of the file are processed via ERB before being sent through YAML::load.
103
102
  def database_configuration
104
- if ENV['DATABASE_URL']
105
- {Rails.env => ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.connection_url_to_hash(ENV['DATABASE_URL']).stringify_keys}
103
+ yaml = paths["config/database"].first
104
+ if File.exists?(yaml)
105
+ require "erb"
106
+ YAML.load ERB.new(IO.read(yaml)).result
107
+ elsif ENV['DATABASE_URL']
108
+ nil
106
109
  else
107
- require 'erb'
108
- YAML.load ERB.new(IO.read(paths["config/database"].first)).result
110
+ raise "Could not load database configuration. No such file - #{yaml}"
109
111
  end
110
112
  rescue Psych::SyntaxError => e
111
113
  raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
@@ -5,6 +5,7 @@ aliases = {
5
5
  "d" => "destroy",
6
6
  "c" => "console",
7
7
  "s" => "server",
8
+ "t" => "test",
8
9
  "db" => "dbconsole",
9
10
  "r" => "runner"
10
11
  }
@@ -16,6 +17,7 @@ The most common rails commands are:
16
17
  generate Generate new code (short-cut alias: "g")
17
18
  console Start the Rails console (short-cut alias: "c")
18
19
  server Start the Rails server (short-cut alias: "s")
20
+ test Running the test file (short-cut alias: "t")
19
21
  dbconsole Start a console for the database specified in config/database.yml
20
22
  (short-cut alias: "db")
21
23
  new Create a new Rails application. "rails new my_app" creates a
@@ -46,7 +46,10 @@ module Rails
46
46
  def initialize(app, options={})
47
47
  @app = app
48
48
  @options = options
49
+
50
+ app.sandbox = sandbox?
49
51
  app.load_console
52
+
50
53
  @console = app.config.console || IRB
51
54
  end
52
55
 
@@ -71,7 +74,6 @@ module Rails
71
74
  end
72
75
 
73
76
  def start
74
- app.sandbox = sandbox?
75
77
  require_debugger if debugger?
76
78
  set_environment! if environment?
77
79
 
@@ -42,8 +42,12 @@ module Rails
42
42
  set_environment
43
43
  end
44
44
 
45
+ # TODO: this is no longer required but we keep it for the moment to support older config.ru files.
45
46
  def app
46
- @app ||= super.respond_to?(:to_app) ? super.to_app : super
47
+ @app ||= begin
48
+ app = super
49
+ app.respond_to?(:to_app) ? app.to_app : app
50
+ end
47
51
  end
48
52
 
49
53
  def opt_parser
@@ -58,7 +62,7 @@ module Rails
58
62
  url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}"
59
63
  puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
60
64
  puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}"
61
- puts "=> Call with -d to detach" unless options[:daemonize]
65
+ puts "=> Run `rails server -h` for more startup options"
62
66
  trap(:INT) { exit }
63
67
  puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
64
68
 
@@ -1,4 +1,5 @@
1
1
  require 'rails/railtie'
2
+ require 'rails/engine/railties'
2
3
  require 'active_support/core_ext/module/delegation'
3
4
  require 'pathname'
4
5
  require 'rbconfig'
@@ -106,7 +107,7 @@ module Rails
106
107
  #
107
108
  # The <tt>Application</tt> class adds a couple more paths to this set. And as in your
108
109
  # <tt>Application</tt>, all folders under +app+ are automatically added to the load path.
109
- # If you have an <tt>app/services/tt> folder for example, it will be added by default.
110
+ # If you have an <tt>app/services</tt> folder for example, it will be added by default.
110
111
  #
111
112
  # == Endpoint
112
113
  #
@@ -467,7 +468,7 @@ module Rails
467
468
  end
468
469
 
469
470
  def railties
470
- @railties ||= self.class::Railties.new
471
+ @railties ||= Railties.new
471
472
  end
472
473
 
473
474
  # Returns a module with all the helpers defined for the engine.
@@ -552,7 +553,7 @@ module Rails
552
553
  #
553
554
  # This needs to be an initializer, since it needs to run once
554
555
  # per engine and get the engine as a block parameter
555
- initializer :set_autoload_paths, before: :bootstrap_hook do |app|
556
+ initializer :set_autoload_paths, before: :bootstrap_hook do
556
557
  ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
557
558
  ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths)
558
559
 
@@ -215,7 +215,7 @@ module Rails
215
215
 
216
216
  # Make an entry in Rails routing file config/routes.rb
217
217
  #
218
- # route "root :to => 'welcome#index'"
218
+ # route "root 'welcome#index'"
219
219
  def route(routing_code)
220
220
  log :route, routing_code
221
221
  sentinel = /\.routes\.draw do\s*$/
@@ -115,7 +115,11 @@ module Rails
115
115
  end
116
116
 
117
117
  def database_gemfile_entry
118
- options[:skip_active_record] ? "" : "gem '#{gem_for_database}'"
118
+ options[:skip_active_record] ? "" :
119
+ <<-GEMFILE.strip_heredoc.chomp
120
+ # Use #{options[:database]} as the database for Active Record
121
+ gem '#{gem_for_database}'
122
+ GEMFILE
119
123
  end
120
124
 
121
125
  def include_all_railties?
@@ -131,13 +135,11 @@ module Rails
131
135
  <<-GEMFILE.strip_heredoc
132
136
  gem 'rails', path: '#{Rails::Generators::RAILS_DEV_PATH}'
133
137
  gem 'arel', github: 'rails/arel'
134
- gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
135
138
  GEMFILE
136
139
  elsif options.edge?
137
140
  <<-GEMFILE.strip_heredoc
138
141
  gem 'rails', github: 'rails/rails'
139
142
  gem 'arel', github: 'rails/arel'
140
- gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
141
143
  GEMFILE
142
144
  else
143
145
  <<-GEMFILE.strip_heredoc
@@ -178,40 +180,56 @@ module Rails
178
180
  return if options[:skip_sprockets]
179
181
 
180
182
  gemfile = if options.dev? || options.edge?
183
+ <<-GEMFILE.strip_heredoc
184
+ # Use edge version of sprockets-rails
185
+ gem 'sprockets-rails', github: 'rails/sprockets-rails'
186
+
187
+ # Use SCSS for stylesheets
188
+ gem 'sass-rails', github: 'rails/sass-rails'
189
+
190
+ # Use Uglifier as compressor for JavaScript assets
191
+ gem 'uglifier', '>= 1.3.0'
192
+ GEMFILE
193
+ else
194
+ <<-GEMFILE.strip_heredoc
195
+ # Use SCSS for stylesheets
196
+ gem 'sass-rails', '~> 4.0.0.rc1'
197
+
198
+ # Use Uglifier as compressor for JavaScript assets
199
+ gem 'uglifier', '>= 1.3.0'
200
+ GEMFILE
201
+ end
202
+
203
+ if options[:skip_javascript]
204
+ gemfile += <<-GEMFILE
205
+ #{coffee_gemfile_entry}
206
+ #{javascript_runtime_gemfile_entry}
207
+ GEMFILE
208
+ end
209
+
210
+ gemfile.gsub(/^[ \t]+/, '')
211
+ end
212
+
213
+ def coffee_gemfile_entry
214
+ if options.dev? || options.edge?
181
215
  <<-GEMFILE
182
- # Gems used only for assets and not required
183
- # in production environments by default.
184
- group :assets do
185
- gem 'sprockets-rails', github: 'rails/sprockets-rails'
186
- gem 'sass-rails', github: 'rails/sass-rails'
187
- gem 'coffee-rails', github: 'rails/coffee-rails'
188
-
189
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
190
- #{javascript_runtime_gemfile_entry}
191
- gem 'uglifier', '>= 1.0.3'
192
- end
216
+ # Use CoffeeScript for .js.coffee assets and views
217
+ gem 'coffee-rails', github: 'rails/coffee-rails'
193
218
  GEMFILE
194
219
  else
195
220
  <<-GEMFILE
196
- # Gems used only for assets and not required
197
- # in production environments by default.
198
- group :assets do
199
- gem 'sass-rails', '~> 4.0.0.beta1'
200
- gem 'coffee-rails', '~> 4.0.0.beta1'
201
-
202
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
203
- #{javascript_runtime_gemfile_entry}
204
- gem 'uglifier', '>= 1.0.3'
205
- end
221
+ # Use CoffeeScript for .js.coffee assets and views
222
+ gem 'coffee-rails', '~> 4.0.0'
206
223
  GEMFILE
207
224
  end
208
-
209
- gemfile.strip_heredoc.gsub(/^[ \t]*$/, '')
210
225
  end
211
226
 
212
227
  def javascript_gemfile_entry
213
228
  unless options[:skip_javascript]
214
- <<-GEMFILE.strip_heredoc
229
+ <<-GEMFILE.gsub(/^[ \t]+/, '')
230
+ #{coffee_gemfile_entry}
231
+ #{javascript_runtime_gemfile_entry}
232
+ # Use #{options[:javascript]} as the JavaScript library
215
233
  gem '#{options[:javascript]}-rails'
216
234
 
217
235
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
@@ -221,11 +239,15 @@ module Rails
221
239
  end
222
240
 
223
241
  def javascript_runtime_gemfile_entry
224
- if defined?(JRUBY_VERSION)
225
- "gem 'therubyrhino'\n"
242
+ runtime = if defined?(JRUBY_VERSION)
243
+ "gem 'therubyrhino'"
226
244
  else
227
- "# gem 'therubyracer', platforms: :ruby\n"
245
+ "# gem 'therubyracer', platforms: :ruby"
228
246
  end
247
+ <<-GEMFILE
248
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
249
+ #{runtime}
250
+ GEMFILE
229
251
  end
230
252
 
231
253
  def bundle_command(command)