actionpack 3.1.1.rc2 → 3.1.1.rc3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,5 +1,41 @@
1
1
  *Rails 3.1.1 (unreleased)*
2
2
 
3
+ * stylesheet_link_tag('/stylesheets/application') and similar helpers doesn't
4
+ throw Sprockets::FileOutsidePaths exception anymore [Santiago Pastorino]
5
+
6
+ * Ensure default_asset_host_protocol is respected, closes #2980. [José Valim]
7
+
8
+ Changing rake db:schema:dump to run :environment as well as :load_config,
9
+ as running :load_config alone will lead to the dumper being run without
10
+ including extensions such as those included in foreigner and
11
+ spatial_adapter.
12
+
13
+ This reverses a change made here:
14
+ https://github.com/rails/rails/commit/5df72a238e9fcb18daf6ab6e6dc9051c9106d7bb#L0L324
15
+
16
+ I'm assuming here that :load_config needs to be invoked
17
+ separately from :environment, as it is elsewhere in the
18
+ file for db operations, if not the alternative is to go
19
+ back to "task :dump => :environment do".
20
+
21
+ [Ben Woosley]
22
+
23
+ * Update to rack-cache 1.1.
24
+
25
+ Versions prior to 1.1 delete the If-Modified-Since and If-Not-Modified
26
+ headers when config.action_controller.perform_caching is true. This has two
27
+ problems:
28
+ * unexpected inconsistent behaviour between development &
29
+ production environments
30
+ * breaks applications that use of these headers
31
+
32
+ [Brendan Ribera]
33
+
34
+ * Ensure that enhancements to assets:precompile task are only run once [Sam Pohlenz]
35
+
36
+ * TestCase should respect the view_assigns API instead of pulling variables on
37
+ its own. [José Valim]
38
+
3
39
  * javascript_path and stylesheet_path now refer to /assets if asset pipelining
4
40
  is on. [Santiago Pastorino]
5
41
 
@@ -3,7 +3,8 @@ module AbstractController
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir, :stylesheets_dir
6
+ config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir,
7
+ :stylesheets_dir, :default_asset_host_protocol
7
8
  end
8
9
  end
9
10
  end
@@ -120,8 +120,6 @@ module AbstractController
120
120
  view_renderer.render(view_context, options)
121
121
  end
122
122
 
123
- private
124
-
125
123
  DEFAULT_PROTECTED_INSTANCE_VARIABLES = %w(
126
124
  @_action_name @_response_body @_formats @_prefixes @_config
127
125
  @_view_context_class @_view_renderer @_lookup_context
@@ -139,6 +137,8 @@ module AbstractController
139
137
  hash
140
138
  end
141
139
 
140
+ private
141
+
142
142
  # Normalize args and options.
143
143
  # :api: private
144
144
  def _normalize_render(*args, &block)
@@ -4,12 +4,7 @@ require 'active_support/core_ext/hash/indifferent_access'
4
4
  module ActionDispatch
5
5
  module TestProcess
6
6
  def assigns(key = nil)
7
- assigns = {}.with_indifferent_access
8
- @controller.instance_variable_names.each do |ivar|
9
- next if ActionController::Base.protected_instance_variables.include?(ivar)
10
- assigns[ivar[1..-1]] = @controller.instance_variable_get(ivar)
11
- end
12
-
7
+ assigns = @controller.view_assigns.with_indifferent_access
13
8
  key.nil? ? assigns : assigns[key]
14
9
  end
15
10
 
@@ -3,7 +3,7 @@ module ActionPack
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
5
  TINY = 1
6
- PRE = "rc2"
6
+ PRE = "rc3"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
@@ -16,8 +16,6 @@ module ActionView
16
16
  # roots. Rewrite the asset path for cache-busting asset ids. Include
17
17
  # asset host, if configured, with the correct request protocol.
18
18
  #
19
- # When include_host is true and the asset host does not specify the protocol
20
- # the protocol parameter specifies how the protocol will be added.
21
19
  # When :relative (default), the protocol will be determined by the client using current protocol
22
20
  # When :request, the protocol will be the request protocol
23
21
  # Otherwise, the protocol is used (E.g. :http, :https, etc)
@@ -25,11 +23,10 @@ module ActionView
25
23
  source = source.to_s
26
24
  return source if is_uri?(source)
27
25
 
28
- options[:include_host] ||= true
29
26
  source = rewrite_extension(source, dir, options[:ext]) if options[:ext]
30
27
  source = rewrite_asset_path(source, dir, options)
31
28
  source = rewrite_relative_url_root(source, relative_url_root)
32
- source = rewrite_host_and_protocol(source, options[:protocol]) if options[:include_host]
29
+ source = rewrite_host_and_protocol(source, options[:protocol])
33
30
  source
34
31
  end
35
32
 
@@ -89,9 +86,7 @@ module ActionView
89
86
  end
90
87
 
91
88
  def default_protocol
92
- protocol = @config.action_controller.default_asset_host_protocol if @config.action_controller.present?
93
- protocol ||= @config.default_asset_host_protocol
94
- protocol || (has_request? ? :request : :relative)
89
+ @config.default_asset_host_protocol || (has_request? ? :request : :relative)
95
90
  end
96
91
 
97
92
  def invalid_asset_host!(help_message)
@@ -120,19 +115,11 @@ module ActionView
120
115
  end
121
116
 
122
117
  def relative_url_root
123
- if config.action_controller.present?
124
- config.action_controller.relative_url_root
125
- else
126
- config.relative_url_root
127
- end
118
+ config.relative_url_root
128
119
  end
129
120
 
130
121
  def asset_host_config
131
- if config.action_controller.present?
132
- config.action_controller.asset_host
133
- else
134
- config.asset_host
135
- end
122
+ config.asset_host
136
123
  end
137
124
 
138
125
  # Returns the current request if one exists.
@@ -65,7 +65,7 @@ module ActionView
65
65
  methods.flatten.each do |method|
66
66
  _helpers.module_eval <<-end_eval
67
67
  def #{method}(*args, &block) # def current_user(*args, &block)
68
- _test_case.send(%(#{method}), *args, &block) # test_case.send(%(current_user), *args, &block)
68
+ _test_case.send(%(#{method}), *args, &block) # _test_case.send(%(current_user), *args, &block)
69
69
  end # end
70
70
  end_eval
71
71
  end
@@ -1,60 +1,95 @@
1
+ require "fileutils"
2
+
1
3
  namespace :assets do
4
+ def ruby_rake_task(task)
5
+ env = ENV['RAILS_ENV'] || 'production'
6
+ groups = ENV['RAILS_GROUPS'] || 'assets'
7
+ args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
8
+ args << "--trace" if Rake.application.options.trace
9
+ ruby *args
10
+ end
11
+
12
+ # We are currently running with no explicit bundler group
13
+ # and/or no explicit environment - we have to reinvoke rake to
14
+ # execute this task.
15
+ def invoke_or_reboot_rake_task(task)
16
+ if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
17
+ ruby_rake_task task
18
+ else
19
+ Rake::Task[task].invoke
20
+ end
21
+ end
22
+
2
23
  desc "Compile all the assets named in config.assets.precompile"
3
24
  task :precompile do
4
- # We need to do this dance because RAILS_GROUPS is used
5
- # too early in the boot process and changing here is already too late.
6
- if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
7
- ENV["RAILS_GROUPS"] ||= "assets"
8
- ENV["RAILS_ENV"] ||= "production"
9
- ruby $0, *ARGV
10
- else
11
- require "fileutils"
12
- Rake::Task["tmp:cache:clear"].invoke
13
- Rake::Task["assets:environment"].invoke
25
+ invoke_or_reboot_rake_task "assets:precompile:all"
26
+ end
14
27
 
28
+ namespace :precompile do
29
+ def internal_precompile(digest=nil)
15
30
  unless Rails.application.config.assets.enabled
16
- raise "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
31
+ warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
32
+ exit
17
33
  end
18
34
 
19
- # Ensure that action view is loaded and the appropriate sprockets hooks get executed
20
- ActionView::Base
35
+ # Ensure that action view is loaded and the appropriate
36
+ # sprockets hooks get executed
37
+ _ = ActionView::Base
21
38
 
22
39
  config = Rails.application.config
23
40
  config.assets.compile = true
24
- config.assets.digest = false if ENV["RAILS_ASSETS_NONDIGEST"]
25
-
26
- env = Rails.application.assets
27
-
28
- # Always compile files and avoid use of existing precompiled assets
29
- config.assets.compile = true
41
+ config.assets.digest = digest unless digest.nil?
30
42
  config.assets.digests = {}
31
43
 
32
- target = File.join(Rails.public_path, config.assets.prefix)
33
- static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest)
44
+ env = Rails.application.assets
45
+ target = File.join(Rails.public_path, config.assets.prefix)
46
+ compiler = Sprockets::StaticCompiler.new(env,
47
+ target,
48
+ config.assets.precompile,
49
+ :manifest_path => config.assets.manifest,
50
+ :digest => config.assets.digest,
51
+ :manifest => digest.nil?)
52
+ compiler.compile
53
+ end
34
54
 
35
- manifest = static_compiler.precompile(config.assets.precompile)
36
- manifest_path = config.assets.manifest || target
37
- FileUtils.mkdir_p(manifest_path)
55
+ task :all do
56
+ Rake::Task["assets:precompile:primary"].invoke
57
+ # We need to reinvoke in order to run the secondary digestless
58
+ # asset compilation run - a fresh Sprockets environment is
59
+ # required in order to compile digestless assets as the
60
+ # environment has already cached the assets on the primary
61
+ # run.
62
+ ruby_rake_task "assets:precompile:nondigest" if Rails.application.config.assets.digest
63
+ end
38
64
 
39
- unless ENV["RAILS_ASSETS_NONDIGEST"]
40
- File.open("#{manifest_path}/manifest.yml", 'wb') do |f|
41
- YAML.dump(manifest, f)
42
- end
43
- ENV["RAILS_ASSETS_NONDIGEST"] = "true"
44
- ruby $0, *ARGV
45
- end
65
+ task :primary => ["assets:environment", "tmp:cache:clear"] do
66
+ internal_precompile
67
+ end
68
+
69
+ task :nondigest => ["assets:environment", "tmp:cache:clear"] do
70
+ internal_precompile(false)
46
71
  end
47
72
  end
48
73
 
49
74
  desc "Remove compiled assets"
50
- task :clean => ['assets:environment', 'tmp:cache:clear'] do
51
- config = Rails.application.config
52
- public_asset_path = File.join(Rails.public_path, config.assets.prefix)
53
- rm_rf public_asset_path, :secure => true
75
+ task :clean do
76
+ invoke_or_reboot_rake_task "assets:clean:all"
77
+ end
78
+
79
+ namespace :clean do
80
+ task :all => ["assets:environment", "tmp:cache:clear"] do
81
+ config = Rails.application.config
82
+ public_asset_path = File.join(Rails.public_path, config.assets.prefix)
83
+ rm_rf public_asset_path, :secure => true
84
+ end
54
85
  end
55
86
 
56
87
  task :environment do
57
- Rails.application.initialize!(:assets)
58
- Sprockets::Bootstrap.new(Rails.application).run
88
+ if Rails.application.config.assets.initialize_on_precompile
89
+ Rake::Task["environment"].invoke
90
+ else
91
+ Rails.application.initialize!(:assets)
92
+ Sprockets::Bootstrap.new(Rails.application).run
93
+ end
59
94
  end
60
95
  end
@@ -1,5 +1,6 @@
1
1
  module Sprockets
2
2
  module Helpers
3
- autoload :RailsHelper, "sprockets/helpers/rails_helper"
3
+ autoload :RailsHelper, "sprockets/helpers/rails_helper"
4
+ autoload :IsolatedHelper, "sprockets/helpers/isolated_helper"
4
5
  end
5
6
  end
@@ -0,0 +1,13 @@
1
+ module Sprockets
2
+ module Helpers
3
+ module IsolatedHelper
4
+ def controller
5
+ nil
6
+ end
7
+
8
+ def config
9
+ Rails.application.config.action_controller
10
+ end
11
+ end
12
+ end
13
+ end
@@ -8,9 +8,6 @@ module Sprockets
8
8
 
9
9
  def asset_paths
10
10
  @asset_paths ||= begin
11
- config = self.config if respond_to?(:config)
12
- config ||= Rails.application.config
13
- controller = self.controller if respond_to?(:controller)
14
11
  paths = RailsHelper::AssetPaths.new(config, controller)
15
12
  paths.asset_environment = asset_environment
16
13
  paths.asset_digests = asset_digests
@@ -131,6 +128,8 @@ module Sprockets
131
128
  return nil if is_uri?(source)
132
129
  source = rewrite_extension(source, nil, ext)
133
130
  asset_environment[source]
131
+ rescue Sprockets::FileOutsidePaths
132
+ nil
134
133
  end
135
134
 
136
135
  def digest_for(logical_path)
@@ -1,3 +1,5 @@
1
+ require "action_controller/railtie"
2
+
1
3
  module Sprockets
2
4
  autoload :Bootstrap, "sprockets/bootstrap"
3
5
  autoload :Helpers, "sprockets/helpers"
@@ -7,13 +9,13 @@ module Sprockets
7
9
 
8
10
  # TODO: Get rid of config.assets.enabled
9
11
  class Railtie < ::Rails::Railtie
10
- config.default_asset_host_protocol = :relative
12
+ config.action_controller.default_asset_host_protocol = :relative
11
13
 
12
14
  rake_tasks do
13
15
  load "sprockets/assets.rake"
14
16
  end
15
17
 
16
- initializer "sprockets.environment", :group => :assets do |app|
18
+ initializer "sprockets.environment", :group => :all do |app|
17
19
  config = app.config
18
20
  next unless config.assets.enabled
19
21
 
@@ -40,8 +42,8 @@ module Sprockets
40
42
 
41
43
  ActiveSupport.on_load(:action_view) do
42
44
  include ::Sprockets::Helpers::RailsHelper
43
-
44
45
  app.assets.context_class.instance_eval do
46
+ include ::Sprockets::Helpers::IsolatedHelper
45
47
  include ::Sprockets::Helpers::RailsHelper
46
48
  end
47
49
  end
@@ -2,41 +2,50 @@ require 'fileutils'
2
2
 
3
3
  module Sprockets
4
4
  class StaticCompiler
5
- attr_accessor :env, :target, :digest
5
+ attr_accessor :env, :target, :paths
6
6
 
7
- def initialize(env, target, options = {})
7
+ def initialize(env, target, paths, options = {})
8
8
  @env = env
9
9
  @target = target
10
+ @paths = paths
10
11
  @digest = options.key?(:digest) ? options.delete(:digest) : true
12
+ @manifest = options.key?(:manifest) ? options.delete(:manifest) : true
13
+ @manifest_path = options.delete(:manifest_path) || target
11
14
  end
12
15
 
13
- def precompile(paths)
14
- Rails.application.config.assets.digest = digest
16
+ def compile
15
17
  manifest = {}
16
-
17
18
  env.each_logical_path do |logical_path|
18
- next unless precompile_path?(logical_path, paths)
19
+ next unless compile_path?(logical_path)
19
20
  if asset = env.find_asset(logical_path)
20
- manifest[logical_path] = compile(asset)
21
+ manifest[logical_path] = write_asset(asset)
21
22
  end
22
23
  end
23
- manifest
24
+ write_manifest(manifest) if @manifest
24
25
  end
25
26
 
26
- def compile(asset)
27
- asset_path = digest_asset(asset)
28
- filename = File.join(target, asset_path)
29
- FileUtils.mkdir_p File.dirname(filename)
30
- asset.write_to(filename)
31
- asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
32
- asset_path
27
+ def write_manifest(manifest)
28
+ FileUtils.mkdir_p(@manifest_path)
29
+ File.open("#{@manifest_path}/manifest.yml", 'wb') do |f|
30
+ YAML.dump(manifest, f)
31
+ end
32
+ end
33
+
34
+ def write_asset(asset)
35
+ path_for(asset).tap do |path|
36
+ filename = File.join(target, path)
37
+ FileUtils.mkdir_p File.dirname(filename)
38
+ asset.write_to(filename)
39
+ asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
40
+ end
33
41
  end
34
42
 
35
- def precompile_path?(logical_path, paths)
43
+ def compile_path?(logical_path)
36
44
  paths.each do |path|
37
- if path.is_a?(Regexp)
45
+ case path
46
+ when Regexp
38
47
  return true if path.match(logical_path)
39
- elsif path.is_a?(Proc)
48
+ when Proc
40
49
  return true if path.call(logical_path)
41
50
  else
42
51
  return true if File.fnmatch(path.to_s, logical_path)
@@ -45,8 +54,8 @@ module Sprockets
45
54
  false
46
55
  end
47
56
 
48
- def digest_asset(asset)
49
- digest ? asset.digest_path : asset.logical_path
57
+ def path_for(asset)
58
+ @digest ? asset.digest_path : asset.logical_path
50
59
  end
51
60
  end
52
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940595
4
+ hash: 977940592
5
5
  prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
9
  - 1
10
- - rc2
11
- version: 3.1.1.rc2
10
+ - rc3
11
+ version: 3.1.1.rc3
12
12
  platform: ruby
13
13
  authors:
14
14
  - David Heinemeier Hansson
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-29 00:00:00 -03:00
19
+ date: 2011-10-05 00:00:00 -02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,13 +27,13 @@ dependencies:
27
27
  requirements:
28
28
  - - "="
29
29
  - !ruby/object:Gem::Version
30
- hash: 977940595
30
+ hash: 977940592
31
31
  segments:
32
32
  - 3
33
33
  - 1
34
34
  - 1
35
- - rc2
36
- version: 3.1.1.rc2
35
+ - rc3
36
+ version: 3.1.1.rc3
37
37
  type: :runtime
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -44,13 +44,13 @@ dependencies:
44
44
  requirements:
45
45
  - - "="
46
46
  - !ruby/object:Gem::Version
47
- hash: 977940595
47
+ hash: 977940592
48
48
  segments:
49
49
  - 3
50
50
  - 1
51
51
  - 1
52
- - rc2
53
- version: 3.1.1.rc2
52
+ - rc3
53
+ version: 3.1.1.rc3
54
54
  type: :runtime
55
55
  version_requirements: *id002
56
56
  - !ruby/object:Gem::Dependency
@@ -61,12 +61,11 @@ dependencies:
61
61
  requirements:
62
62
  - - ~>
63
63
  - !ruby/object:Gem::Version
64
- hash: 17
64
+ hash: 13
65
65
  segments:
66
66
  - 1
67
- - 0
68
- - 3
69
- version: 1.0.3
67
+ - 1
68
+ version: "1.1"
70
69
  type: :runtime
71
70
  version_requirements: *id003
72
71
  - !ruby/object:Gem::Dependency
@@ -156,12 +155,12 @@ dependencies:
156
155
  requirements:
157
156
  - - ~>
158
157
  - !ruby/object:Gem::Version
159
- hash: 15
158
+ hash: 11
160
159
  segments:
161
160
  - 2
162
161
  - 0
163
- - 0
164
- version: 2.0.0
162
+ - 2
163
+ version: 2.0.2
165
164
  type: :runtime
166
165
  version_requirements: *id009
167
166
  - !ruby/object:Gem::Dependency
@@ -388,6 +387,7 @@ files:
388
387
  - lib/sprockets/assets.rake
389
388
  - lib/sprockets/bootstrap.rb
390
389
  - lib/sprockets/compressors.rb
390
+ - lib/sprockets/helpers/isolated_helper.rb
391
391
  - lib/sprockets/helpers/rails_helper.rb
392
392
  - lib/sprockets/helpers.rb
393
393
  - lib/sprockets/railtie.rb