Hello community,
here is the log from the commit of package rubygem-sprockets-rails for
openSUSE:Factory checked in at 2016-04-28 16:52:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-sprockets-rails (Old)
and /work/SRC/openSUSE:Factory/.rubygem-sprockets-rails.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-sprockets-rails"
Changes:
--------
---
/work/SRC/openSUSE:Factory/rubygem-sprockets-rails/rubygem-sprockets-rails.changes
2015-09-19 09:54:45.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-sprockets-rails.new/rubygem-sprockets-rails.changes
2016-04-28 16:53:03.000000000 +0200
@@ -1,0 +2,30 @@
+Thu Mar 3 05:30:36 UTC 2016 - [email protected]
+
+- updated to version 3.0.4
+ no changelog found
+
+-------------------------------------------------------------------
+Wed Mar 2 05:38:23 UTC 2016 - [email protected]
+
+- updated to version 3.0.3
+ no changelog found
+
+-------------------------------------------------------------------
+Wed Feb 24 05:44:53 UTC 2016 - [email protected]
+
+- updated to version 3.0.2
+ no changelog found
+
+-------------------------------------------------------------------
+Fri Jan 29 05:35:07 UTC 2016 - [email protected]
+
+- updated to version 3.0.1
+ no changelog found
+
+-------------------------------------------------------------------
+Fri Dec 18 05:39:37 UTC 2015 - [email protected]
+
+- updated to version 3.0.0
+ no changelog found
+
+-------------------------------------------------------------------
Old:
----
sprockets-rails-2.3.3.gem
New:
----
sprockets-rails-3.0.4.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-sprockets-rails.spec ++++++
--- /var/tmp/diff_new_pack.7K2CNK/_old 2016-04-28 16:53:04.000000000 +0200
+++ /var/tmp/diff_new_pack.7K2CNK/_new 2016-04-28 16:53:04.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-sprockets-rails
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,13 +24,13 @@
#
Name: rubygem-sprockets-rails
-Version: 2.3.3
+Version: 3.0.4
Release: 0
%define mod_name sprockets-rails
%define mod_full_name %{mod_name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
+BuildRequires: %{ruby >= 1.9.3}
BuildRequires: %{rubygem gem2rpm}
-BuildRequires: %{ruby}
BuildRequires: ruby-macros >= 5
Url: https://github.com/rails/sprockets-rails
Source: http://rubygems.org/gems/%{mod_full_name}.gem
@@ -48,7 +48,7 @@
%install
%gem_install \
- --doc-files="LICENSE README.md" \
+ --doc-files="MIT-LICENSE README.md" \
-f
%gem_packages
++++++ sprockets-rails-2.3.3.gem -> sprockets-rails-3.0.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/LICENSE new/LICENSE
--- old/LICENSE 2015-09-08 03:29:27.000000000 +0200
+++ new/LICENSE 1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
-Copyright (c) 2014 Joshua Peek
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/MIT-LICENSE new/MIT-LICENSE
--- old/MIT-LICENSE 1970-01-01 01:00:00.000000000 +0100
+++ new/MIT-LICENSE 2016-03-02 18:18:46.000000000 +0100
@@ -0,0 +1,20 @@
+Copyright (c) 2014-2016 Joshua Peek
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2015-09-08 03:29:27.000000000 +0200
+++ new/README.md 2016-03-02 18:18:46.000000000 +0100
@@ -27,7 +27,7 @@
**`rake assets:clobber`**
-Nuke `public/assets` and clear the Sprockets file system cache.
+Nuke `public/assets`.
#### Customize
@@ -37,11 +37,6 @@
``` ruby
require 'sprockets/rails/task'
-# clean the old tasks
-Rake::Task["assets:environment"].clear
-Rake::Task["assets:precompile"].clear
-Rake::Task["assets:clean"].clear
-Rake::Task["assets:clobber"].clear
Sprockets::Rails::Task.new(Rails.application) do |t|
t.environment = lambda { Rails.application.assets }
t.assets = %w( application.js application.css )
@@ -51,7 +46,7 @@
Each asset task will invoke `assets:environment` first. By default this loads
the Rails environment. You can override this task to add or remove dependencies
for your specific compilation environment.
-Also see
[Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/task.rb)
and
[Rake::SprocketsTask](https://github.com/sstephenson/sprockets/blob/master/lib/rake/sprocketstask.rb).
+Also see
[Sprockets::Rails::Task](https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/task.rb)
and
[Rake::SprocketsTask](https://github.com/rails/sprockets/blob/master/lib/rake/sprocketstask.rb).
### Initializer options
@@ -60,10 +55,6 @@
Add additional assets to compile on deploy. Defaults to `application.js`,
`application.css` and any other non-js/css file under `app/assets`.
-**`config.assets.raise_runtime_errors`**
-
-Set to `true` to enable additional runtime error checking. Recommended in the
`development` environment to minimize unexpected behavior when deploying to
`production`.
-
**`config.assets.paths`**
Add additional load paths to this Array. Rails includes `app/assets`,
`lib/assets` and `vendor/assets` for you already. Plugins might want to add
their custom paths to this.
@@ -83,13 +74,9 @@
Defaults to `/assets`. Changes the directory to compile assets to.
-**`config.assets.manifest`**
-
-Defines the full path to be used for the asset precompiler's manifest file.
Defaults to a randomly-generated filename in the `config.assets.prefix`
directory within the public folder.
-
**`config.assets.digest`**
-Link to undigest asset filenames. This option will eventually go away. Unless
when `compile` is disabled.
+When enabled, fingerprints will be added to asset filenames.
**`config.assets.debug`**
@@ -97,7 +84,7 @@
**`config.assets.compile`**
-Enables Sprockets compile environment. If disabled, `Rails.application.assets`
will be unavailable to any ActionView helpers. View helpers will depend on
assets being precompiled to `public/assets` in order to link to them. You can
still access the environment by directly calling `Rails.application.assets`.
+Enables Sprockets compile environment. If disabled, `Rails.application.assets`
will be `nil` to prevent inadvertent compilation calls. View helpers will
depend on assets being precompiled to `public/assets` in order to link to them.
Initializers expecting `Rails.application.assets` during boot should be
accessing the environment in a `config.assets.configure` block. See below.
**`config.assets.configure`**
@@ -105,18 +92,34 @@
``` ruby
config.assets.configure do |env|
- env.js_compressor = :uglify # or :closure, :yui
+ env.js_compressor = :uglifier # or :closure, :yui
env.css_compressor = :sass # or :yui
require 'my_processor'
env.register_preprocessor 'application/javascript', MyProcessor
env.logger = Rails.logger
-
- env.cache = ActiveSupport::Cache::FileStore.new("tmp/cache/assets")
end
```
+**`config.assets.resolve_with`**
+
+A list of `:environment` and `:manifest` symbols that defines the order that
+we try to find assets: manifest first, environment second? Manifest only?
+
+By default, we check the manifest first if asset digests are enabled and debug
+is not enabled, then we check the environment if compiling is enabled:
+```
+# Dev where debug is true, or digests are disabled
+%i[ environment ]
+
+# Dev default, or production with compile enabled.
+%i[ manifest environment ]
+
+# Production default.
+%i[ manifest ]
+```
+If the resolver list is empty (e.g. if debug is true and compile is false),
the standard rails public path resolution will be used.
## Complementary plugins
@@ -132,29 +135,33 @@
* Only compiles digest filenames. Static non-digest assets should simply live
in public/.
* Unmanaged asset paths and urls fallback to linking to public/. This should
make it easier to work with both compiled assets and simple static assets. As a
side effect, there will never be any "asset not precompiled errors" when
linking to missing assets. They will just link to a public file which may or
may not exist.
-* JS and CSS compressors must be explicitly set. Magic detection has been
removed to avoid loading compressors in environments where you want to avoid
loading any of the asset libraries. Assign `config.assets.js_compressor =
:uglify` or `config.assets.css_compressor = :sass` for the standard compressors.
+* JS and CSS compressors must be explicitly set. Magic detection has been
removed to avoid loading compressors in environments where you want to avoid
loading any of the asset libraries. Assign `config.assets.js_compressor =
:uglifier` or `config.assets.css_compressor = :sass` for the standard
compressors.
* The manifest file is now in a JSON format. Since it lives in public/ by
default, the initial filename is also randomized to obfuscate public access to
the resource.
* `config.assets.manifest` (if used) must now include the manifest filename,
e.g. `Rails.root.join('config/manifest.json')`. It cannot be a directory.
* Two cleanup tasks. `rake assets:clean` is now a safe cleanup that only
removes older assets that are no longer used. While `rake assets:clobber` nukes
the entire `public/assets` directory and clears your filesystem cache. The
clean task allows for rolling deploys that may still be linking to an old asset
while the new assets are being built.
+## Experimental
-## Contributing
+### [SRI](http://www.w3.org/TR/SRI/) support
-Usual bundler workflow.
+Sprockets 3.x adds experimental support for subresource integrity checks. The
spec is still evolving and the API may change in backwards incompatible ways.
-``` shell
-$ git clone https://github.com/rails/sprockets-rails.git
-$ cd sprockets-rails/
-$ bundle install
-$ bundle exec rake test
+``` ruby
+javascript_include_tag :application, integrity: true
+# => "<script src="/assets/application.js"
integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
```
-[](http://travis-ci.org/rails/sprockets-rails)
+## Contributing to Sprockets Rails
+
+Sprockets Rails is work of many contributors. You're encouraged to submit pull
requests, propose
+features and discuss issues.
+
+See [CONTRIBUTING](CONTRIBUTING.md).
## Releases
-sprockets-rails 2.x will primarily target sprockets 2.x with future
compatibility for 3.x. Consider upgrading to sprockets-rails 3.x to take full
advantage of 3.x features.
+sprockets-rails 3.x will primarily target sprockets 3.x. And future versions
will target the corresponding sprockets release line.
The minor and patch version will be updated according to
[semver](http://semver.org/).
@@ -162,9 +169,12 @@
* Any time the sprockets dependency is bumped, there will be a new minor
release
* Simple bug fixes will be patch releases
-
## License
-Copyright © 2014 Joshua Peek.
+Sprockets Rails is released under the [MIT License](MIT-LICENSE).
+
+## Code Status
-Released under the MIT license. See `LICENSE` for details.
+* [](http://travis-ci.org/rails/sprockets-rails)
+* [](http://badge.fury.io/rb/sprockets-rails)
+*
[](https://gemnasium.com/rails/sprockets-rails)
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/context.rb
new/lib/sprockets/rails/context.rb
--- old/lib/sprockets/rails/context.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/sprockets/rails/context.rb 2016-03-02 18:18:46.000000000 +0100
@@ -0,0 +1,48 @@
+require 'action_view'
+require 'sprockets'
+
+module Sprockets
+ module Rails
+ module Context
+ include ActionView::Helpers::AssetUrlHelper
+ include ActionView::Helpers::AssetTagHelper
+
+ def self.included(klass)
+ klass.class_eval do
+ class_attribute :config, :assets_prefix, :digest_assets
+ end
+ end
+
+ def compute_asset_path(path, options = {})
+ @dependencies << 'actioncontroller-asset-url-config'
+
+ begin
+ asset_uri = resolve(path)
+ rescue FileNotFound
+ # TODO: eh, we should be able to use a form of locate that returns
+ # nil instead of raising an exception.
+ end
+
+ if asset_uri
+ asset = link_asset(path)
+ digest_path = asset.digest_path
+ path = digest_path if digest_assets
+ File.join(assets_prefix || "/", path)
+ else
+ super
+ end
+ end
+ end
+ end
+
+ register_dependency_resolver 'actioncontroller-asset-url-config' do |env|
+ config = env.context_class.config
+ [config.relative_url_root,
+ (config.asset_host unless config.asset_host.respond_to?(:call))]
+ end
+
+ # fallback to the default pipeline when using Sprockets 3.x
+ unless config[:pipelines].include? :debug
+ register_pipeline :debug, config[:pipelines][:default]
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/helper.rb
new/lib/sprockets/rails/helper.rb
--- old/lib/sprockets/rails/helper.rb 2015-09-08 03:29:27.000000000 +0200
+++ new/lib/sprockets/rails/helper.rb 2016-03-02 18:18:46.000000000 +0100
@@ -1,128 +1,118 @@
require 'action_view'
require 'sprockets'
require 'active_support/core_ext/class/attribute'
+require 'sprockets/rails/utils'
module Sprockets
module Rails
module Helper
- class << self
- attr_accessor :precompile, :assets, :raise_runtime_errors
- end
-
- def precompile
- Sprockets::Rails::Helper.precompile
- end
-
- def assets
- Sprockets::Rails::Helper.assets
- end
-
- def raise_runtime_errors
- Sprockets::Rails::Helper.raise_runtime_errors
- end
-
- class AssetFilteredError < StandardError
+ class AssetNotPrecompiled < StandardError
+ include Sprockets::Rails::Utils
def initialize(source)
- msg = "Asset filtered out and will not be served: " <<
- "add `Rails.application.config.assets.precompile += %w(
#{source} )` " <<
- "to `config/initializers/assets.rb` and restart your server"
- super(msg)
- end
- end
-
- class AbsoluteAssetPathError < ArgumentError
- def initialize(bad_path, good_path, prefix)
- msg = "Asset names passed to helpers should not include the
#{prefix.inspect} prefix. " <<
- "Instead of #{bad_path.inspect}, use #{good_path.inspect}"
+ msg =
+ if using_sprockets4?
+ "Asset `#{source}` was not declared to be precompiled in
production.\n" +
+ "Declare links to your assets in `assets/config/manifest.js`.\n" +
+ "Examples:\n" +
+ "`//= link ../javascripts/application.js`\n" +
+ "`//= link_directory ../javascripts .js`\n" +
+ "`//= link_directory ../stylesheets .css`\n" +
+ "`//= link_tree ../javascripts .js`\n" +
+ "`//= link_tree ../images`\n"
+ else
+ "Asset was not declared to be precompiled in production.\n" +
+ "Add `Rails.application.config.assets.precompile += " +
+ "%w( #{source} )` to `config/initializers/assets.rb` and " +
+ "restart your server"
+ end
super(msg)
end
end
- if defined? ActionView::Helpers::AssetUrlHelper
- include ActionView::Helpers::AssetUrlHelper
- include ActionView::Helpers::AssetTagHelper
- else
- require 'sprockets/rails/legacy_asset_tag_helper'
- require 'sprockets/rails/legacy_asset_url_helper'
- include LegacyAssetTagHelper
- include LegacyAssetUrlHelper
- end
-
- VIEW_ACCESSORS = [:assets_environment, :assets_manifest,
- :assets_prefix, :digest_assets, :debug_assets]
+ include ActionView::Helpers::AssetUrlHelper
+ include ActionView::Helpers::AssetTagHelper
+ include Sprockets::Rails::Utils
+
+ VIEW_ACCESSORS = [
+ :assets_environment, :assets_manifest,
+ :assets_precompile, :precompiled_asset_checker,
+ :assets_prefix, :digest_assets, :debug_assets,
+ :resolve_assets_with
+ ]
def self.included(klass)
- if klass < Sprockets::Context
- klass.class_eval do
- alias_method :assets_environment, :environment
- def assets_manifest; end
- class_attribute :config, :assets_prefix, :digest_assets,
:debug_assets
+ klass.class_attribute(*VIEW_ACCESSORS)
+
+ klass.class_eval do
+ remove_method :assets_environment
+ def assets_environment
+ if instance_variable_defined?(:@assets_environment)
+ @assets_environment = @assets_environment.cached
+ elsif env = self.class.assets_environment
+ @assets_environment = env.cached
+ else
+ nil
+ end
end
- else
- klass.class_attribute(*VIEW_ACCESSORS)
end
end
def self.extended(obj)
obj.class_eval do
attr_accessor(*VIEW_ACCESSORS)
+
+ remove_method :assets_environment
+ def assets_environment
+ if env = @assets_environment
+ @assets_environment = env.cached
+ else
+ nil
+ end
+ end
end
end
def compute_asset_path(path, options = {})
- # Check if we are inside Sprockets context before calling
check_dependencies!.
- check_dependencies!(path) if defined?(depend_on)
+ debug = options[:debug]
- if digest_path = asset_digest_path(path)
- path = digest_path if digest_assets
- path += "?body=1" if options[:debug]
- File.join(assets_prefix || "/", path)
+ if asset_path = resolve_asset_path(path, debug)
+ File.join(assets_prefix || "/", legacy_debug_path(asset_path, debug))
else
super
end
end
- # Computes the full URL to a asset in the public directory. This
- # method checks for errors before returning path.
- def asset_path(source, options = {})
- unless options[:debug]
- check_errors_for(source, options)
+ # Resolve the asset path against the Sprockets manifest or environment.
+ # Returns nil if it's an asset we don't know about.
+ def resolve_asset_path(path, allow_non_precompiled = false) #:nodoc:
+ resolve_asset do |resolver|
+ resolver.asset_path path, digest_assets, allow_non_precompiled
end
- super(source, options)
end
- alias :path_to_asset :asset_path
- # Get digest for asset path.
+ # Expand asset path to digested form.
#
# path - String path
# options - Hash options
#
- # Returns String Hex digest or nil if digests are disabled.
- def asset_digest(path, options = {})
- return unless digest_assets
-
- if digest_path = asset_digest_path(path, options)
- digest_path[/-(.+)\./, 1]
+ # Returns String path or nil if no asset was found.
+ def asset_digest_path(path, options = {})
+ resolve_asset do |resolver|
+ resolver.digest_path path, options[:debug]
end
end
- # Expand asset path to digested form.
+ # Experimental: Get integrity for asset path.
#
# path - String path
# options - Hash options
#
- # Returns String path or nil if no asset was found.
- def asset_digest_path(path, options = {})
- if manifest = assets_manifest
- if digest_path = manifest.assets[path]
- return digest_path
- end
- end
+ # Returns String integrity attribute or nil if no asset was found.
+ def asset_integrity(path, options = {})
+ path = path_with_extname(path, options)
- if environment = assets_environment
- if asset = environment[path]
- return asset.digest_path
- end
+ resolve_asset do |resolver|
+ resolver.integrity path
end
end
@@ -131,21 +121,27 @@
# Eventually will be deprecated and replaced by source maps.
def javascript_include_tag(*sources)
options = sources.extract_options!.stringify_keys
+ integrity = compute_integrity?(options)
if options["debug"] != false && request_debug_assets?
sources.map { |source|
- check_errors_for(source, :type => :javascript)
- if asset = lookup_asset_for_path(source, :type => :javascript)
- asset.to_a.map do |a|
- super(path_to_javascript(a.logical_path, :debug => true),
options)
+ if asset = lookup_debug_asset(source, type: :javascript)
+ if asset.respond_to?(:to_a)
+ asset.to_a.map do |a|
+ super(path_to_javascript(a.logical_path, debug: true),
options)
+ end
+ else
+ super(path_to_javascript(asset.logical_path, debug: true),
options)
end
else
super(source, options)
end
}.flatten.uniq.join("\n").html_safe
else
- sources.push(options)
- super(*sources)
+ sources.map { |source|
+ options = options.merge('integrity' => asset_integrity(source,
type: :javascript)) if integrity
+ super source, options
+ }.join("\n").html_safe
end
end
@@ -154,81 +150,205 @@
# Eventually will be deprecated and replaced by source maps.
def stylesheet_link_tag(*sources)
options = sources.extract_options!.stringify_keys
+ integrity = compute_integrity?(options)
+
if options["debug"] != false && request_debug_assets?
sources.map { |source|
- check_errors_for(source, :type => :stylesheet)
- if asset = lookup_asset_for_path(source, :type => :stylesheet)
- asset.to_a.map do |a|
- super(path_to_stylesheet(a.logical_path, :debug => true),
options)
+ if asset = lookup_debug_asset(source, type: :stylesheet)
+ if asset.respond_to?(:to_a)
+ asset.to_a.map do |a|
+ super(path_to_stylesheet(a.logical_path, debug: true),
options)
+ end
+ else
+ super(path_to_stylesheet(asset.logical_path, debug: true),
options)
end
else
super(source, options)
end
}.flatten.uniq.join("\n").html_safe
else
- sources.push(options)
- super(*sources)
+ sources.map { |source|
+ options = options.merge('integrity' => asset_integrity(source,
type: :stylesheet)) if integrity
+ super source, options
+ }.join("\n").html_safe
end
end
protected
- # Ensures the asset is included in the dependencies list.
- def check_dependencies!(dep)
- depend_on(dep)
- depend_on_asset(dep)
- rescue Sprockets::FileNotFound
+ # This is awkward: `integrity` is a boolean option indicating whether
+ # we want to include or omit the subresource integrity hash, but the
+ # options hash is also passed through as literal tag attributes.
+ # That means we have to delete the shortcut boolean option so it
+ # doesn't bleed into the tag attributes, but also check its value if
+ # it's boolean-ish.
+ def compute_integrity?(options)
+ if secure_subresource_integrity_context?
+ case options['integrity']
+ when nil, false, true
+ options.delete('integrity') == true
+ end
+ else
+ options.delete 'integrity'
+ false
+ end
end
- # Raise errors when source is not in the precompiled list, or
- # incorrectly contains the assets_prefix.
- def check_errors_for(source, options)
- return unless self.raise_runtime_errors
+ # Only serve integrity metadata for HTTPS requests:
+ # http://www.w3.org/TR/SRI/#non-secure-contexts-remain-non-secure
+ def secure_subresource_integrity_context?
+ respond_to?(:request) && self.request && self.request.ssl?
+ end
- source = source.to_s
- return if source.blank? || source =~ URI_REGEXP
+ # Enable split asset debugging. Eventually will be deprecated
+ # and replaced by source maps in Sprockets 3.x.
+ def request_debug_assets?
+ debug_assets || (defined?(controller) && controller &&
params[:debug_assets])
+ rescue # FIXME: what exactly are we rescuing?
+ false
+ end
- asset = lookup_asset_for_path(source, options)
+ # Internal method to support multifile debugging. Will
+ # eventually be removed w/ Sprockets 3.x.
+ def lookup_debug_asset(path, options = {})
+ path = path_with_extname(path, options)
- if asset && asset_needs_precompile?(asset.logical_path,
asset.pathname.to_s)
- raise AssetFilteredError.new(asset.logical_path)
+ resolve_asset do |resolver|
+ resolver.find_debug_asset path
end
+ end
+
+ # compute_asset_extname is in AV::Helpers::AssetUrlHelper
+ def path_with_extname(path, options)
+ path = path.to_s
+ "#{path}#{compute_asset_extname(path, options)}"
+ end
- full_prefix = File.join(self.assets_prefix || "/", '')
- if !asset && source.start_with?(full_prefix)
- short_path = source[full_prefix.size, source.size]
- if lookup_asset_for_path(short_path, options)
- raise AbsoluteAssetPathError.new(source, short_path, full_prefix)
+ # Try each asset resolver and return the first non-nil result.
+ def resolve_asset
+ asset_resolver_strategies.detect do |resolver|
+ if result = yield(resolver)
+ break result
end
end
end
- # Returns true when an asset will not be available after precompile is
run
- def asset_needs_precompile?(source, filename)
- if assets_environment && assets_environment.send(:matches_filter,
precompile || [], source, filename)
- false
+ # List of resolvers in `config.assets.resolve_with` order.
+ def asset_resolver_strategies
+ @asset_resolver_strategies ||=
+ Array(resolve_assets_with).map do |name|
+ HelperAssetResolvers[name].new(self)
+ end
+ end
+
+ # Append ?body=1 if debug is on and we're on old Sprockets.
+ def legacy_debug_path(path, debug)
+ if debug && !using_sprockets4?
+ "#{path}?body=1"
else
- true
+ path
end
end
+ end
- # Enable split asset debugging. Eventually will be deprecated
- # and replaced by source maps in Sprockets 3.x.
- def request_debug_assets?
- debug_assets || (defined?(controller) && controller &&
params[:debug_assets])
- rescue
- return false
+ # Use a separate module since Helper is mixed in and we needn't pollute
+ # the class namespace with our internals.
+ module HelperAssetResolvers #:nodoc:
+ def self.[](name)
+ case name
+ when :manifest
+ Manifest
+ when :environment
+ Environment
+ else
+ raise ArgumentError, "Unrecognized asset resolver: #{name.inspect}.
Expected :manifest or :environment"
end
+ end
- # Internal method to support multifile debugging. Will
- # eventually be removed w/ Sprockets 3.x.
- def lookup_asset_for_path(path, options = {})
- return unless env = assets_environment
- path = path.to_s
- if extname = compute_asset_extname(path, options)
- path = "#{path}#{extname}"
+ class Manifest #:nodoc:
+ def initialize(view)
+ @manifest = view.assets_manifest
+ raise ArgumentError, 'config.assets.resolve_with includes :manifest,
but app.assets_manifest is nil' unless @manifest
+ end
+
+ def asset_path(path, digest, allow_non_precompiled = false)
+ if digest
+ digest_path path, allow_non_precompiled
+ end
+ end
+
+ def digest_path(path, allow_non_precompiled = false)
+ @manifest.assets[path]
+ end
+
+ def integrity(path)
+ if meta = metadata(path)
+ meta["integrity"]
end
- env[path]
end
+
+ def find_debug_asset(path)
+ nil
+ end
+
+ private
+ def metadata(path)
+ if digest_path = digest_path(path)
+ @manifest.files[digest_path]
+ end
+ end
+ end
+
+ class Environment #:nodoc:
+ def initialize(view)
+ raise ArgumentError, 'config.assets.resolve_with includes
:environment, but app.assets is nil' unless view.assets_environment
+ @env = view.assets_environment
+ @precompiled_asset_checker = view.precompiled_asset_checker
+ end
+
+ def asset_path(path, digest, allow_non_precompiled = false)
+ # Digests enabled? Do the work to calculate the full asset path.
+ if digest
+ digest_path path, allow_non_precompiled
+
+ # Otherwise, ask the Sprockets environment whether the asset exists
+ # and check whether it's also precompiled for production deploys.
+ elsif asset = find_asset(path)
+ raise_unless_precompiled_asset asset.logical_path unless
allow_non_precompiled
+ path
+ end
+ end
+
+ def digest_path(path, allow_non_precompiled = false)
+ if asset = find_asset(path)
+ raise_unless_precompiled_asset asset.logical_path unless
allow_non_precompiled
+ asset.digest_path
+ end
+ end
+
+ def integrity(path)
+ find_asset(path).try :integrity
+ end
+
+ def find_debug_asset(path)
+ if asset = find_asset(path, pipeline: :debug)
+ raise_unless_precompiled_asset asset.logical_path.sub('.debug', '')
+ asset
+ end
+ end
+
+ private
+ def find_asset(path, options = {})
+ @env[path, options]
+ end
+
+ def precompiled?(path)
+ @precompiled_asset_checker.call path
+ end
+
+ def raise_unless_precompiled_asset(path)
+ raise Helper::AssetNotPrecompiled.new(path) unless
precompiled?(path)
+ end
+ end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/legacy_asset_tag_helper.rb
new/lib/sprockets/rails/legacy_asset_tag_helper.rb
--- old/lib/sprockets/rails/legacy_asset_tag_helper.rb 2015-09-08
03:29:27.000000000 +0200
+++ new/lib/sprockets/rails/legacy_asset_tag_helper.rb 1970-01-01
01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-require 'sprockets'
-
-module Sprockets
- module Rails
- # Backports of AssetTagHelper methods for Rails 2.x and 3.x.
- module LegacyAssetTagHelper
- include ActionView::Helpers::TagHelper
-
- def javascript_include_tag(*sources)
- options = sources.extract_options!.stringify_keys
- sources.uniq.map { |source|
- tag_options = {
- "src" => path_to_javascript(source)
- }.merge(options)
- content_tag(:script, "", tag_options)
- }.join("\n").html_safe
- end
-
- def stylesheet_link_tag(*sources)
- options = sources.extract_options!.stringify_keys
- sources.uniq.map { |source|
- tag_options = {
- "rel" => "stylesheet",
- "media" => "screen",
- "href" => path_to_stylesheet(source)
- }.merge(options)
- tag(:link, tag_options)
- }.join("\n").html_safe
- end
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/legacy_asset_url_helper.rb
new/lib/sprockets/rails/legacy_asset_url_helper.rb
--- old/lib/sprockets/rails/legacy_asset_url_helper.rb 2015-09-08
03:29:27.000000000 +0200
+++ new/lib/sprockets/rails/legacy_asset_url_helper.rb 1970-01-01
01:00:00.000000000 +0100
@@ -1,133 +0,0 @@
-require 'sprockets'
-
-module Sprockets
- module Rails
- # Backports of AssetUrlHelper methods for Rails 2.x and 3.x.
- module LegacyAssetUrlHelper
- URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}
-
- def asset_path(source, options = {})
- source = source.to_s
- return "" unless source.present?
- return source if source =~ URI_REGEXP
-
- tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
-
- if extname = compute_asset_extname(source, options)
- source = "#{source}#{extname}"
- end
-
- if source[0] != ?/
- source = compute_asset_path(source, options)
- end
-
- relative_url_root = defined?(config.relative_url_root) &&
config.relative_url_root
- if relative_url_root
- source = "#{relative_url_root}#{source}" unless
source.starts_with?("#{relative_url_root}/")
- end
-
- if host = compute_asset_host(source, options)
- source = "#{host}#{source}"
- end
-
- "#{source}#{tail}"
- end
- alias_method :path_to_asset, :asset_path
-
- def asset_url(source, options = {})
- path_to_asset(source, options.merge(:protocol => :request))
- end
-
- ASSET_EXTENSIONS = {
- :javascript => '.js',
- :stylesheet => '.css'
- }
-
- def compute_asset_extname(source, options = {})
- return if options[:extname] == false
- extname = options[:extname] || ASSET_EXTENSIONS[options[:type]]
- extname if extname && File.extname(source) != extname
- end
-
- ASSET_PUBLIC_DIRECTORIES = {
- :audio => '/audios',
- :font => '/fonts',
- :image => '/images',
- :javascript => '/javascripts',
- :stylesheet => '/stylesheets',
- :video => '/videos'
- }
-
- def compute_asset_path(source, options = {})
- dir = ASSET_PUBLIC_DIRECTORIES[options[:type]] || ""
- File.join(dir, source)
- end
-
- def compute_asset_host(source = "", options = {})
- request = self.request if respond_to?(:request)
-
- if defined? config
- host = config.asset_host
- elsif defined? ActionController::Base.asset_host
- host = ActionController::Base.asset_host
- end
-
- host ||= request.base_url if request && options[:protocol] == :request
- return unless host
-
- if host.respond_to?(:call)
- arity = host.respond_to?(:arity) ? host.arity :
host.method(:call).arity
- args = [source]
- args << request if request && (arity > 1 || arity < 0)
- host = host.call(*args)
- elsif host =~ /%d/
- host = host % (Zlib.crc32(source) % 4)
- end
-
- if host =~ URI_REGEXP
- host
- else
- protocol = options[:protocol] || (request ? :request : :relative)
- case protocol
- when :relative
- "//#{host}"
- when :request
- "#{request.protocol}#{host}"
- else
- "#{protocol}://#{host}"
- end
- end
- end
-
- def javascript_path(source, options = {})
- path_to_asset(source, {:type => :javascript}.merge(options))
- end
- alias_method :path_to_javascript, :javascript_path
-
- def stylesheet_path(source, options = {})
- path_to_asset(source, {:type => :stylesheet}.merge(options))
- end
- alias_method :path_to_stylesheet, :stylesheet_path
-
- def image_path(source, options = {})
- path_to_asset(source, {:type => :image}.merge(options))
- end
- alias_method :path_to_image, :image_path
-
- def video_path(source, options = {})
- path_to_asset(source, {:type => :video}.merge(options))
- end
- alias_method :path_to_video, :video_path
-
- def audio_path(source, options = {})
- path_to_asset(source, {:type => :audio}.merge(options))
- end
- alias_method :path_to_audio, :audio_path
-
- def font_path(source, options = {})
- path_to_asset(source, {:type => :font}.merge(options))
- end
- alias_method :path_to_font, :font_path
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/route_wrapper.rb
new/lib/sprockets/rails/route_wrapper.rb
--- old/lib/sprockets/rails/route_wrapper.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/lib/sprockets/rails/route_wrapper.rb 2016-03-02 18:18:46.000000000
+0100
@@ -0,0 +1,23 @@
+module Sprockets
+ module Rails
+ module RouteWrapper
+
+ def internal_assets_path?
+ path =~ %r{\A#{self.class.assets_prefix}\z}
+ end
+
+ def internal?
+ super || internal_assets_path?
+ end
+
+ def self.included(klass)
+ klass.class_eval do
+ def internal_with_sprockets?
+ internal_without_sprockets? || internal_assets_path?
+ end
+ alias_method_chain :internal?, :sprockets
+ end
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/task.rb
new/lib/sprockets/rails/task.rb
--- old/lib/sprockets/rails/task.rb 2015-09-08 03:29:27.000000000 +0200
+++ new/lib/sprockets/rails/task.rb 2016-03-02 18:18:46.000000000 +0100
@@ -16,7 +16,9 @@
def environment
if app
- app.assets
+ # Use initialized app.assets or force build an environment if
+ # config.assets.compile is disabled
+ app.assets || Sprockets::Railtie.build_environment(app)
else
super
end
@@ -24,7 +26,8 @@
def output
if app
- File.join(app.root, 'public', app.config.assets.prefix)
+ config = app.config
+ File.join(config.paths['public'].first, config.assets.prefix)
else
super
end
@@ -46,17 +49,12 @@
end
end
- def cache_path
- if app
- "#{app.config.root}/tmp/cache/assets"
- else
- @cache_path
- end
- end
- attr_writer :cache_path
-
def define
namespace :assets do
+ %w( environment precompile clean clobber ).each do |task|
+ Rake::Task[task].clear if Rake::Task.task_defined?(task)
+ end
+
# Override this task change the loaded dependencies
desc "Load asset compile environment"
task :environment do
@@ -73,9 +71,8 @@
desc "Remove old compiled assets"
task :clean, [:keep] => :environment do |t, args|
- keep = Integer(args.keep || 2)
with_logger do
- manifest.clean(keep)
+ manifest.clean(Integer(args.keep || self.keep))
end
end
@@ -83,7 +80,6 @@
task :clobber => :environment do
with_logger do
manifest.clobber
- rm_rf cache_path if cache_path
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/utils.rb
new/lib/sprockets/rails/utils.rb
--- old/lib/sprockets/rails/utils.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/sprockets/rails/utils.rb 2016-03-02 18:18:46.000000000 +0100
@@ -0,0 +1,11 @@
+require 'sprockets'
+
+module Sprockets
+ module Rails
+ module Utils
+ def using_sprockets4?
+ Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('4.x')
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/rails/version.rb
new/lib/sprockets/rails/version.rb
--- old/lib/sprockets/rails/version.rb 2015-09-08 03:29:27.000000000 +0200
+++ new/lib/sprockets/rails/version.rb 2016-03-02 18:18:46.000000000 +0100
@@ -1,5 +1,5 @@
module Sprockets
module Rails
- VERSION = "2.3.3"
+ VERSION = "3.0.4"
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/sprockets/railtie.rb new/lib/sprockets/railtie.rb
--- old/lib/sprockets/railtie.rb 2015-09-08 03:29:27.000000000 +0200
+++ new/lib/sprockets/railtie.rb 2016-03-02 18:18:46.000000000 +0100
@@ -2,9 +2,13 @@
require 'rails/railtie'
require 'action_controller/railtie'
require 'active_support/core_ext/module/remove_method'
+require 'active_support/core_ext/numeric/bytes'
require 'sprockets'
+require 'sprockets/rails/context'
require 'sprockets/rails/helper'
+require 'sprockets/rails/route_wrapper'
require 'sprockets/rails/version'
+require 'set'
module Rails
class Application
@@ -19,37 +23,40 @@
remove_possible_method :assets=
# Returns Sprockets::Environment for app config.
- def assets
- @assets ||= Sprockets::Environment.new(root.to_s) do |env|
- env.version = ::Rails.env
+ attr_accessor :assets
- path = "#{config.root}/tmp/cache/assets/#{::Rails.env}"
- env.cache = Sprockets::Cache::FileStore.new(path)
+ # Returns Sprockets::Manifest for app config.
+ attr_accessor :assets_manifest
- env.context_class.class_eval do
- include ::Sprockets::Rails::Helper
- end
+ # Called from asset helpers to alert you if you reference an asset URL that
+ # isn't precompiled and hence won't be available in production.
+ def asset_precompiled?(logical_path)
+ if precompiled_assets.include?(logical_path)
+ true
+ elsif !config.cache_classes
+ # Check to see if precompile list has been updated
+ precompiled_assets(true).include?(logical_path)
+ else
+ false
end
end
- attr_writer :assets
- # Returns Sprockets::Manifest for app config.
- attr_accessor :assets_manifest
+ # Lazy-load the precompile list so we don't cause asset compilation at app
+ # boot time, but ensure we cache the list so we don't recompute it for each
+ # request or test case.
+ def precompiled_assets(clear_cache = false)
+ @precompiled_assets = nil if clear_cache
+ @precompiled_assets ||=
assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
+ end
end
class Engine < Railtie
# Skip defining append_assets_path on Rails <= 4.2
unless initializers.find { |init| init.name == :append_assets_path }
initializer :append_assets_path, :group => :all do |app|
- if paths["app/assets"].respond_to?(:existent_directories)
-
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
-
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
-
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
- else
- app.config.assets.paths.unshift(*paths["vendor/assets"].paths.select
{ |d| File.directory?(d) })
- app.config.assets.paths.unshift(*paths["lib/assets"].paths.select {
|d| File.directory?(d) })
- app.config.assets.paths.unshift(*paths["app/assets"].paths.select {
|d| File.directory?(d) })
- end
+
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
+
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
+
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
end
end
end
@@ -57,8 +64,11 @@
module Sprockets
class Railtie < ::Rails::Railtie
- LOOSE_APP_ASSETS = lambda do |filename, path|
- path =~ /app\/assets/ && !%w(.js .css).include?(File.extname(filename))
+ include Sprockets::Rails::Utils
+
+ LOOSE_APP_ASSETS = lambda do |logical_path, filename|
+ filename.start_with?(::Rails.root.join("app/assets").to_s) &&
+ !['.js', '.css', ''].include?(File.extname(logical_path))
end
class OrderedOptions < ActiveSupport::OrderedOptions
@@ -68,92 +78,140 @@
end
config.assets = OrderedOptions.new
- config.assets._blocks = []
- config.assets.paths = []
- config.assets.prefix = "/assets"
- config.assets.manifest = nil
- config.assets.precompile = [LOOSE_APP_ASSETS,
/(?:\/|\\|\A)application\.(css|js)$/]
- config.assets.version = ""
- config.assets.debug = false
- config.assets.compile = true
- config.assets.digest = false
+ config.assets._blocks = []
+ config.assets.paths = []
+ config.assets.prefix = "/assets"
+ config.assets.manifest = nil
+ if using_sprockets4?
+ config.assets.precompile = %w( manifest.js )
+ else
+ config.assets.precompile = [LOOSE_APP_ASSETS,
/(?:\/|\\|\A)application\.(css|js)$/]
+ end
+ config.assets.version = ""
+ config.assets.debug = false
+ config.assets.compile = true
+ config.assets.digest = true
+ config.assets.cache_limit = 50.megabytes
+
+ config.assets.configure do |env|
+ config.assets.paths.each { |path| env.append_path(path) }
+ end
+
+ config.assets.configure do |env|
+ env.context_class.send :include, ::Sprockets::Rails::Context
+ env.context_class.assets_prefix = config.assets.prefix
+ env.context_class.digest_assets = config.assets.digest
+ env.context_class.config = config.action_controller
+ end
+
+ config.assets.configure do |env|
+ env.cache = Sprockets::Cache::FileStore.new(
+ "#{env.root}/tmp/cache/assets",
+ config.assets.cache_limit,
+ env.logger
+ )
+ end
+
+ Sprockets.register_dependency_resolver 'rails-env' do
+ ::Rails.env.to_s
+ end
+
+ config.assets.configure do |env|
+ env.depend_on 'rails-env'
+ end
+
+ config.assets.configure do |env|
+ env.version = config.assets.version
+ end
rake_tasks do |app|
require 'sprockets/rails/task'
Sprockets::Rails::Task.new(app)
end
- config.after_initialize do |app|
- config = app.config
-
- # Configuration options that should invalidate
- # the Sprockets cache when changed.
- app.assets.version = [
- app.assets.version,
- config.assets.version,
- config.action_controller.relative_url_root,
- (config.action_controller.asset_host unless
config.action_controller.asset_host.respond_to?(:call)),
- Sprockets::Rails::VERSION
- ].compact.join('-')
-
- # Copy config.assets.paths to Sprockets
- config.assets.paths.each do |path|
- app.assets.append_path path
+ def build_environment(app, initialized = nil)
+ initialized = app.initialized? if initialized.nil?
+ unless initialized
+ ::Rails.logger.warn "Application uninitialized: Try calling
YourApp::Application.initialize!"
end
+ env = Sprockets::Environment.new(app.root.to_s)
+
+ config = app.config
+
# Run app.assets.configure blocks
config.assets._blocks.each do |block|
- block.call app.assets
+ block.call(env)
end
# Set compressors after the configure blocks since they can
# define new compressors and we only accept existent compressors.
- app.assets.js_compressor = config.assets.js_compressor
- app.assets.css_compressor = config.assets.css_compressor
+ env.js_compressor = config.assets.js_compressor
+ env.css_compressor = config.assets.css_compressor
# No more configuration changes at this point.
# With cache classes on, Sprockets won't check the FS when files
# change. Preferable in production when the FS only changes on
# deploys when the app restarts.
if config.cache_classes
- app.assets = app.assets.index
+ env = env.cached
end
- manifest_assets_path = File.join(config.paths['public'].first,
config.assets.prefix)
+ env
+ end
+
+ def self.build_manifest(app)
+ config = app.config
+ path = File.join(config.paths['public'].first, config.assets.prefix)
+ Sprockets::Manifest.new(app.assets, path, config.assets.manifest)
+ end
+
+ config.after_initialize do |app|
+ config = app.config
+
if config.assets.compile
- app.assets_manifest = Sprockets::Manifest.new(app.assets,
manifest_assets_path, config.assets.manifest)
- else
- app.assets_manifest = Sprockets::Manifest.new(manifest_assets_path,
config.assets.manifest)
+ app.assets = self.build_environment(app, true)
+ app.routes.prepend do
+ mount app.assets => config.assets.prefix
+ end
+ end
+
+ app.assets_manifest = build_manifest(app)
+
+ if config.assets.resolve_with.nil?
+ config.assets.resolve_with = []
+ config.assets.resolve_with << :manifest if config.assets.digest &&
!config.assets.debug
+ config.assets.resolve_with << :environment if config.assets.compile
+ end
+
+ ActionDispatch::Routing::RouteWrapper.class_eval do
+ class_attribute :assets_prefix
+
+ if defined?(prepend) && ::Rails.version >= '4'
+ prepend Sprockets::Rails::RouteWrapper
+ else
+ include Sprockets::Rails::RouteWrapper
+ end
+
+ self.assets_prefix = config.assets.prefix
end
ActiveSupport.on_load(:action_view) do
include Sprockets::Rails::Helper
# Copy relevant config to AV context
- self.debug_assets = config.assets.debug
- self.digest_assets = config.assets.digest
- self.assets_prefix = config.assets.prefix
-
- # Copy over to Sprockets as well
- context = app.assets.context_class
- context.assets_prefix = config.assets.prefix
- context.digest_assets = config.assets.digest
- context.config = config.action_controller
+ self.debug_assets = config.assets.debug
+ self.digest_assets = config.assets.digest
+ self.assets_prefix = config.assets.prefix
+ self.assets_precompile = config.assets.precompile
- self.assets_environment = app.assets if config.assets.compile
+ self.assets_environment = app.assets
self.assets_manifest = app.assets_manifest
- end
- Sprockets::Rails::Helper.precompile ||=
app.config.assets.precompile
- Sprockets::Rails::Helper.assets ||= app.assets
- Sprockets::Rails::Helper.raise_runtime_errors =
app.config.assets.raise_runtime_errors
+ self.resolve_assets_with = config.assets.resolve_with
- if config.assets.compile
- if app.routes.respond_to?(:prepend)
- app.routes.prepend do
- mount app.assets => config.assets.prefix
- end
- end
+ # Expose the app precompiled asset check to the view
+ self.precompiled_asset_checker = -> logical_path {
app.asset_precompiled? logical_path }
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2015-09-08 03:29:27.000000000 +0200
+++ new/metadata 2016-03-02 18:18:46.000000000 +0100
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: sprockets-rails
version: !ruby/object:Gem::Version
- version: 2.3.3
+ version: 3.0.4
platform: ruby
authors:
- Joshua Peek
autorequire:
bindir: bin
cert_chain: []
-date: 2015-09-08 00:00:00.000000000 Z
+date: 2016-03-02 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: sprockets
@@ -16,62 +16,56 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '2.8'
- - - "<"
- - !ruby/object:Gem::Version
- version: '4.0'
+ version: 3.0.0
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '2.8'
- - - "<"
- - !ruby/object:Gem::Version
- version: '4.0'
+ version: 3.0.0
- !ruby/object:Gem::Dependency
name: actionpack
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
- !ruby/object:Gem::Dependency
name: activesupport
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
- !ruby/object:Gem::Dependency
name: railties
requirement: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '3.0'
+ version: '4.0'
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
@@ -120,13 +114,14 @@
extensions: []
extra_rdoc_files: []
files:
-- LICENSE
+- MIT-LICENSE
- README.md
- lib/sprockets/rails.rb
+- lib/sprockets/rails/context.rb
- lib/sprockets/rails/helper.rb
-- lib/sprockets/rails/legacy_asset_tag_helper.rb
-- lib/sprockets/rails/legacy_asset_url_helper.rb
+- lib/sprockets/rails/route_wrapper.rb
- lib/sprockets/rails/task.rb
+- lib/sprockets/rails/utils.rb
- lib/sprockets/rails/version.rb
- lib/sprockets/railtie.rb
homepage: https://github.com/rails/sprockets-rails
@@ -141,7 +136,7 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '0'
+ version: 1.9.3
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
@@ -149,9 +144,8 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.4.7
+rubygems_version: 2.5.1
signing_key:
specification_version: 4
summary: Sprockets Rails integration
test_files: []
-has_rdoc: