railties 4.1.16 → 4.2.0.beta1

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -439
  3. data/RDOC_MAIN.rdoc +1 -1
  4. data/README.rdoc +6 -2
  5. data/lib/rails.rb +7 -1
  6. data/lib/rails/all.rb +1 -0
  7. data/lib/rails/api/task.rb +7 -0
  8. data/lib/rails/app_rails_loader.rb +4 -2
  9. data/lib/rails/application.rb +74 -47
  10. data/lib/rails/application/configuration.rb +23 -1
  11. data/lib/rails/application/finisher.rb +0 -2
  12. data/lib/rails/code_statistics.rb +4 -2
  13. data/lib/rails/commands/commands_tasks.rb +1 -6
  14. data/lib/rails/commands/console.rb +24 -12
  15. data/lib/rails/commands/dbconsole.rb +2 -2
  16. data/lib/rails/commands/plugin.rb +1 -1
  17. data/lib/rails/commands/server.rb +22 -9
  18. data/lib/rails/engine.rb +7 -7
  19. data/lib/rails/gem_version.rb +3 -3
  20. data/lib/rails/generators.rb +68 -15
  21. data/lib/rails/generators/actions.rb +27 -7
  22. data/lib/rails/generators/actions/create_migration.rb +2 -1
  23. data/lib/rails/generators/app_base.rb +55 -65
  24. data/lib/rails/generators/base.rb +2 -2
  25. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +0 -5
  26. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +1 -1
  27. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +3 -1
  28. data/lib/rails/generators/erb/scaffold/templates/new.html.erb +1 -1
  29. data/lib/rails/generators/generated_attribute.rb +24 -4
  30. data/lib/rails/generators/model_helpers.rb +28 -0
  31. data/lib/rails/generators/rails/app/app_generator.rb +8 -2
  32. data/lib/rails/generators/rails/app/templates/Gemfile +21 -6
  33. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +1 -1
  34. data/lib/rails/generators/rails/app/templates/bin/setup +28 -0
  35. data/lib/rails/generators/rails/app/templates/config/application.rb +5 -1
  36. data/lib/rails/generators/rails/app/templates/config/boot.rb +1 -2
  37. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +1 -3
  38. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
  39. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +4 -0
  40. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +8 -10
  41. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -0
  42. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +1 -1
  43. data/lib/rails/generators/rails/app/templates/gitignore +2 -0
  44. data/lib/rails/generators/rails/controller/USAGE +0 -1
  45. data/lib/rails/generators/rails/controller/controller_generator.rb +6 -2
  46. data/lib/rails/generators/rails/helper/USAGE +0 -4
  47. data/lib/rails/generators/rails/model/USAGE +11 -1
  48. data/lib/rails/generators/rails/model/model_generator.rb +4 -0
  49. data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -3
  50. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec +1 -1
  51. data/lib/rails/generators/rails/plugin/templates/Gemfile +10 -6
  52. data/lib/rails/generators/rails/plugin/templates/Rakefile +4 -0
  53. data/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +0 -1
  54. data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +1 -1
  55. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +2 -10
  56. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -4
  57. data/lib/rails/generators/rails/scaffold/USAGE +7 -1
  58. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +0 -1
  59. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
  60. data/lib/rails/generators/resource_helpers.rb +2 -11
  61. data/lib/rails/generators/test_unit/helper/helper_generator.rb +1 -5
  62. data/lib/rails/generators/testing/behaviour.rb +17 -0
  63. data/lib/rails/info.rb +1 -1
  64. data/lib/rails/info_controller.rb +1 -1
  65. data/lib/rails/mailers_controller.rb +14 -16
  66. data/lib/rails/paths.rb +1 -1
  67. data/lib/rails/rack.rb +1 -1
  68. data/lib/rails/rack/log_tailer.rb +4 -0
  69. data/lib/rails/rack/logger.rb +1 -1
  70. data/lib/rails/railtie.rb +2 -2
  71. data/lib/rails/ruby_version_check.rb +1 -1
  72. data/lib/rails/source_annotation_extractor.rb +23 -16
  73. data/lib/rails/tasks/framework.rake +1 -1
  74. data/lib/rails/tasks/statistics.rake +8 -3
  75. data/lib/rails/templates/rails/mailers/email.html.erb +2 -13
  76. data/lib/rails/templates/rails/mailers/index.html.erb +2 -2
  77. data/lib/rails/templates/rails/mailers/mailer.html.erb +1 -1
  78. data/lib/rails/test_unit/sub_test_task.rb +2 -2
  79. metadata +13 -13
  80. data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +0 -6
  81. data/lib/rails/rubyprof_ext.rb +0 -35
@@ -20,7 +20,7 @@ module Rails
20
20
  ENV['RAILS_ENV'] = options[:environment] || environment
21
21
 
22
22
  case config["adapter"]
23
- when /^mysql/
23
+ when /^(jdbc)?mysql/
24
24
  args = {
25
25
  'host' => '--host',
26
26
  'port' => '--port',
@@ -30,7 +30,7 @@ module Rails
30
30
  'sslca' => '--ssl-ca',
31
31
  'sslcert' => '--ssl-cert',
32
32
  'sslcapath' => '--ssl-capath',
33
- 'sslcipher' => '--ssl-cipher',
33
+ 'sslcipher' => '--ssh-cipher',
34
34
  'sslkey' => '--ssl-key'
35
35
  }.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
36
36
 
@@ -11,7 +11,7 @@ else
11
11
  end
12
12
  if File.exist?(railsrc)
13
13
  extra_args_string = File.read(railsrc)
14
- extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten
14
+ extra_args = extra_args_string.split(/\n+/).flat_map {|l| l.split}
15
15
  puts "Using #{extra_args.join(" ")} from #{railsrc}"
16
16
  ARGV.insert(1, *extra_args)
17
17
  end
@@ -9,7 +9,17 @@ module Rails
9
9
  def parse!(args)
10
10
  args, options = args.dup, {}
11
11
 
12
- opt_parser = OptionParser.new do |opts|
12
+ option_parser(options).parse! args
13
+
14
+ options[:log_stdout] = options[:daemonize].blank? && (options[:environment] || Rails.env) == "development"
15
+ options[:server] = args.shift
16
+ options
17
+ end
18
+
19
+ private
20
+
21
+ def option_parser(options)
22
+ OptionParser.new do |opts|
13
23
  opts.banner = "Usage: rails server [mongrel, thin, etc] [options]"
14
24
  opts.on("-p", "--port=port", Integer,
15
25
  "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v }
@@ -18,7 +28,14 @@ module Rails
18
28
  opts.on("-c", "--config=file", String,
19
29
  "Use custom rackup configuration file") { |v| options[:config] = v }
20
30
  opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true }
21
- opts.on("-u", "--debugger", "Enable the debugger") { options[:debugger] = true }
31
+ opts.on("-u", "--debugger", "Enable the debugger") do
32
+ if RUBY_VERSION < '2.0.0'
33
+ options[:debugger] = true
34
+ else
35
+ puts "=> Notice: debugger option is ignored since ruby 2.0 and " \
36
+ "it will be removed in future versions"
37
+ end
38
+ end
22
39
  opts.on("-e", "--environment=name", String,
23
40
  "Specifies the environment to run this server under (test/development/production).",
24
41
  "Default: development") { |v| options[:environment] = v }
@@ -30,12 +47,6 @@ module Rails
30
47
 
31
48
  opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
32
49
  end
33
-
34
- opt_parser.parse! args
35
-
36
- options[:log_stdout] = options[:daemonize].blank? && (options[:environment] || Rails.env) == "development"
37
- options[:server] = args.shift
38
- options
39
50
  end
40
51
  end
41
52
 
@@ -75,7 +86,9 @@ module Rails
75
86
 
76
87
  def middleware
77
88
  middlewares = []
78
- middlewares << [Rails::Rack::Debugger] if options[:debugger]
89
+ if RUBY_VERSION < '2.0.0'
90
+ middlewares << [Rails::Rack::Debugger] if options[:debugger]
91
+ end
79
92
  middlewares << [::Rack::ContentLength]
80
93
 
81
94
  # FIXME: add Rack::Lock in the case people are using webrick.
data/lib/rails/engine.rb CHANGED
@@ -351,7 +351,7 @@ module Rails
351
351
 
352
352
  base.called_from = begin
353
353
  call_stack = if Kernel.respond_to?(:caller_locations)
354
- caller_locations.map { |l| l.absolute_path || l.path }
354
+ caller_locations.map(&:path)
355
355
  else
356
356
  # Remove the line number from backtraces making sure we don't leave anything behind
357
357
  caller.map { |p| p.sub(/:\d+.*/, '') }
@@ -371,7 +371,7 @@ module Rails
371
371
  end
372
372
 
373
373
  def isolate_namespace(mod)
374
- engine_name(generate_railtie_name(mod))
374
+ engine_name(generate_railtie_name(mod.name))
375
375
 
376
376
  self.routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
377
377
  self.isolated = true
@@ -395,7 +395,7 @@ module Rails
395
395
  end
396
396
 
397
397
  unless mod.respond_to?(:railtie_routes_url_helpers)
398
- define_method(:railtie_routes_url_helpers) { railtie.routes.url_helpers }
398
+ define_method(:railtie_routes_url_helpers) {|include_path_helpers = true| railtie.routes.url_helpers(include_path_helpers) }
399
399
  end
400
400
  end
401
401
  end
@@ -509,7 +509,7 @@ module Rails
509
509
  def call(env)
510
510
  env.merge!(env_config)
511
511
  if env['SCRIPT_NAME']
512
- env.merge! "ROUTES_#{routes.object_id}_SCRIPT_NAME" => env['SCRIPT_NAME'].dup
512
+ env["ROUTES_#{routes.object_id}_SCRIPT_NAME"] = env['SCRIPT_NAME'].dup
513
513
  end
514
514
  app.call(env)
515
515
  end
@@ -567,10 +567,10 @@ module Rails
567
567
  end
568
568
 
569
569
  initializer :add_routing_paths do |app|
570
- routing_paths = self.paths["config/routes.rb"].existent
570
+ paths = self.paths["config/routes.rb"].existent
571
571
 
572
- if routes? || routing_paths.any?
573
- app.routes_reloader.paths.unshift(*routing_paths)
572
+ if routes? || paths.any?
573
+ app.routes_reloader.paths.unshift(*paths)
574
574
  app.routes_reloader.route_sets << routes
575
575
  end
576
576
  end
@@ -6,9 +6,9 @@ module Rails
6
6
 
7
7
  module VERSION
8
8
  MAJOR = 4
9
- MINOR = 1
10
- TINY = 16
11
- PRE = nil
9
+ MINOR = 2
10
+ TINY = 0
11
+ PRE = "beta1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -156,10 +156,20 @@ module Rails
156
156
  args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
157
157
  klass.start(args, config)
158
158
  else
159
- puts "Could not find generator #{namespace}."
159
+ options = sorted_groups.map(&:last).flatten
160
+ suggestions = options.sort_by {|suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
161
+ msg = "Could not find generator '#{namespace}'. "
162
+ msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.join(" or ") }\n"
163
+ msg << "Run `rails generate --help` for more options."
164
+ puts msg
160
165
  end
161
166
  end
162
167
 
168
+ # Returns an array of generator namespaces that are hidden.
169
+ # Generator namespaces may be hidden for a variety of reasons.
170
+ # Some are aliased such as "rails:migration" and can be
171
+ # invoked with the shorter "migration", others are private to other generators
172
+ # such as "css:scaffold".
163
173
  def self.hidden_namespaces
164
174
  @hidden_namespaces ||= begin
165
175
  orm = options[:rails][:orm]
@@ -199,17 +209,6 @@ module Rails
199
209
 
200
210
  # Show help message with available generators.
201
211
  def self.help(command = 'generate')
202
- lookup!
203
-
204
- namespaces = subclasses.map{ |k| k.namespace }
205
- namespaces.sort!
206
-
207
- groups = Hash.new { |h,k| h[k] = [] }
208
- namespaces.each do |namespace|
209
- base = namespace.split(':').first
210
- groups[base] << namespace
211
- end
212
-
213
212
  puts "Usage: rails #{command} GENERATOR [args] [options]"
214
213
  puts
215
214
  puts "General options:"
@@ -222,20 +221,74 @@ module Rails
222
221
  puts "Please choose a generator below."
223
222
  puts
224
223
 
225
- # Print Rails defaults first.
224
+ print_generators
225
+ end
226
+
227
+ def self.public_namespaces
228
+ lookup!
229
+ subclasses.map { |k| k.namespace }
230
+ end
231
+
232
+ def self.print_generators
233
+ sorted_groups.each { |b, n| print_list(b, n) }
234
+ end
235
+
236
+ def self.sorted_groups
237
+ namespaces = public_namespaces
238
+ namespaces.sort!
239
+ groups = Hash.new { |h,k| h[k] = [] }
240
+ namespaces.each do |namespace|
241
+ base = namespace.split(':').first
242
+ groups[base] << namespace
243
+ end
226
244
  rails = groups.delete("rails")
227
245
  rails.map! { |n| n.sub(/^rails:/, '') }
228
246
  rails.delete("app")
229
247
  rails.delete("plugin")
230
- print_list("rails", rails)
231
248
 
232
249
  hidden_namespaces.each { |n| groups.delete(n.to_s) }
233
250
 
234
- groups.sort.each { |b, n| print_list(b, n) }
251
+ [["rails", rails]] + groups.sort.to_a
235
252
  end
236
253
 
237
254
  protected
238
255
 
256
+ # This code is based directly on the Text gem implementation
257
+ # Returns a value representing the "cost" of transforming str1 into str2
258
+ def self.levenshtein_distance str1, str2
259
+ s = str1
260
+ t = str2
261
+ n = s.length
262
+ m = t.length
263
+ max = n/2
264
+
265
+ return m if (0 == n)
266
+ return n if (0 == m)
267
+ return n if (n - m).abs > max
268
+
269
+ d = (0..m).to_a
270
+ x = nil
271
+
272
+ str1.each_char.each_with_index do |char1,i|
273
+ e = i+1
274
+
275
+ str2.each_char.each_with_index do |char2,j|
276
+ cost = (char1 == char2) ? 0 : 1
277
+ x = [
278
+ d[j+1] + 1, # insertion
279
+ e + 1, # deletion
280
+ d[j] + cost # substitution
281
+ ].min
282
+ d[j] = e
283
+ e = x
284
+ end
285
+
286
+ d[m] = x
287
+ end
288
+
289
+ return x
290
+ end
291
+
239
292
  # Prints a list of generators.
240
293
  def self.print_list(base, namespaces) #:nodoc:
241
294
  namespaces = namespaces.reject do |n|
@@ -7,6 +7,7 @@ module Rails
7
7
  def initialize(*) # :nodoc:
8
8
  super
9
9
  @in_group = nil
10
+ @after_bundle_callbacks = []
10
11
  end
11
12
 
12
13
  # Adds an entry into +Gemfile+ for the supplied gem.
@@ -20,9 +21,9 @@ module Rails
20
21
 
21
22
  # Set the message to be shown in logs. Uses the git repo if one is given,
22
23
  # otherwise use name (version).
23
- parts, message = [ name.inspect ], name
24
+ parts, message = [ quote(name) ], name
24
25
  if version ||= options.delete(:version)
25
- parts << version.inspect
26
+ parts << quote(version)
26
27
  message << " (#{version})"
27
28
  end
28
29
  message = options[:git] if options[:git]
@@ -30,7 +31,7 @@ module Rails
30
31
  log :gemfile, message
31
32
 
32
33
  options.each do |option, value|
33
- parts << "#{option}: #{value.inspect}"
34
+ parts << "#{option}: #{quote(value)}"
34
35
  end
35
36
 
36
37
  in_root do
@@ -68,7 +69,7 @@ module Rails
68
69
  log :source, source
69
70
 
70
71
  in_root do
71
- prepend_file "Gemfile", "source #{source.inspect}\n", verbose: false
72
+ prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false
72
73
  end
73
74
  end
74
75
 
@@ -188,7 +189,7 @@ module Rails
188
189
  # generate(:authenticated, "user session")
189
190
  def generate(what, *args)
190
191
  log :generate, what
191
- argument = args.map {|arg| arg.to_s }.flatten.join(" ")
192
+ argument = args.flat_map {|arg| arg.to_s }.join(" ")
192
193
 
193
194
  in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) }
194
195
  end
@@ -218,10 +219,10 @@ module Rails
218
219
  # route "root 'welcome#index'"
219
220
  def route(routing_code)
220
221
  log :route, routing_code
221
- sentinel = /\.routes\.draw do\s*\n/m
222
+ sentinel = /\.routes\.draw do\s*$/
222
223
 
223
224
  in_root do
224
- inject_into_file 'config/routes.rb', " #{routing_code}\n", { after: sentinel, verbose: false, force: true }
225
+ inject_into_file 'config/routes.rb', "\n #{routing_code}", { after: sentinel, verbose: false }
225
226
  end
226
227
  end
227
228
 
@@ -232,6 +233,16 @@ module Rails
232
233
  log File.read(find_in_source_paths(path))
233
234
  end
234
235
 
236
+ # Registers a callback to be executed after bundle and spring binstubs
237
+ # have run.
238
+ #
239
+ # after_bundle do
240
+ # git add: '.'
241
+ # end
242
+ def after_bundle(&block)
243
+ @after_bundle_callbacks << block
244
+ end
245
+
235
246
  protected
236
247
 
237
248
  # Define log for backwards compatibility. If just one argument is sent,
@@ -255,6 +266,15 @@ module Rails
255
266
  end
256
267
  end
257
268
 
269
+ # Surround string with single quotes if there is no quotes.
270
+ # Otherwise fall back to double quotes
271
+ def quote(str)
272
+ if str.include?("'")
273
+ str.inspect
274
+ else
275
+ "'#{str}'"
276
+ end
277
+ end
258
278
  end
259
279
  end
260
280
  end
@@ -55,7 +55,8 @@ module Rails
55
55
  else
56
56
  say_status :conflict, :red
57
57
  raise Error, "Another migration is already named #{migration_file_name}: " +
58
- "#{existing_migration}. Use --force to replace this migration file."
58
+ "#{existing_migration}. Use --force to replace this migration " +
59
+ "or --skip to ignore conflicted file."
59
60
  end
60
61
  end
61
62
 
@@ -41,6 +41,9 @@ module Rails
41
41
  class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
42
42
  desc: 'Skip Active Record files'
43
43
 
44
+ class_option :skip_gems, type: :array, default: [],
45
+ desc: 'Skip the provided gems files'
46
+
44
47
  class_option :skip_action_view, type: :boolean, aliases: '-V', default: false,
45
48
  desc: 'Skip Action View files'
46
49
 
@@ -79,8 +82,7 @@ module Rails
79
82
  end
80
83
 
81
84
  def initialize(*args)
82
- @original_wd = Dir.pwd
83
- @gem_filter = lambda { |gem| true }
85
+ @gem_filter = lambda { |gem| !options[:skip_gems].include?(gem.name) }
84
86
  @extra_entries = []
85
87
  super
86
88
  convert_database_option_for_jruby
@@ -105,15 +107,14 @@ module Rails
105
107
  end
106
108
 
107
109
  def gemfile_entries
108
- [ rails_gemfile_entry,
109
- database_gemfile_entry,
110
- assets_gemfile_entry,
111
- javascript_gemfile_entry,
112
- jbuilder_gemfile_entry,
113
- sdoc_gemfile_entry,
114
- spring_gemfile_entry,
115
- mime_type_gemfile_entry,
116
- @extra_entries].flatten.find_all(&@gem_filter)
110
+ [rails_gemfile_entry,
111
+ database_gemfile_entry,
112
+ assets_gemfile_entry,
113
+ javascript_gemfile_entry,
114
+ jbuilder_gemfile_entry,
115
+ sdoc_gemfile_entry,
116
+ psych_gemfile_entry,
117
+ @extra_entries].flatten.find_all(&@gem_filter)
117
118
  end
118
119
 
119
120
  def add_gem_entry_filter
@@ -161,8 +162,7 @@ module Rails
161
162
 
162
163
  def database_gemfile_entry
163
164
  return [] if options[:skip_active_record]
164
- gem_name, gem_version = gem_for_database
165
- GemfileEntry.version gem_name, gem_version,
165
+ GemfileEntry.version gem_for_database, nil,
166
166
  "Use #{options[:database]} as the database for Active Record"
167
167
  end
168
168
 
@@ -174,17 +174,17 @@ module Rails
174
174
  options[value] ? '# ' : ''
175
175
  end
176
176
 
177
+ def sqlite3?
178
+ !options[:skip_active_record] && options[:database] == 'sqlite3'
179
+ end
180
+
177
181
  class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
178
182
  def initialize(name, version, comment, options = {}, commented_out = false)
179
183
  super
180
184
  end
181
185
 
182
- def self.github(name, github, branch = nil, comment = nil)
183
- if branch
184
- new(name, nil, comment, github: github, branch: branch)
185
- else
186
- new(name, nil, comment, github: github)
187
- end
186
+ def self.github(name, github, comment = nil)
187
+ new(name, nil, comment, github: github)
188
188
  end
189
189
 
190
190
  def self.version(name, version, comment = nil)
@@ -194,28 +194,13 @@ module Rails
194
194
  def self.path(name, path, comment = nil)
195
195
  new(name, nil, comment, path: path)
196
196
  end
197
-
198
- def padding(max_width)
199
- ' ' * (max_width - name.length + 2)
200
- end
201
-
202
- def version
203
- version = super
204
-
205
- if version.is_a?(Array)
206
- version.join("', '")
207
- else
208
- version
209
- end
210
- end
211
197
  end
212
198
 
213
199
  def rails_gemfile_entry
214
200
  if options.dev?
215
- [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH),
216
- GemfileEntry.github('arel', 'rails/arel', '5-0-stable')]
201
+ [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH)]
217
202
  elsif options.edge?
218
- [GemfileEntry.github('rails', 'rails/rails', '4-1-stable')]
203
+ [GemfileEntry.github('rails', 'rails/rails')]
219
204
  else
220
205
  [GemfileEntry.version('rails',
221
206
  Rails::VERSION::STRING,
@@ -226,16 +211,16 @@ module Rails
226
211
  def gem_for_database
227
212
  # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
228
213
  case options[:database]
229
- when "oracle" then ["ruby-oci8", nil]
230
- when "postgresql" then ["pg", ["~> 0.11"]]
231
- when "frontbase" then ["ruby-frontbase", nil]
232
- when "mysql" then ["mysql2", ["~> 0.3.13"]]
233
- when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
234
- when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
235
- when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
236
- when "jdbcpostgresql" then ["activerecord-jdbcpostgresql-adapter", nil]
237
- when "jdbc" then ["activerecord-jdbc-adapter", nil]
238
- else [options[:database], nil]
214
+ when "oracle" then "ruby-oci8"
215
+ when "postgresql" then "pg"
216
+ when "frontbase" then "ruby-frontbase"
217
+ when "mysql" then "mysql2"
218
+ when "sqlserver" then "activerecord-sqlserver-adapter"
219
+ when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
220
+ when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
221
+ when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
222
+ when "jdbc" then "activerecord-jdbc-adapter"
223
+ else options[:database]
239
224
  end
240
225
  end
241
226
 
@@ -253,14 +238,23 @@ module Rails
253
238
  def assets_gemfile_entry
254
239
  return [] if options[:skip_sprockets]
255
240
 
256
- [
257
- GemfileEntry.version('sass-rails',
258
- '~> 4.0.3',
259
- 'Use SCSS for stylesheets'),
260
- GemfileEntry.version('uglifier',
261
- '>= 1.3.0',
262
- 'Use Uglifier as compressor for JavaScript assets')
263
- ]
241
+ gems = []
242
+ if options.dev? || options.edge?
243
+ gems << GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails',
244
+ 'Use edge version of sprockets-rails')
245
+ gems << GemfileEntry.github('sass-rails', 'rails/sass-rails',
246
+ 'Use SCSS for stylesheets')
247
+ else
248
+ gems << GemfileEntry.version('sass-rails',
249
+ '~> 5.0.0.beta1',
250
+ 'Use SCSS for stylesheets')
251
+ end
252
+
253
+ gems << GemfileEntry.version('uglifier',
254
+ '>= 1.3.0',
255
+ 'Use Uglifier as compressor for JavaScript assets')
256
+
257
+ gems
264
258
  end
265
259
 
266
260
  def jbuilder_gemfile_entry
@@ -276,7 +270,7 @@ module Rails
276
270
  def coffee_gemfile_entry
277
271
  comment = 'Use CoffeeScript for .js.coffee assets and views'
278
272
  if options.dev? || options.edge?
279
- GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, comment
273
+ GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', comment
280
274
  else
281
275
  GemfileEntry.version 'coffee-rails', '~> 4.0.0', comment
282
276
  end
@@ -297,7 +291,7 @@ module Rails
297
291
  end
298
292
 
299
293
  def javascript_runtime_gemfile_entry
300
- comment = 'See https://github.com/rails/execjs#readme for more supported runtimes'
294
+ comment = 'See https://github.com/sstephenson/execjs#readme for more supported runtimes'
301
295
  if defined?(JRUBY_VERSION)
302
296
  GemfileEntry.version 'therubyrhino', nil, comment
303
297
  else
@@ -305,16 +299,12 @@ module Rails
305
299
  end
306
300
  end
307
301
 
308
- def spring_gemfile_entry
309
- return [] unless spring_install?
310
- comment = 'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring'
311
- GemfileEntry.new('spring', nil, comment, group: :development)
312
- end
313
-
314
- def mime_type_gemfile_entry
315
- return [] unless RUBY_VERSION < '2'
302
+ def psych_gemfile_entry
303
+ return [] unless defined?(Rubinius)
316
304
 
317
- GemfileEntry.new('mime-types', '< 3', nil, require: false)
305
+ comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \
306
+ 'data can be read safely from different rubies (see http://git.io/uuLVag)'
307
+ GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
318
308
  end
319
309
 
320
310
  def bundle_command(command)