sprockets-rails 3.1.1 → 3.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0503d614de81e601c0d1a88dda49145ab4bbd8a4
4
- data.tar.gz: 1ec370b1e1456da17a98e004bc1a782eabf4901c
3
+ metadata.gz: 233f747991d3fc5bd6219a99e3eedf0f04460ef2
4
+ data.tar.gz: 0398d6281cd9879088a43fa35707a09485c7bd4d
5
5
  SHA512:
6
- metadata.gz: e425d7eaf3690f0b656a2c63b0031f312cff8c130eba7d7e7e7eff4e412b596cd6022684ac80e43e7dcd681c45bacf06207ac2714635ede815fbbd8deb7e040b
7
- data.tar.gz: 659db7e663b14937d5cdcf2743dee89fc12497482882090e94250f0852552c331d995145a8b4f666a1b09cc7b844de59269a609d70f7f00843d15d443814bb3f
6
+ metadata.gz: fb5fa5f828fac3bb652a1981134be5dc2983b936858da7ec8e336a70da0739df1a90c551ec6e80de45a8aec18c40f58a6ce5a885dc157c97c98d88291e57268c
7
+ data.tar.gz: 129def55fa022f362bc3280801a99fe7cd984470777015386ce3ecd9ecdb52d00aa1d5e35ab8f6d0b5f80907103bb32db96c99fe6a512b4faebfd16d8d90afb0
data/README.md CHANGED
@@ -48,9 +48,12 @@ Each asset task will invoke `assets:environment` first. By default this loads th
48
48
 
49
49
  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).
50
50
 
51
-
52
51
  ### Initializer options
53
52
 
53
+ **`config.assets.unknown_asset_fallback`**
54
+
55
+ When set to a truthy value, a result will be returned even if the requested asset is not found in the asset pipeline. When set to a falsey value it will raise an error when no asset is found in the pipeline. Defaults to `true`.
56
+
54
57
  **`config.assets.precompile`**
55
58
 
56
59
  Add additional assets to compile on deploy. Defaults to `application.js`, `application.css` and any other non-js/css file under `app/assets`.
@@ -6,6 +6,8 @@ require 'sprockets/rails/utils'
6
6
  module Sprockets
7
7
  module Rails
8
8
  module Helper
9
+ class AssetNotFound < StandardError; end
10
+
9
11
  class AssetNotPrecompiled < StandardError
10
12
  include Sprockets::Rails::Utils
11
13
  def initialize(source)
@@ -33,7 +35,8 @@ module Sprockets
33
35
  :assets_environment, :assets_manifest,
34
36
  :assets_precompile, :precompiled_asset_checker,
35
37
  :assets_prefix, :digest_assets, :debug_assets,
36
- :resolve_assets_with, :check_precompiled_asset
38
+ :resolve_assets_with, :check_precompiled_asset,
39
+ :unknown_asset_fallback
37
40
  ]
38
41
 
39
42
  def self.included(klass)
@@ -68,12 +71,26 @@ module Sprockets
68
71
  end
69
72
  end
70
73
 
74
+ # Writes over the built in ActionView::Helpers::AssetUrlHelper#compute_asset_path
75
+ # to use the asset pipeline.
71
76
  def compute_asset_path(path, options = {})
72
77
  debug = options[:debug]
73
78
 
74
79
  if asset_path = resolve_asset_path(path, debug)
75
80
  File.join(assets_prefix || "/", legacy_debug_path(asset_path, debug))
76
81
  else
82
+ message = "The asset #{ path.inspect } is not present in the asset pipeline."
83
+ raise AssetNotFound, message unless unknown_asset_fallback
84
+
85
+ if respond_to?(:public_compute_asset_path)
86
+ message << "Falling back to an asset that may be in the public folder.\n"
87
+ message << "This behavior is deprecated and will be removed.\n"
88
+ message << "To bypass the asset pipeline and preserve this behavior,\n"
89
+ message << "use the `skip_pipeline: true` option.\n"
90
+
91
+ call_stack = respond_to?(:caller_locations) ? caller_locations : caller
92
+ ActiveSupport::Deprecation.warn(message, call_stack)
93
+ end
77
94
  super
78
95
  end
79
96
  end
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Rails
3
- VERSION = "3.1.1"
3
+ VERSION = "3.2.0"
4
4
  end
5
5
  end
@@ -82,8 +82,8 @@ module Sprockets
82
82
  end
83
83
 
84
84
  LOOSE_APP_ASSETS = lambda do |logical_path, filename|
85
- filename.start_with?(::Rails.root.join("app/assets").to_s) &&
86
- !['.js', '.css', ''].include?(File.extname(logical_path))
85
+ filename.start_with?(::Rails.root.join("app/assets").to_s) &&
86
+ !['.js', '.css', ''].include?(File.extname(logical_path))
87
87
  end
88
88
 
89
89
  class OrderedOptions < ActiveSupport::OrderedOptions
@@ -102,10 +102,10 @@ module Sprockets
102
102
 
103
103
  initializer :set_default_precompile do |app|
104
104
  if using_sprockets4?
105
- raise ManifestNeededError if !::Rails.root.join("app/assets/config/manifest.js").exist?
106
- app.config.assets.precompile += %w( manifest.js )
105
+ raise ManifestNeededError unless ::Rails.root.join("app/assets/config/manifest.js").exist?
106
+ app.config.assets.precompile += %w( manifest.js )
107
107
  else
108
- app.config.assets.precompile += [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/]
108
+ app.config.assets.precompile += [LOOSE_APP_ASSETS, /(?:\/|\\|\A)application\.(css|js)$/]
109
109
  end
110
110
  end
111
111
 
@@ -122,6 +122,7 @@ module Sprockets
122
122
  config.assets.cache_limit = 50.megabytes
123
123
  config.assets.gzip = true
124
124
  config.assets.check_precompiled_asset = true
125
+ config.assets.unknown_asset_fallback = true
125
126
 
126
127
  config.assets.configure do |env|
127
128
  config.assets.paths.each { |path| env.append_path(path) }
@@ -245,7 +246,7 @@ module Sprockets
245
246
  self.resolve_assets_with = config.assets.resolve_with
246
247
 
247
248
  self.check_precompiled_asset = config.assets.check_precompiled_asset
248
-
249
+ self.unknown_asset_fallback = config.assets.unknown_asset_fallback
249
250
  # Expose the app precompiled asset check to the view
250
251
  self.precompiled_asset_checker = -> logical_path { app.asset_precompiled? logical_path }
251
252
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-29 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.6.6
148
+ rubygems_version: 2.6.4
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Sprockets Rails integration