railties 5.0.0.beta2 → 5.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/RDOC_MAIN.rdoc +1 -1
  4. data/lib/rails/application.rb +1 -1
  5. data/lib/rails/application/finisher.rb +4 -4
  6. data/lib/rails/code_statistics.rb +21 -9
  7. data/lib/rails/commands.rb +0 -1
  8. data/lib/rails/commands/runner.rb +2 -2
  9. data/lib/rails/engine/configuration.rb +1 -0
  10. data/lib/rails/gem_version.rb +1 -1
  11. data/lib/rails/generators.rb +5 -1
  12. data/lib/rails/generators/actions.rb +2 -1
  13. data/lib/rails/generators/app_base.rb +17 -11
  14. data/lib/rails/generators/rails/app/app_generator.rb +7 -2
  15. data/lib/rails/generators/rails/app/templates/Gemfile +6 -0
  16. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -2
  17. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +1 -1
  18. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -1
  19. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +1 -1
  20. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +2 -2
  21. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +11 -1
  22. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +5 -0
  23. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -3
  24. data/lib/rails/generators/rails/app/templates/config/puma.rb +3 -0
  25. data/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
  26. data/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
  27. data/lib/rails/generators/rails/plugin/plugin_generator.rb +1 -4
  28. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -0
  29. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
  30. data/lib/rails/rack/logger.rb +0 -4
  31. data/lib/rails/railtie.rb +7 -4
  32. data/lib/rails/tasks.rb +1 -0
  33. data/lib/rails/tasks/dev.rake +14 -0
  34. data/lib/rails/tasks/framework.rake +1 -1
  35. data/lib/rails/tasks/routes.rake +6 -6
  36. data/lib/rails/test_unit/line_filtering.rb +12 -4
  37. data/lib/rails/test_unit/minitest_plugin.rb +5 -2
  38. data/lib/rails/test_unit/reporter.rb +4 -16
  39. metadata +12 -11
  40. data/lib/rails/commands/dev_cache.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83e9a8d14879b7cd28fc9fd57f76b5e2f280c609
4
- data.tar.gz: ac950ac53f6b98b0797920ed8d93fd96e875b74e
3
+ metadata.gz: b4fea73157abd641e818793971d61f9ba1c982cb
4
+ data.tar.gz: 9356d423706a1cb8c934ca166661c0bd9a018f5d
5
5
  SHA512:
6
- metadata.gz: 99c2414aba749e7dd0bb5fb7fb473387ded69a813dae0a40e4d4b2925318575bfed83ae59b46b28234590a7606aa5e82ef1237d97b9435da4504be22c9712e53
7
- data.tar.gz: 0b1c83b2b97aa12caf646777cc37313eb25f46111b9359b4b648507698840678e1f2a12af058fd6ea288a8c35e267adaa5718e6529922340d581d7766bc67b40
6
+ metadata.gz: 93728268e600949966dcb493db8738e8b601d973d09bff191808f473e5015862a8a533268e0354136e42b27e4ed73cfe70e8cbe6e34556ff39eeb292acddaea7
7
+ data.tar.gz: 941025bde174d4fc8645f143148dc26addbd7eb60df50d31c500fa9258105aa5d363b4270b7223ac3f90a280e35d4aa8e5c58a6ebab2c46716751e2b365c646b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## Rails 5.0.0.beta3 (February 24, 2016) ##
2
+
3
+ * Alias `rake` with `rails_command` in the Rails Application Templates API
4
+ following Rails 5 convention of preferring "rails" to "rake" to run tasks.
5
+
6
+ *claudiob*
7
+
8
+ * Generate applications with an option to log to STDOUT in production
9
+ using the environment variable `RAILS_LOG_TO_STDOUT`.
10
+
11
+ *Richard Schneeman*
12
+
13
+ * Change fail fast of `bin/rails test` interrupts run on error.
14
+
15
+ *Yuji Yaginuma*
16
+
17
+ * The application generator supports `--skip-listen` to opt-out of features
18
+ that depend on the listen gem. As of this writing they are the evented file
19
+ system monitor and the async plugin for spring.
20
+
21
+ * The Gemfiles of new applications include spring-watcher-listen on Linux and
22
+ Mac OS X (unless --skip-spring).
23
+
24
+ *Xavier Noria*
25
+
26
+ * New applications are generated with the evented file system monitor enabled
27
+ on Linux and Mac OS X.
28
+
29
+ *Xavier Noria*
30
+
31
+ * Add dummy files for apple-touch-icon.png and apple-touch-icon.png. GH#23427
32
+
33
+ *Alexey Zabelin*
34
+
1
35
  ## Rails 5.0.0.beta2 (February 01, 2016) ##
2
36
 
3
37
  * Add `after_bundle` callbacks in Rails plugin templates. Useful for allowing
data/RDOC_MAIN.rdoc CHANGED
@@ -51,7 +51,7 @@ can read more about Action Pack in its {README}[link:files/actionpack/README_rdo
51
51
 
52
52
  4. Go to http://localhost:3000 and you'll see:
53
53
 
54
- "Welcome aboard: You're riding Ruby on Rails!"
54
+ "Yay! Youre on Rails!"
55
55
 
56
56
  5. Follow the guidelines to start developing your application. You may find the following resources handy:
57
57
 
@@ -214,7 +214,7 @@ module Rails
214
214
  # url: http://localhost:3001
215
215
  # namespace: my_app_development
216
216
  #
217
- # # config/production.rb
217
+ # # config/environments/production.rb
218
218
  # Rails.application.configure do
219
219
  # config.middleware.use ExceptionNotifier, config_for(:exception_notification)
220
220
  # end
@@ -22,10 +22,10 @@ module Rails
22
22
  initializer :add_builtin_route do |app|
23
23
  if Rails.env.development?
24
24
  app.routes.append do
25
- get '/rails/info/properties' => "rails/info#properties"
26
- get '/rails/info/routes' => "rails/info#routes"
27
- get '/rails/info' => "rails/info#index"
28
- get '/' => "rails/welcome#index"
25
+ get '/rails/info/properties' => "rails/info#properties", internal: true
26
+ get '/rails/info/routes' => "rails/info#routes", internal: true
27
+ get '/rails/info' => "rails/info#index", internal: true
28
+ get '/' => "rails/welcome#index", internal: true
29
29
  end
30
30
  end
31
31
  end
@@ -9,6 +9,8 @@ class CodeStatistics #:nodoc:
9
9
  'Job tests',
10
10
  'Integration tests']
11
11
 
12
+ HEADERS = {lines: ' Lines', code_lines: ' LOC', classes: 'Classes', methods: 'Methods'}
13
+
12
14
  def initialize(*pairs)
13
15
  @pairs = pairs
14
16
  @statistics = calculate_statistics
@@ -67,27 +69,37 @@ class CodeStatistics #:nodoc:
67
69
  test_loc
68
70
  end
69
71
 
72
+ def width_for(label)
73
+ [@statistics.values.sum {|s| s.send(label) }.to_s.size, HEADERS[label].length].max
74
+ end
75
+
70
76
  def print_header
71
77
  print_splitter
72
- puts "| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |"
78
+ print '| Name '
79
+ HEADERS.each do |k, v|
80
+ print " | #{v.rjust(width_for(k))}"
81
+ end
82
+ puts ' | M/C | LOC/M |'
73
83
  print_splitter
74
84
  end
75
85
 
76
86
  def print_splitter
77
- puts "+----------------------+--------+--------+---------+---------+-----+-------+"
87
+ print '+----------------------'
88
+ HEADERS.each_key do |k|
89
+ print "+#{'-' * (width_for(k) + 2)}"
90
+ end
91
+ puts '+-----+-------+'
78
92
  end
79
93
 
80
94
  def print_line(name, statistics)
81
95
  m_over_c = (statistics.methods / statistics.classes) rescue m_over_c = 0
82
96
  loc_over_m = (statistics.code_lines / statistics.methods) - 2 rescue loc_over_m = 0
83
97
 
84
- puts "| #{name.ljust(20)} " \
85
- "| #{statistics.lines.to_s.rjust(6)} " \
86
- "| #{statistics.code_lines.to_s.rjust(6)} " \
87
- "| #{statistics.classes.to_s.rjust(7)} " \
88
- "| #{statistics.methods.to_s.rjust(7)} " \
89
- "| #{m_over_c.to_s.rjust(3)} " \
90
- "| #{loc_over_m.to_s.rjust(5)} |"
98
+ print "| #{name.ljust(20)} "
99
+ HEADERS.each_key do |k|
100
+ print "| #{statistics.send(k).to_s.rjust(width_for(k))} "
101
+ end
102
+ puts "| #{m_over_c.to_s.rjust(3)} | #{loc_over_m.to_s.rjust(5)} |"
91
103
  end
92
104
 
93
105
  def print_code_test_stats
@@ -14,6 +14,5 @@ command = ARGV.shift
14
14
  command = aliases[command] || command
15
15
 
16
16
  require 'rails/command'
17
- require 'rails/commands/dev_cache'
18
17
 
19
18
  Rails::Command.run(command, ARGV)
@@ -59,8 +59,8 @@ elsif File.exist?(code_or_file)
59
59
  Kernel.load code_or_file
60
60
  else
61
61
  begin
62
- eval(code_or_file, binding, __FILE__, __LINE__)
63
- rescue SyntaxError,NameError => err
62
+ eval(code_or_file, binding, __FILE__, __LINE__)
63
+ rescue SyntaxError, NameError
64
64
  $stderr.puts "Please specify a valid ruby command or the path of a script to run."
65
65
  $stderr.puts "Run '#{$0} -h' for help."
66
66
  exit 1
@@ -39,6 +39,7 @@ module Rails
39
39
  paths.add "app", eager_load: true, glob: "{*,*/concerns}"
40
40
  paths.add "app/assets", glob: "*"
41
41
  paths.add "app/controllers", eager_load: true
42
+ paths.add "app/channels", eager_load: true, glob: "**/*_channel.rb"
42
43
  paths.add "app/helpers", eager_load: true
43
44
  paths.add "app/models", eager_load: true
44
45
  paths.add "app/mailers", eager_load: true
@@ -8,7 +8,7 @@ module Rails
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta2"
11
+ PRE = "beta3"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -105,7 +105,7 @@ module Rails
105
105
 
106
106
  # Configure generators for API only applications. It basically hides
107
107
  # everything that is usually browser related, such as assets and session
108
- # migration generators, and completely disable views, helpers and assets
108
+ # migration generators, and completely disable helpers and assets
109
109
  # so generators such as scaffold won't create them.
110
110
  def self.api_only!
111
111
  hide_namespaces "assets", "helper", "css", "js"
@@ -116,6 +116,10 @@ module Rails
116
116
  helper: false,
117
117
  template_engine: nil
118
118
  )
119
+
120
+ if ARGV.first == 'mailer'
121
+ options[:rails].merge!(template_engine: :erb)
122
+ end
119
123
  end
120
124
 
121
125
  # Remove the color from output.
@@ -216,8 +216,9 @@ module Rails
216
216
  log :rake, command
217
217
  env = options[:env] || ENV["RAILS_ENV"] || 'development'
218
218
  sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
219
- in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", verbose: false) }
219
+ in_root { run("#{sudo}#{extify(:rails)} #{command} RAILS_ENV=#{env}", verbose: false) }
220
220
  end
221
+ alias :rails_command :rake
221
222
 
222
223
  # Just run the capify command in root
223
224
  #
@@ -63,6 +63,9 @@ module Rails
63
63
  class_option :skip_spring, type: :boolean, default: false,
64
64
  desc: "Don't install Spring application preloader"
65
65
 
66
+ class_option :skip_listen, type: :boolean, default: false,
67
+ desc: "Don't generate configuration that depends on the listen gem"
68
+
66
69
  class_option :skip_javascript, type: :boolean, aliases: '-J', default: false,
67
70
  desc: 'Skip JavaScript files'
68
71
 
@@ -308,16 +311,11 @@ module Rails
308
311
  end
309
312
 
310
313
  def coffee_gemfile_entry
311
- comment = 'Use CoffeeScript for .coffee assets and views'
312
- if options.dev? || options.edge?
313
- GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, comment
314
- else
315
- GemfileEntry.version 'coffee-rails', '~> 4.1.0', comment
316
- end
314
+ GemfileEntry.version 'coffee-rails', '~> 4.1.0', 'Use CoffeeScript for .coffee assets and views'
317
315
  end
318
316
 
319
317
  def javascript_gemfile_entry
320
- if options[:skip_javascript]
318
+ if options[:skip_javascript] || options[:skip_sprockets]
321
319
  []
322
320
  else
323
321
  gems = [coffee_gemfile_entry, javascript_runtime_gemfile_entry]
@@ -325,8 +323,8 @@ module Rails
325
323
  "Use #{options[:javascript]} as the JavaScript library")
326
324
 
327
325
  unless options[:skip_turbolinks]
328
- gems << GemfileEntry.version("turbolinks", nil,
329
- "Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks")
326
+ gems << GemfileEntry.version("turbolinks", "~> 5.x",
327
+ "Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks")
330
328
  end
331
329
 
332
330
  gems
@@ -352,9 +350,9 @@ module Rails
352
350
 
353
351
  def cable_gemfile_entry
354
352
  return [] if options[:skip_action_cable]
355
- comment = 'Action Cable dependencies for the Redis adapter'
353
+ comment = 'Use Redis adapter to run Action Cable in production'
356
354
  gems = []
357
- gems << GemfileEntry.new("redis", '~> 3.0', comment)
355
+ gems << GemfileEntry.new("redis", '~> 3.0', comment, {}, true)
358
356
  gems
359
357
  end
360
358
 
@@ -390,6 +388,14 @@ module Rails
390
388
  !options[:skip_spring] && !options.dev? && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")
391
389
  end
392
390
 
391
+ def depend_on_listen?
392
+ !options[:skip_listen] && os_supports_listen_out_of_the_box?
393
+ end
394
+
395
+ def os_supports_listen_out_of_the_box?
396
+ RbConfig::CONFIG['host_os'] =~ /darwin|linux/
397
+ end
398
+
393
399
  def run_bundle
394
400
  bundle_command('install') if bundle_install?
395
401
  end
@@ -91,6 +91,7 @@ module Rails
91
91
  cookie_serializer_config_exist = File.exist?('config/initializers/cookies_serializer.rb')
92
92
  callback_terminator_config_exist = File.exist?('config/initializers/callback_terminator.rb')
93
93
  active_record_belongs_to_required_by_default_config_exist = File.exist?('config/initializers/active_record_belongs_to_required_by_default.rb')
94
+ action_cable_config_exist = File.exist?('config/cable.yml')
94
95
 
95
96
  config
96
97
 
@@ -105,6 +106,10 @@ module Rails
105
106
  unless active_record_belongs_to_required_by_default_config_exist
106
107
  remove_file 'config/initializers/active_record_belongs_to_required_by_default.rb'
107
108
  end
109
+
110
+ unless action_cable_config_exist
111
+ template 'config/cable.yml'
112
+ end
108
113
  end
109
114
 
110
115
  def database_yml
@@ -276,9 +281,9 @@ module Rails
276
281
  end
277
282
  end
278
283
 
279
- def delete_app_views_if_api_option
284
+ def delete_application_layout_file_if_api_option
280
285
  if options[:api]
281
- remove_dir 'app/views'
286
+ remove_file 'app/views/layouts/application.html.erb'
282
287
  end
283
288
  end
284
289
 
@@ -38,9 +38,15 @@ group :development do
38
38
  gem 'web-console', '~> 3.0'
39
39
  <%- end -%>
40
40
  <%- end -%>
41
+ <% if depend_on_listen? -%>
42
+ gem 'listen', '~> 3.0.5'
43
+ <% end -%>
41
44
  <% if spring_install? -%>
42
45
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
43
46
  gem 'spring'
47
+ <% if depend_on_listen? -%>
48
+ gem 'spring-watcher-listen', '~> 2.0.0'
49
+ <% end -%>
44
50
  <% end -%>
45
51
  end
46
52
  <% end -%>
@@ -11,8 +11,8 @@
11
11
  <%%= stylesheet_link_tag 'application', media: 'all' %>
12
12
  <%- else -%>
13
13
  <%- if gemfile_entries.any? { |m| m.name == 'turbolinks' } -%>
14
- <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
15
- <%%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
14
+ <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %>
15
+ <%%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %>
16
16
  <%- else -%>
17
17
  <%%= stylesheet_link_tag 'application', media: 'all' %>
18
18
  <%%= javascript_include_tag 'application' %>
@@ -1,4 +1,4 @@
1
- # MySQL. Versions 4.1 and 5.0 are recommended.
1
+ # MySQL. Versions 5.0 and up are supported.
2
2
  #
3
3
  # Install the MySQL driver:
4
4
  # gem install activerecord-jdbcmysql-adapter
@@ -1,4 +1,4 @@
1
- # PostgreSQL. Versions 8.2 and up are supported.
1
+ # PostgreSQL. Versions 9.1 and up are supported.
2
2
  #
3
3
  # Configure Using Gemfile
4
4
  # gem 'activerecord-jdbcpostgresql-adapter'
@@ -1,4 +1,4 @@
1
- # MySQL. Versions 5.0+ are recommended.
1
+ # MySQL. Versions 5.0 and up are supported.
2
2
  #
3
3
  # Install the MySQL driver
4
4
  # gem install mysql2
@@ -1,4 +1,4 @@
1
- # PostgreSQL. Versions 8.2 and up are supported.
1
+ # PostgreSQL. Versions 9.1 and up are supported.
2
2
  #
3
3
  # Install the pg driver:
4
4
  # gem install pg
@@ -19,7 +19,7 @@ default: &default
19
19
  encoding: unicode
20
20
  # For details on connection pooling, see rails configuration guide
21
21
  # http://guides.rubyonrails.org/configuring.html#database-pooling
22
- pool: 5
22
+ pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23
23
 
24
24
  development:
25
25
  <<: *default
@@ -15,12 +15,22 @@ Rails.application.configure do
15
15
  # Enable/disable caching. By default caching is disabled.
16
16
  if Rails.root.join('tmp/caching-dev.txt').exist?
17
17
  config.action_controller.perform_caching = true
18
+
19
+ <%- unless options.skip_action_mailer? -%>
20
+ config.action_mailer.perform_caching = false
21
+ <%- end -%>
22
+
18
23
  config.cache_store = :memory_store
19
24
  config.public_file_server.headers = {
20
25
  'Cache-Control' => 'public, max-age=172800'
21
26
  }
22
27
  else
23
28
  config.action_controller.perform_caching = false
29
+
30
+ <%- unless options.skip_action_mailer? -%>
31
+ config.action_mailer.perform_caching = false
32
+ <%- end -%>
33
+
24
34
  config.cache_store = :null_store
25
35
  end
26
36
  <%- unless options.skip_action_mailer? -%>
@@ -58,5 +68,5 @@ Rails.application.configure do
58
68
 
59
69
  # Use an evented file watcher to asynchronously detect changes in source code,
60
70
  # routes, locales, etc. This feature depends on the listen gem.
61
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
71
+ <%= '# ' unless depend_on_listen? %>config.file_watcher = ActiveSupport::EventedFileUpdateChecker
62
72
  end
@@ -60,6 +60,10 @@ Rails.application.configure do
60
60
  # require 'syslog/logger'
61
61
  # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
62
62
 
63
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
64
+ config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
65
+ end
66
+
63
67
  # Use a different cache store in production.
64
68
  # config.cache_store = :mem_cache_store
65
69
 
@@ -67,6 +71,7 @@ Rails.application.configure do
67
71
  # config.active_job.queue_adapter = :resque
68
72
  # config.active_job.queue_name_prefix = "<%= app_name %>_#{Rails.env}"
69
73
  <%- unless options.skip_action_mailer? -%>
74
+ config.action_mailer.perform_caching = false
70
75
 
71
76
  # Ignore bad email addresses and do not raise email delivery errors.
72
77
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@@ -28,6 +28,7 @@ Rails.application.configure do
28
28
  # Disable request forgery protection in test environment.
29
29
  config.action_controller.allow_forgery_protection = false
30
30
  <%- unless options.skip_action_mailer? -%>
31
+ config.action_mailer.perform_caching = false
31
32
 
32
33
  # Tell Action Mailer not to deliver emails to the real world.
33
34
  # The :test delivery method accumulates sent emails in the
@@ -35,9 +36,6 @@ Rails.application.configure do
35
36
  config.action_mailer.delivery_method = :test
36
37
  <%- end -%>
37
38
 
38
- # Randomize the order test cases are executed.
39
- config.active_support.test_order = :random
40
-
41
39
  # Print deprecation notices to the stderr.
42
40
  config.active_support.deprecation = :stderr
43
41
 
@@ -42,3 +42,6 @@ environment ENV.fetch("RAILS_ENV") { "development" }
42
42
  # on_worker_boot do
43
43
  # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
44
  # end
45
+
46
+ # Allow puma to be restarted by `rails restart` command.
47
+ plugin :tmp_restart
@@ -90,6 +90,7 @@ task default: :test
90
90
  opts[:force] = force
91
91
  opts[:skip_bundle] = true
92
92
  opts[:api] = options.api?
93
+ opts[:skip_listen] = true
93
94
 
94
95
  invoke Rails::Generators::AppGenerator,
95
96
  [ File.expand_path(dummy_path, destination_root) ], opts
@@ -287,10 +288,6 @@ task default: :test
287
288
 
288
289
  protected
289
290
 
290
- def app_templates_dir
291
- "../../app/templates"
292
- end
293
-
294
291
  def create_dummy_app(path = nil)
295
292
  dummy_path(path) if path
296
293
 
@@ -1,5 +1,6 @@
1
1
  <%= wrap_in_modules <<-rb.strip_heredoc
2
2
  class ApplicationController < ActionController::#{api? ? "API" : "Base"}
3
+ #{ api? ? '# ' : '' }protect_from_forgery with: :exception
3
4
  end
4
5
  rb
5
6
  %>
@@ -6,7 +6,7 @@
6
6
  <%- if attribute.password_digest? -%>
7
7
  password_digest: <%%= BCrypt::Password.create('secret') %>
8
8
  <%- elsif attribute.reference? -%>
9
- <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default) %>
9
+ <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %>
10
10
  <%- else -%>
11
11
  <%= yaml_key_value(attribute.column_name, attribute.default) %>
12
12
  <%- end -%>
@@ -72,10 +72,6 @@ module Rails
72
72
  instrumenter.finish 'request.action_dispatch', request: request
73
73
  end
74
74
 
75
- def development?
76
- Rails.env.development?
77
- end
78
-
79
75
  def logger
80
76
  Rails.logger
81
77
  end
data/lib/rails/railtie.rb CHANGED
@@ -183,7 +183,7 @@ module Rails
183
183
  end
184
184
 
185
185
  protected
186
- def generate_railtie_name(string)
186
+ def generate_railtie_name(string) #:nodoc:
187
187
  ActiveSupport::Inflector.underscore(string).tr("/", "_")
188
188
  end
189
189
 
@@ -200,21 +200,24 @@ module Rails
200
200
 
201
201
  delegate :railtie_name, to: :class
202
202
 
203
- def initialize
203
+ def initialize #:nodoc:
204
204
  if self.class.abstract_railtie?
205
205
  raise "#{self.class.name} is abstract, you cannot instantiate it directly."
206
206
  end
207
207
  end
208
208
 
209
- def configure(&block)
209
+ def configure(&block) #:nodoc:
210
210
  instance_eval(&block)
211
211
  end
212
212
 
213
+ # This is used to create the <tt>config</tt> object on Railties, an instance of
214
+ # Railtie::Configuration, that is used by Railties and Application to store
215
+ # related configuration.
213
216
  def config
214
217
  @config ||= Railtie::Configuration.new
215
218
  end
216
219
 
217
- def railtie_namespace
220
+ def railtie_namespace #:nodoc:
218
221
  @railtie_namespace ||= self.class.parents.detect { |n| n.respond_to?(:railtie_namespace) }
219
222
  end
220
223
 
data/lib/rails/tasks.rb CHANGED
@@ -3,6 +3,7 @@ require 'rake'
3
3
  # Load Rails Rakefile extensions
4
4
  %w(
5
5
  annotations
6
+ dev
6
7
  framework
7
8
  initializers
8
9
  log
@@ -0,0 +1,14 @@
1
+ namespace :dev do
2
+ desc 'Toggle development mode caching on/off'
3
+ task :cache do
4
+ if File.exist? 'tmp/caching-dev.txt'
5
+ File.delete 'tmp/caching-dev.txt'
6
+ puts 'Development mode is no longer being cached.'
7
+ else
8
+ FileUtils.touch 'tmp/caching-dev.txt'
9
+ puts 'Development mode is now being cached.'
10
+ end
11
+
12
+ FileUtils.touch 'tmp/restart.txt'
13
+ end
14
+ end
@@ -45,7 +45,7 @@ namespace :rails do
45
45
  @app_generator ||= begin
46
46
  require 'rails/generators'
47
47
  require 'rails/generators/rails/app/app_generator'
48
- gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true },
48
+ gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true, api: !!Rails.application.config.api_only },
49
49
  destination_root: Rails.root
50
50
  File.exist?(Rails.root.join("config", "application.rb")) ?
51
51
  gen.send(:app_const) : gen.send(:valid_const?)
@@ -2,15 +2,15 @@ require 'active_support/deprecation'
2
2
  require 'active_support/core_ext/string/strip' # for strip_heredoc
3
3
  require 'optparse'
4
4
 
5
- desc 'Print out all defined routes in match order, with names. Target specific controller with --controller option - or its -c shorthand.'
5
+ desc 'Print out all defined routes in match order, with names. Target specific controller with -c option, or grep routes using -g option'
6
6
  task routes: :environment do
7
7
  all_routes = Rails.application.routes.routes
8
8
  require 'action_dispatch/routing/inspector'
9
9
  inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
10
10
  if ARGV.any?{ |argv| argv.start_with? 'CONTROLLER' }
11
11
  puts <<-eow.strip_heredoc
12
- Passing `CONTROLLER` to `bin/rake routes` is deprecated and will be removed in Rails 5.1.
13
- Please use `bin/rake routes -c controller_name` instead.
12
+ Passing `CONTROLLER` to `bin/rails routes` is deprecated and will be removed in Rails 5.1.
13
+ Please use `bin/rails routes -c controller_name` instead.
14
14
  eow
15
15
  end
16
16
 
@@ -18,12 +18,12 @@ task routes: :environment do
18
18
  routes_filter = { controller: ENV['CONTROLLER'] } if ENV['CONTROLLER']
19
19
 
20
20
  OptionParser.new do |opts|
21
- opts.banner = "Usage: rake routes [options]"
22
- opts.on("-c", "--controller [CONTROLLER]") do |controller|
21
+ opts.banner = "Usage: rails routes [options]"
22
+ opts.on("-c CONTROLLER") do |controller|
23
23
  routes_filter = { controller: controller }
24
24
  end
25
25
 
26
- opts.on("-g", "--grep [PATTERN]") do |pattern|
26
+ opts.on("-g PATTERN") do |pattern|
27
27
  routes_filter = pattern
28
28
  end
29
29
 
@@ -13,9 +13,12 @@ module Rails
13
13
  end
14
14
 
15
15
  class CompositeFilter # :nodoc:
16
+ attr_reader :named_filter
17
+
16
18
  def initialize(runnable, filter, patterns)
17
19
  @runnable = runnable
18
- @filters = [ derive_regexp(filter), *derive_line_filters(patterns) ].compact
20
+ @named_filter = derive_named_filter(filter)
21
+ @filters = [ @named_filter, *derive_line_filters(patterns) ].compact
19
22
  end
20
23
 
21
24
  # Minitest uses === to find matching filters.
@@ -24,9 +27,14 @@ module Rails
24
27
  end
25
28
 
26
29
  private
27
- def derive_regexp(filter)
28
- # Regexp filtering copied from Minitest.
29
- filter =~ %r%/(.*)/% ? Regexp.new($1) : filter
30
+ def derive_named_filter(filter)
31
+ if filter.respond_to?(:named_filter)
32
+ filter.named_filter
33
+ elsif filter =~ %r%/(.*)/% # Regexp filtering copied from Minitest.
34
+ Regexp.new $1
35
+ elsif filter.is_a?(String)
36
+ filter
37
+ end
30
38
  end
31
39
 
32
40
  def derive_line_filters(patterns)
@@ -1,6 +1,7 @@
1
1
  require "active_support/core_ext/module/attribute_accessors"
2
2
  require "rails/test_unit/reporter"
3
3
  require "rails/test_unit/test_requirer"
4
+ require 'shellwords'
4
5
 
5
6
  module Minitest
6
7
  class SuppressedSummaryReporter < SummaryReporter
@@ -42,7 +43,7 @@ module Minitest
42
43
  end
43
44
 
44
45
  opts.on("-f", "--fail-fast",
45
- "Abort test run on first failure") do
46
+ "Abort test run on first failure or error") do
46
47
  options[:fail_fast] = true
47
48
  end
48
49
 
@@ -60,11 +61,13 @@ module Minitest
60
61
  # as the patterns would also contain the other Rake tasks.
61
62
  def self.rake_run(patterns) # :nodoc:
62
63
  @rake_patterns = patterns
63
- passed = run
64
+ passed = run(Shellwords.split(ENV['TESTOPTS'] || ''))
64
65
  exit passed unless passed
65
66
  passed
66
67
  end
67
68
 
69
+ # Owes great inspiration to test runner trailblazers like RSpec,
70
+ # minitest-reporters, maxitest and others.
68
71
  def self.plugin_rails_init(options)
69
72
  self.run_with_rails_extension = true
70
73
 
@@ -18,13 +18,13 @@ module Rails
18
18
  if output_inline? && result.failure && (!result.skipped? || options[:verbose])
19
19
  io.puts
20
20
  io.puts
21
- io.puts format_failures(result).map { |line| color_output(line, by: result) }
21
+ io.puts color_output(result, by: result)
22
22
  io.puts
23
23
  io.puts format_rerun_snippet(result)
24
24
  io.puts
25
25
  end
26
26
 
27
- if fail_fast? && result.failure && !result.error? && !result.skipped?
27
+ if fail_fast? && result.failure && !result.skipped?
28
28
  raise Interrupt
29
29
  end
30
30
  end
@@ -66,21 +66,9 @@ module Rails
66
66
  "%s#%s = %.2f s = %s" % [result.class, result.name, result.time, result.result_code]
67
67
  end
68
68
 
69
- def format_failures(result)
70
- result.failures.map do |failure|
71
- "#{failure.result_label}:\n#{result.class}##{result.name}:\n#{failure.message}\n"
72
- end
73
- end
74
-
75
69
  def format_rerun_snippet(result)
76
- # Try to extract path to assertion from backtrace.
77
- if result.location =~ /\[(.*)\]\z/
78
- assertion_path = $1
79
- else
80
- assertion_path = result.method(result.name).source_location.join(':')
81
- end
82
-
83
- "#{self.executable} #{relative_path_for(assertion_path)}"
70
+ location, line = result.method(result.name).source_location
71
+ "#{self.executable} #{relative_path_for(location)}:#{line}"
84
72
  end
85
73
 
86
74
  def app_root
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta2
4
+ version: 5.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta2
19
+ version: 5.0.0.beta3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0.beta2
26
+ version: 5.0.0.beta3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 5.0.0.beta2
33
+ version: 5.0.0.beta3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 5.0.0.beta2
40
+ version: 5.0.0.beta3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.0.0.beta2
95
+ version: 5.0.0.beta3
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.0.0.beta2
102
+ version: 5.0.0.beta3
103
103
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
104
104
  email: david@loudthinking.com
105
105
  executables:
@@ -135,7 +135,6 @@ files:
135
135
  - lib/rails/commands/console_helper.rb
136
136
  - lib/rails/commands/dbconsole.rb
137
137
  - lib/rails/commands/destroy.rb
138
- - lib/rails/commands/dev_cache.rb
139
138
  - lib/rails/commands/generate.rb
140
139
  - lib/rails/commands/plugin.rb
141
140
  - lib/rails/commands/rake_proxy.rb
@@ -244,6 +243,8 @@ files:
244
243
  - lib/rails/generators/rails/app/templates/public/404.html
245
244
  - lib/rails/generators/rails/app/templates/public/422.html
246
245
  - lib/rails/generators/rails/app/templates/public/500.html
246
+ - lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png
247
+ - lib/rails/generators/rails/app/templates/public/apple-touch-icon.png
247
248
  - lib/rails/generators/rails/app/templates/public/favicon.ico
248
249
  - lib/rails/generators/rails/app/templates/public/robots.txt
249
250
  - lib/rails/generators/rails/app/templates/test/test_helper.rb
@@ -354,6 +355,7 @@ files:
354
355
  - lib/rails/source_annotation_extractor.rb
355
356
  - lib/rails/tasks.rb
356
357
  - lib/rails/tasks/annotations.rake
358
+ - lib/rails/tasks/dev.rake
357
359
  - lib/rails/tasks/engine.rake
358
360
  - lib/rails/tasks/framework.rake
359
361
  - lib/rails/tasks/initializers.rake
@@ -402,9 +404,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
404
  version: 1.3.1
403
405
  requirements: []
404
406
  rubyforge_project:
405
- rubygems_version: 2.5.2
407
+ rubygems_version: 2.5.1
406
408
  signing_key:
407
409
  specification_version: 4
408
410
  summary: Tools for creating, working with, and running Rails applications.
409
411
  test_files: []
410
- has_rdoc:
@@ -1,21 +0,0 @@
1
- require 'rails/command'
2
-
3
- module Rails
4
- module Commands
5
- # This is a wrapper around the Rails dev:cache command
6
- class DevCache < Command
7
- set_banner :dev_cache, 'Toggle development mode caching on/off'
8
- def dev_cache
9
- if File.exist? 'tmp/caching-dev.txt'
10
- File.delete 'tmp/caching-dev.txt'
11
- puts 'Development mode is no longer being cached.'
12
- else
13
- FileUtils.touch 'tmp/caching-dev.txt'
14
- puts 'Development mode is now being cached.'
15
- end
16
-
17
- FileUtils.touch 'tmp/restart.txt'
18
- end
19
- end
20
- end
21
- end