railties 5.0.0.beta1.1 → 5.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -6
  3. data/MIT-LICENSE +2 -2
  4. data/RDOC_MAIN.rdoc +1 -1
  5. data/lib/rails/application/default_middleware_stack.rb +1 -1
  6. data/lib/rails/application/finisher.rb +1 -1
  7. data/lib/rails/code_statistics.rb +1 -1
  8. data/lib/rails/commands/runner.rb +7 -1
  9. data/lib/rails/commands/server.rb +7 -3
  10. data/lib/rails/engine/commands.rb +3 -32
  11. data/lib/rails/engine/commands_tasks.rb +116 -0
  12. data/lib/rails/gem_version.rb +1 -1
  13. data/lib/rails/generators/actions.rb +2 -2
  14. data/lib/rails/generators/actions/create_migration.rb +1 -1
  15. data/lib/rails/generators/app_base.rb +22 -1
  16. data/lib/rails/generators/generated_attribute.rb +3 -2
  17. data/lib/rails/generators/named_base.rb +4 -0
  18. data/lib/rails/generators/rails/app/app_generator.rb +18 -2
  19. data/lib/rails/generators/rails/app/templates/Gemfile +0 -3
  20. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.coffee +1 -1
  21. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +1 -1
  22. data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +1 -1
  23. data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -3
  24. data/lib/rails/generators/rails/app/templates/config/cable.yml +10 -0
  25. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +1 -1
  26. data/lib/rails/generators/rails/app/templates/config/initializers/active_record_belongs_to_required_by_default.rb +3 -2
  27. data/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb +3 -2
  28. data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +2 -1
  29. data/lib/rails/generators/rails/app/templates/config/initializers/per_form_csrf_tokens.rb +4 -0
  30. data/lib/rails/generators/rails/app/templates/config/puma.rb +44 -0
  31. data/lib/rails/generators/rails/app/templates/config/secrets.yml +1 -1
  32. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
  33. data/lib/rails/generators/rails/model/USAGE +4 -4
  34. data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -1
  35. data/lib/rails/generators/rails/plugin/templates/README.md +26 -1
  36. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +7 -0
  37. data/lib/rails/generators/rails/plugin/templates/app/models/{application_record.rb.tt → %namespaced_name%/application_record.rb.tt} +0 -0
  38. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +1 -1
  39. data/lib/rails/generators/rails/scaffold/USAGE +1 -1
  40. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +1 -1
  41. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +2 -2
  42. data/lib/rails/rack/logger.rb +0 -6
  43. data/lib/rails/tasks/engine.rake +2 -2
  44. data/lib/rails/tasks/log.rake +19 -6
  45. data/lib/rails/tasks/routes.rake +30 -2
  46. data/lib/rails/templates/rails/welcome/index.html.erb +61 -265
  47. data/lib/rails/test_unit/line_filtering.rb +70 -0
  48. data/lib/rails/test_unit/minitest_plugin.rb +12 -9
  49. data/lib/rails/test_unit/railtie.rb +6 -0
  50. data/lib/rails/test_unit/reporter.rb +37 -1
  51. data/lib/rails/test_unit/test_requirer.rb +1 -1
  52. data/lib/rails/test_unit/testing.rake +6 -1
  53. metadata +17 -13
  54. data/lib/rails/generators/rails/app/templates/config/redis/cable.yml +0 -9
  55. data/lib/rails/generators/rails/plugin/templates/app/mailers/.empty_directory +0 -0
  56. data/lib/rails/generators/rails/plugin/templates/app/models/.empty_directory +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d23335496f6d7e45ebcb75396de70773e320caf7
4
- data.tar.gz: ae756993b2b619caf4414441bdd22dc44b700ebf
3
+ metadata.gz: 83e9a8d14879b7cd28fc9fd57f76b5e2f280c609
4
+ data.tar.gz: ac950ac53f6b98b0797920ed8d93fd96e875b74e
5
5
  SHA512:
6
- metadata.gz: ff0406de559fb90e7ebfaa23acca91dd40238dcc78804787d68da413be03c02f5ff72ac5d6b272658580c833ab95471529008d3047b72745f905ec13a7769bc2
7
- data.tar.gz: 46034d9104babd7ec8bbd92710eec64e6fcb2a0131939467e32d65d2d1c3470d427455c48a5a98adc2fb24df02788791406572ddebbe23e7f13e901379db1300
6
+ metadata.gz: 99c2414aba749e7dd0bb5fb7fb473387ded69a813dae0a40e4d4b2925318575bfed83ae59b46b28234590a7606aa5e82ef1237d97b9435da4504be22c9712e53
7
+ data.tar.gz: 0b1c83b2b97aa12caf646777cc37313eb25f46111b9359b4b648507698840678e1f2a12af058fd6ea288a8c35e267adaa5718e6529922340d581d7766bc67b40
data/CHANGELOG.md CHANGED
@@ -1,7 +1,30 @@
1
- ## Rails 5.0.0.beta1 (December 18, 2015) ##
1
+ ## Rails 5.0.0.beta2 (February 01, 2016) ##
2
+
3
+ * Add `after_bundle` callbacks in Rails plugin templates. Useful for allowing
4
+ templates to perform actions that are dependent upon `bundle install`.
5
+
6
+ *Ryan Manuel*
7
+
8
+ * Bring back `TEST=` env for `rake test` task.
9
+
10
+ *Yves Senn*
11
+
12
+ * Specify log file names or all logs to clear `rake log:clear`
2
13
 
3
- * No changes.
14
+ Specify which logs to clear when using the `rake log:clear` task, e.g. `rake log:clear LOGS=test,staging`
4
15
 
16
+ Clear all logs from log/*.log e.g. `rake log:clear LOGS=all`
17
+
18
+ By default `rake log:clear` clears standard environment log files i.e. 'development,test,production'
19
+
20
+ *Pramod Shinde*
21
+
22
+ * Fix using `add_source` with a block after using `gem` in a custom generator.
23
+
24
+ *Will Fisher*
25
+
26
+
27
+ ## Rails 5.0.0.beta1 (December 18, 2015) ##
5
28
 
6
29
  * Newly generated plugins get a `README.md` in Markdown.
7
30
 
@@ -200,7 +223,7 @@
200
223
  * Fix STATS_DIRECTORIES already defined warning when running rake from within
201
224
  the top level directory of an engine that has a test app.
202
225
 
203
- Fixes #20510
226
+ Fixes #20510.
204
227
 
205
228
  *Ersin Akinci*
206
229
 
@@ -248,13 +271,13 @@
248
271
  middleware for API apps & generators generates the right files,
249
272
  folders and configurations.
250
273
 
251
- *Santiago Pastorino & Jorge Bejar*
274
+ *Santiago Pastorino*, *Jorge Bejar*
252
275
 
253
276
  * Make generated scaffold functional tests work inside engines.
254
277
 
255
278
  *Yuji Yaginuma*
256
279
 
257
- * Generator a `.keep` file in the `tmp` folder by default as many scripts
280
+ * Generate a `.keep` file in the `tmp` folder by default as many scripts
258
281
  assume the existence of this folder and most would fail if it is absent.
259
282
 
260
283
  See #20299.
@@ -320,7 +343,7 @@
320
343
  * Created rake restart task. Restarts your Rails app by touching the
321
344
  `tmp/restart.txt`.
322
345
 
323
- Fixes #18876.
346
+ See #18876.
324
347
 
325
348
  *Hyonjee Joo*
326
349
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2015 David Heinemeier Hansson
1
+ Copyright (c) 2004-2016 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/RDOC_MAIN.rdoc CHANGED
@@ -57,7 +57,7 @@ can read more about Action Pack in its {README}[link:files/actionpack/README_rdo
57
57
 
58
58
  * The \README file created within your application.
59
59
  * {Getting Started with \Rails}[http://guides.rubyonrails.org/getting_started.html].
60
- * {Ruby on \Rails Tutorial}[http://ruby.railstutorial.org/ruby-on-rails-tutorial-book].
60
+ * {Ruby on \Rails Tutorial}[http://www.railstutorial.org/book].
61
61
  * {Ruby on \Rails Guides}[http://guides.rubyonrails.org].
62
62
  * {The API Documentation}[http://api.rubyonrails.org].
63
63
 
@@ -68,7 +68,7 @@ module Rails
68
68
  middleware.use ::ActionDispatch::Cookies unless config.api_only
69
69
 
70
70
  if !config.api_only && config.session_store
71
- if config.force_ssl && !config.session_options.key?(:secure)
71
+ if config.force_ssl && config.ssl_options.fetch(:secure_cookies, true) && !config.session_options.key?(:secure)
72
72
  config.session_options[:secure] = true
73
73
  end
74
74
  middleware.use config.session_store, config.session_options
@@ -86,7 +86,7 @@ module Rails
86
86
  # added in the hook are taken into account.
87
87
  initializer :set_clear_dependencies_hook, group: :all do
88
88
  callback = lambda do
89
- ActiveSupport::Dependencies.interlock.attempt_unloading do
89
+ ActiveSupport::Dependencies.interlock.unloading do
90
90
  ActiveSupport::DescendantsTracker.clear
91
91
  ActiveSupport::Dependencies.clear
92
92
  end
@@ -33,7 +33,7 @@ class CodeStatistics #:nodoc:
33
33
  Hash[@pairs.map{|pair| [pair.first, calculate_directory_statistics(pair.last)]}]
34
34
  end
35
35
 
36
- def calculate_directory_statistics(directory, pattern = /.*\.(rb|js|coffee|rake)$/)
36
+ def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|coffee|rake)$/)
37
37
  stats = CodeStatisticsCalculator.new
38
38
 
39
39
  Dir.foreach(directory) do |file_name|
@@ -58,5 +58,11 @@ elsif File.exist?(code_or_file)
58
58
  $0 = code_or_file
59
59
  Kernel.load code_or_file
60
60
  else
61
- eval(code_or_file, binding, __FILE__, __LINE__)
61
+ begin
62
+ eval(code_or_file, binding, __FILE__, __LINE__)
63
+ rescue SyntaxError,NameError => err
64
+ $stderr.puts "Please specify a valid ruby command or the path of a script to run."
65
+ $stderr.puts "Run '#{$0} -h' for help."
66
+ exit 1
67
+ end
62
68
  end
@@ -6,6 +6,8 @@ require 'rails'
6
6
  module Rails
7
7
  class Server < ::Rack::Server
8
8
  class Options
9
+ DEFAULT_PID_PATH = File.expand_path("tmp/pids/server.pid").freeze
10
+
9
11
  def parse!(args)
10
12
  args, options = args.dup, {}
11
13
 
@@ -91,7 +93,7 @@ module Rails
91
93
  environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
92
94
  daemonize: false,
93
95
  caching: false,
94
- pid: File.expand_path("tmp/pids/server.pid")
96
+ pid: Options::DEFAULT_PID_PATH
95
97
  })
96
98
  end
97
99
 
@@ -133,11 +135,13 @@ module Rails
133
135
  def log_to_stdout
134
136
  wrapped_app # touch the app so the logger is set up
135
137
 
136
- console = ActiveSupport::Logger.new($stdout)
138
+ console = ActiveSupport::Logger.new(STDOUT)
137
139
  console.formatter = Rails.logger.formatter
138
140
  console.level = Rails.logger.level
139
141
 
140
- Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
142
+ unless ActiveSupport::Logger.logger_outputs_to?(Rails.logger, STDOUT)
143
+ Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
144
+ end
141
145
  end
142
146
  end
143
147
  end
@@ -1,3 +1,5 @@
1
+ require 'rails/engine/commands_tasks'
2
+
1
3
  ARGV << '--help' if ARGV.empty?
2
4
 
3
5
  aliases = {
@@ -9,35 +11,4 @@ aliases = {
9
11
  command = ARGV.shift
10
12
  command = aliases[command] || command
11
13
 
12
- require ENGINE_PATH
13
- engine = ::Rails::Engine.find(ENGINE_ROOT)
14
-
15
- case command
16
- when 'generate', 'destroy', 'test'
17
- require 'rails/generators'
18
- Rails::Generators.namespace = engine.railtie_namespace
19
- engine.load_generators
20
- require "rails/commands/#{command}"
21
-
22
- when '--version', '-v'
23
- ARGV.unshift '--version'
24
- require 'rails/commands/application'
25
-
26
- else
27
- puts "Error: Command not recognized" unless %w(-h --help).include?(command)
28
- puts <<-EOT
29
- Usage: rails COMMAND [ARGS]
30
-
31
- The common Rails commands available for engines are:
32
- generate Generate new code (short-cut alias: "g")
33
- destroy Undo code generated with "generate" (short-cut alias: "d")
34
- test Run tests (short-cut alias: "t")
35
-
36
- All commands can be run with -h for more information.
37
-
38
- If you want to run any commands that need to be run in context
39
- of the application, like `rails server` or `rails console`,
40
- you should do it from application's directory (typically test/dummy).
41
- EOT
42
- exit(1)
43
- end
14
+ Rails::Engine::CommandsTasks.new(ARGV).run_command!(command)
@@ -0,0 +1,116 @@
1
+ require 'rails/commands/rake_proxy'
2
+
3
+ module Rails
4
+ class Engine
5
+ class CommandsTasks # :nodoc:
6
+ include Rails::RakeProxy
7
+
8
+ attr_reader :argv
9
+
10
+ HELP_MESSAGE = <<-EOT
11
+ Usage: rails COMMAND [ARGS]
12
+
13
+ The common Rails commands available for engines are:
14
+ generate Generate new code (short-cut alias: "g")
15
+ destroy Undo code generated with "generate" (short-cut alias: "d")
16
+ test Run tests (short-cut alias: "t")
17
+
18
+ All commands can be run with -h for more information.
19
+
20
+ If you want to run any commands that need to be run in context
21
+ of the application, like `rails server` or `rails console`,
22
+ you should do it from application's directory (typically test/dummy).
23
+
24
+ In addition to those commands, there are:
25
+ EOT
26
+
27
+ COMMAND_WHITELIST = %w(generate destroy version help test)
28
+
29
+ def initialize(argv)
30
+ @argv = argv
31
+ end
32
+
33
+ def run_command!(command)
34
+ command = parse_command(command)
35
+
36
+ if COMMAND_WHITELIST.include?(command)
37
+ send(command)
38
+ else
39
+ run_rake_task(command)
40
+ end
41
+ end
42
+
43
+ def generate
44
+ generate_or_destroy(:generate)
45
+ end
46
+
47
+ def destroy
48
+ generate_or_destroy(:destroy)
49
+ end
50
+
51
+ def test
52
+ require_command!("test")
53
+ end
54
+
55
+ def version
56
+ argv.unshift '--version'
57
+ require_command!("application")
58
+ end
59
+
60
+ def help
61
+ write_help_message
62
+ write_commands(formatted_rake_tasks)
63
+ end
64
+
65
+ private
66
+
67
+ def require_command!(command)
68
+ require "rails/commands/#{command}"
69
+ end
70
+
71
+ def generate_or_destroy(command)
72
+ load_generators
73
+ require_command!(command)
74
+ end
75
+
76
+ def load_generators
77
+ require 'rails/generators'
78
+ require ENGINE_PATH
79
+
80
+ engine = ::Rails::Engine.find(ENGINE_ROOT)
81
+ Rails::Generators.namespace = engine.railtie_namespace
82
+ engine.load_generators
83
+ end
84
+
85
+ def write_help_message
86
+ puts HELP_MESSAGE
87
+ end
88
+
89
+ def write_commands(commands)
90
+ width = commands.map { |name, _| name.size }.max || 10
91
+ commands.each { |command| printf(" %-#{width}s %s\n", *command) }
92
+ end
93
+
94
+ def parse_command(command)
95
+ case command
96
+ when '--version', '-v'
97
+ 'version'
98
+ when '--help', '-h'
99
+ 'help'
100
+ else
101
+ command
102
+ end
103
+ end
104
+
105
+ def rake_tasks
106
+ return @rake_tasks if defined?(@rake_tasks)
107
+
108
+ load_generators
109
+ Rake::TaskManager.record_task_metadata = true
110
+ Rake.application.init('rails')
111
+ Rake.application.load_rakefile
112
+ @rake_tasks = Rake.application.tasks.select(&:comment)
113
+ end
114
+ end
115
+ end
116
+ end
@@ -8,7 +8,7 @@ module Rails
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta1.1"
11
+ PRE = "beta2"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -20,7 +20,7 @@ module Rails
20
20
 
21
21
  # Set the message to be shown in logs. Uses the git repo if one is given,
22
22
  # otherwise use name (version).
23
- parts, message = [ quote(name) ], name
23
+ parts, message = [ quote(name) ], name.dup
24
24
  if version ||= options.delete(:version)
25
25
  parts << quote(version)
26
26
  message << " (#{version})"
@@ -75,7 +75,7 @@ module Rails
75
75
 
76
76
  in_root do
77
77
  if block
78
- append_file "Gemfile", "source #{quote(source)} do", force: true
78
+ append_file "Gemfile", "\nsource #{quote(source)} do", force: true
79
79
  @in_group = true
80
80
  instance_eval(&block)
81
81
  @in_group = false
@@ -3,7 +3,7 @@ require 'thor/actions'
3
3
  module Rails
4
4
  module Generators
5
5
  module Actions
6
- class CreateMigration < Thor::Actions::CreateFile
6
+ class CreateMigration < Thor::Actions::CreateFile #:nodoc:
7
7
 
8
8
  def migration_dir
9
9
  File.dirname(@destination)
@@ -51,6 +51,9 @@ module Rails
51
51
  class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
52
52
  desc: 'Skip Active Record files'
53
53
 
54
+ class_option :skip_puma, type: :boolean, aliases: '-P', default: false,
55
+ desc: 'Skip Puma related files'
56
+
54
57
  class_option :skip_action_cable, type: :boolean, aliases: '-C', default: false,
55
58
  desc: 'Skip Action Cable files'
56
59
 
@@ -75,7 +78,7 @@ module Rails
75
78
  class_option :edge, type: :boolean, default: false,
76
79
  desc: "Setup the #{name} with Gemfile pointing to Rails repository"
77
80
 
78
- class_option :rc, type: :string, default: false,
81
+ class_option :rc, type: :string, default: nil,
79
82
  desc: "Path to file containing extra configuration options for rails command"
80
83
 
81
84
  class_option :no_rc, type: :boolean, default: false,
@@ -113,10 +116,12 @@ module Rails
113
116
  def gemfile_entries
114
117
  [rails_gemfile_entry,
115
118
  database_gemfile_entry,
119
+ webserver_gemfile_entry,
116
120
  assets_gemfile_entry,
117
121
  javascript_gemfile_entry,
118
122
  jbuilder_gemfile_entry,
119
123
  psych_gemfile_entry,
124
+ cable_gemfile_entry,
120
125
  @extra_entries].flatten.find_all(&@gem_filter)
121
126
  end
122
127
 
@@ -170,6 +175,12 @@ module Rails
170
175
  "Use #{options[:database]} as the database for Active Record"
171
176
  end
172
177
 
178
+ def webserver_gemfile_entry
179
+ return [] if options[:skip_puma]
180
+ comment = 'Use Puma as the app server'
181
+ GemfileEntry.new('puma', nil, comment)
182
+ end
183
+
173
184
  def include_all_railties?
174
185
  options.values_at(:skip_active_record, :skip_action_mailer, :skip_test, :skip_sprockets, :skip_action_cable).none?
175
186
  end
@@ -281,6 +292,8 @@ module Rails
281
292
  return [] if options[:skip_sprockets]
282
293
 
283
294
  gems = []
295
+ gems << GemfileEntry.version('sass-rails', '~> 5.0',
296
+ 'Use SCSS for stylesheets')
284
297
 
285
298
  gems << GemfileEntry.version('uglifier',
286
299
  '>= 1.3.0',
@@ -337,6 +350,14 @@ module Rails
337
350
  GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
338
351
  end
339
352
 
353
+ def cable_gemfile_entry
354
+ return [] if options[:skip_action_cable]
355
+ comment = 'Action Cable dependencies for the Redis adapter'
356
+ gems = []
357
+ gems << GemfileEntry.new("redis", '~> 3.0', comment)
358
+ gems
359
+ end
360
+
340
361
  def bundle_command(command)
341
362
  say_status :run, "bundle #{command}"
342
363