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
data/lib/rails/railtie.rb CHANGED
@@ -183,8 +183,8 @@ module Rails
183
183
  end
184
184
 
185
185
  protected
186
- def generate_railtie_name(class_or_module)
187
- ActiveSupport::Inflector.underscore(class_or_module).tr("/", "_")
186
+ def generate_railtie_name(string)
187
+ ActiveSupport::Inflector.underscore(string).tr("/", "_")
188
188
  end
189
189
 
190
190
  # If the class method does not have a method, then send the method call
@@ -2,7 +2,7 @@ if RUBY_VERSION < '1.9.3'
2
2
  desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
3
3
  abort <<-end_message
4
4
 
5
- Rails 4 prefers to run on Ruby 2.0.
5
+ Rails 4 prefers to run on Ruby 2.1 or newer.
6
6
 
7
7
  You're running
8
8
  #{desc}
@@ -18,6 +18,20 @@ class SourceAnnotationExtractor
18
18
  @@directories ||= %w(app config db lib test) + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
19
19
  end
20
20
 
21
+ def self.extensions
22
+ @@extensions ||= {}
23
+ end
24
+
25
+ # Registers new Annotations File Extensions
26
+ # SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
27
+ def self.register_extensions(*exts, &block)
28
+ extensions[/\.(#{exts.join("|")})$/] = block
29
+ end
30
+
31
+ register_extensions("builder", "rb", "rake", "yml", "yaml", "ruby") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
32
+ register_extensions("css", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
33
+ register_extensions("erb") { |tag| /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ }
34
+
21
35
  # Returns a representation of the annotation that looks like this:
22
36
  #
23
37
  # [126] [TODO] This algorithm is simple and clearly correct, make it faster.
@@ -78,21 +92,14 @@ class SourceAnnotationExtractor
78
92
  if File.directory?(item)
79
93
  results.update(find_in(item))
80
94
  else
81
- pattern =
82
- case item
83
- when /\.(builder|rb|coffee|rake)$/
84
- /#\s*(#{tag}):?\s*(.*)$/
85
- when /\.(css|scss|sass|less|js)$/
86
- /\/\/\s*(#{tag}):?\s*(.*)$/
87
- when /\.erb$/
88
- /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/
89
- when /\.haml$/
90
- /-\s*#\s*(#{tag}):?\s*(.*)$/
91
- when /\.slim$/
92
- /\/\s*\s*(#{tag}):?\s*(.*)$/
93
- else nil
94
- end
95
- results.update(extract_annotations_from(item, pattern)) if pattern
95
+ extension = Annotation.extensions.detect do |regexp, _block|
96
+ regexp.match(item)
97
+ end
98
+
99
+ if extension
100
+ pattern = extension.last.call(tag)
101
+ results.update(extract_annotations_from(item, pattern)) if pattern
102
+ end
96
103
  end
97
104
  end
98
105
 
@@ -115,7 +122,7 @@ class SourceAnnotationExtractor
115
122
  # Prints the mapping from filenames to annotations in +results+ ordered by filename.
116
123
  # The +options+ hash is passed to each annotation's +to_s+.
117
124
  def display(results, options={})
118
- options[:indent] = results.map { |f, a| a.map(&:line) }.flatten.max.to_s.size
125
+ options[:indent] = results.flat_map { |f, a| a.map(&:line) }.max.to_s.size
119
126
  results.keys.sort.each do |file|
120
127
  puts "#{file}:"
121
128
  results[file].each do |note|
@@ -3,7 +3,7 @@ namespace :rails do
3
3
  task update: [ "update:configs", "update:bin" ]
4
4
 
5
5
  desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
6
- task :template do
6
+ task template: :environment do
7
7
  template = ENV["LOCATION"]
8
8
  raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
9
9
  template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
@@ -1,3 +1,6 @@
1
+ # while having global constant is not good,
2
+ # many 3rd party tools depend on it, like rspec-rails, cucumber-rails, etc
3
+ # so if will be removed - deprecation warning is needed
1
4
  STATS_DIRECTORIES = [
2
5
  %w(Controllers app/controllers),
3
6
  %w(Helpers app/helpers),
@@ -13,10 +16,12 @@ STATS_DIRECTORIES = [
13
16
  %w(Integration\ tests test/integration),
14
17
  %w(Functional\ tests\ (old) test/functional),
15
18
  %w(Unit\ tests \ (old) test/unit)
16
- ].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
19
+ ].collect do |name, dir|
20
+ [ name, "#{File.dirname(Rake.application.rakefile_location)}/#{dir}" ]
21
+ end.select { |name, dir| File.directory?(dir) }
17
22
 
18
- desc "Report code statistics (KLOCs, etc) from the application"
23
+ desc "Report code statistics (KLOCs, etc) from the application or engine"
19
24
  task :stats do
20
25
  require 'rails/code_statistics'
21
26
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
22
- end
27
+ end
@@ -31,10 +31,6 @@
31
31
  padding: 1px;
32
32
  }
33
33
 
34
- dd:empty:before {
35
- content: "\00a0"; // &nbsp;
36
- }
37
-
38
34
  iframe {
39
35
  border: 0;
40
36
  width: 100%;
@@ -81,7 +77,7 @@
81
77
  <% unless @email.attachments.nil? || @email.attachments.empty? %>
82
78
  <dt>Attachments:</dt>
83
79
  <dd>
84
- <%= @email.attachments.map { |a| a.respond_to?(:original_filename) ? a.original_filename : a.filename }.join(', ') %>
80
+ <%= @email.attachments.map { |a| a.respond_to?(:original_filename) ? a.original_filename : a.filename }.inspect %>
85
81
  </dd>
86
82
  <% end %>
87
83
 
@@ -96,14 +92,7 @@
96
92
  </dl>
97
93
  </header>
98
94
 
99
- <% if @part && @part.mime_type %>
100
- <iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe>
101
- <% else %>
102
- <p>
103
- You are trying to preview an email that does not have any content.
104
- This is probably because the <em>mail</em> method has not been called in <em><%= @preview.preview_name %>#<%= @email_action %></em>.
105
- </p>
106
- <% end %>
95
+ <iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe>
107
96
 
108
97
  </body>
109
98
  </html>
@@ -1,8 +1,8 @@
1
1
  <% @previews.each do |preview| %>
2
- <h3><%= link_to preview.preview_name.titleize, url_for(controller: "rails/mailers", action: "preview", path: preview.preview_name) %></h3>
2
+ <h3><%= link_to preview.preview_name.titleize, "/rails/mailers/#{preview.preview_name}" %></h3>
3
3
  <ul>
4
4
  <% preview.emails.each do |email| %>
5
- <li><%= link_to email, url_for(controller: "rails/mailers", action: "preview", path: "#{preview.preview_name}/#{email}") %></li>
5
+ <li><%= link_to email, "/rails/mailers/#{preview.preview_name}/#{email}" %></li>
6
6
  <% end %>
7
7
  </ul>
8
8
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <h3><%= @preview.preview_name.titleize %></h3>
2
2
  <ul>
3
3
  <% @preview.emails.each do |email| %>
4
- <li><%= link_to email, url_for(controller: "rails/mailers", action: "preview", path: "#{@preview.preview_name}/#{email}") %></li>
4
+ <li><%= link_to email, "/rails/mailers/#{@preview.preview_name}/#{email}" %></li>
5
5
  <% end %>
6
6
  </ul>
@@ -7,7 +7,7 @@ module Rails
7
7
  #
8
8
  # This class takes a TestInfo class and defines the appropriate rake task
9
9
  # based on the information, then invokes it.
10
- class TestCreator
10
+ class TestCreator # :nodoc:
11
11
  def initialize(info)
12
12
  @info = info
13
13
  end
@@ -41,7 +41,7 @@ module Rails
41
41
  # to test files (or can be transformed into test files). Calling <tt>files</tt>
42
42
  # provides the set of test files and is used when initializing tests after
43
43
  # a call to <tt>rake test</tt>.
44
- class TestInfo
44
+ class TestInfo # :nodoc:
45
45
  def initialize(tasks)
46
46
  @tasks = tasks
47
47
  @files = nil
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: 4.1.16
4
+ version: 4.2.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2014-08-20 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: 4.1.16
19
+ version: 4.2.0.beta1
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: 4.1.16
26
+ version: 4.2.0.beta1
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: 4.1.16
33
+ version: 4.2.0.beta1
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: 4.1.16
40
+ version: 4.2.0.beta1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
- version: 4.1.16
81
+ version: 4.2.0.beta1
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 4.1.16
88
+ version: 4.2.0.beta1
89
89
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
90
90
  email: david@loudthinking.com
91
91
  executables:
@@ -157,6 +157,7 @@ files:
157
157
  - lib/rails/generators/js/assets/assets_generator.rb
158
158
  - lib/rails/generators/js/assets/templates/javascript.js
159
159
  - lib/rails/generators/migration.rb
160
+ - lib/rails/generators/model_helpers.rb
160
161
  - lib/rails/generators/named_base.rb
161
162
  - lib/rails/generators/rails/app/USAGE
162
163
  - lib/rails/generators/rails/app/app_generator.rb
@@ -171,6 +172,7 @@ files:
171
172
  - lib/rails/generators/rails/app/templates/bin/bundle
172
173
  - lib/rails/generators/rails/app/templates/bin/rails
173
174
  - lib/rails/generators/rails/app/templates/bin/rake
175
+ - lib/rails/generators/rails/app/templates/bin/setup
174
176
  - lib/rails/generators/rails/app/templates/config.ru
175
177
  - lib/rails/generators/rails/app/templates/config/application.rb
176
178
  - lib/rails/generators/rails/app/templates/config/boot.rb
@@ -276,7 +278,6 @@ files:
276
278
  - lib/rails/generators/test_unit/generator/generator_generator.rb
277
279
  - lib/rails/generators/test_unit/generator/templates/generator_test.rb
278
280
  - lib/rails/generators/test_unit/helper/helper_generator.rb
279
- - lib/rails/generators/test_unit/helper/templates/helper_test.rb
280
281
  - lib/rails/generators/test_unit/integration/integration_generator.rb
281
282
  - lib/rails/generators/test_unit/integration/templates/integration_test.rb
282
283
  - lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -306,7 +307,6 @@ files:
306
307
  - lib/rails/railtie/configurable.rb
307
308
  - lib/rails/railtie/configuration.rb
308
309
  - lib/rails/ruby_version_check.rb
309
- - lib/rails/rubyprof_ext.rb
310
310
  - lib/rails/source_annotation_extractor.rb
311
311
  - lib/rails/tasks.rb
312
312
  - lib/rails/tasks/annotations.rake
@@ -349,12 +349,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
349
349
  version: 1.9.3
350
350
  required_rubygems_version: !ruby/object:Gem::Requirement
351
351
  requirements:
352
- - - ">="
352
+ - - ">"
353
353
  - !ruby/object:Gem::Version
354
- version: '0'
354
+ version: 1.3.1
355
355
  requirements: []
356
356
  rubyforge_project:
357
- rubygems_version: 2.4.5.1
357
+ rubygems_version: 2.2.2
358
358
  signing_key:
359
359
  specification_version: 4
360
360
  summary: Tools for creating, working with, and running Rails applications.
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>HelperTest < ActionView::TestCase
5
- end
6
- <% end -%>
@@ -1,35 +0,0 @@
1
- require 'prof'
2
-
3
- module Prof #:nodoc:
4
- # Adapted from Shugo Maeda's unprof.rb
5
- def self.print_profile(results, io = $stderr)
6
- total = results.detect { |i|
7
- i.method_class.nil? && i.method_id == :"#toplevel"
8
- }.total_time
9
- total = 0.001 if total < 0.001
10
-
11
- io.puts " %% cumulative self self total"
12
- io.puts " time seconds seconds calls ms/call ms/call name"
13
-
14
- sum = 0.0
15
- results.each do |r|
16
- sum += r.self_time
17
-
18
- name = if r.method_class.nil?
19
- r.method_id.to_s
20
- elsif r.method_class.is_a?(Class)
21
- "#{r.method_class}##{r.method_id}"
22
- else
23
- "#{r.method_class}.#{r.method_id}"
24
- end
25
- io.printf "%6.2f %8.3f %8.3f %8d %8.2f %8.2f %s\n",
26
- r.self_time / total * 100,
27
- sum,
28
- r.self_time,
29
- r.count,
30
- r.self_time * 1000 / r.count,
31
- r.total_time * 1000 / r.count,
32
- name
33
- end
34
- end
35
- end