sprockets-rails 3.0.0.beta2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -19
- data/lib/sprockets/rails/helper.rb +202 -79
- data/lib/sprockets/rails/utils.rb +0 -5
- data/lib/sprockets/rails/version.rb +1 -1
- data/lib/sprockets/railtie.rb +35 -15
- metadata +5 -7
- data/LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f20d1344a104a96a8fdc6ca1140776f9bee0b095
|
4
|
+
data.tar.gz: b2a9b8a9c86913d9ec6d55a221e2f433cac8201f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f0bfaac5eaaaa8db5681deb71749e0e1195b8f4e0c819125d70102359094baa1a535ad6a5d6163b60d24b5474848c7db2fc12d9bf917aa9c53d3809e69fa2f0
|
7
|
+
data.tar.gz: 8966809de396e82b543ccac54823f99c0abad6696f58bfdc40a1db9e884d196b2570b8c62720c2ac04c35de942a8a4469805c31418d070f09a262afb486124c4
|
data/README.md
CHANGED
@@ -74,10 +74,6 @@ config.assets.version = 'v2'
|
|
74
74
|
|
75
75
|
Defaults to `/assets`. Changes the directory to compile assets to.
|
76
76
|
|
77
|
-
**`config.assets.manifest`**
|
78
|
-
|
79
|
-
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.
|
80
|
-
|
81
77
|
**`config.assets.digest`**
|
82
78
|
|
83
79
|
When enabled, fingerprints will be added to asset filenames.
|
@@ -108,6 +104,24 @@ config.assets.configure do |env|
|
|
108
104
|
end
|
109
105
|
```
|
110
106
|
|
107
|
+
**`config.assets.resolve_with`**
|
108
|
+
|
109
|
+
A list of `:environment` and `:manifest` symbols that defines the order that
|
110
|
+
we try to find assets: manifest first, environment second? Manifest only?
|
111
|
+
|
112
|
+
By default, we check the manifest first if asset digests are enabled and debug
|
113
|
+
is not enabled, then we check the environment if compiling is enabled:
|
114
|
+
```
|
115
|
+
# Dev where debug is true, or digests are disabled
|
116
|
+
%i[ environment ]
|
117
|
+
|
118
|
+
# Dev default, or production with compile enabled.
|
119
|
+
%i[ manifest environment ]
|
120
|
+
|
121
|
+
# Production default.
|
122
|
+
%i[ manifest ]
|
123
|
+
```
|
124
|
+
|
111
125
|
|
112
126
|
## Complementary plugins
|
113
127
|
|
@@ -136,23 +150,16 @@ Sprockets 3.x adds experimental support for subresource integrity checks. The sp
|
|
136
150
|
|
137
151
|
``` ruby
|
138
152
|
javascript_include_tag :application, integrity: true
|
139
|
-
# => "<script src="/assets/application.js" integrity="
|
153
|
+
# => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
|
140
154
|
```
|
141
155
|
|
142
156
|
|
143
|
-
## Contributing
|
157
|
+
## Contributing to Sprockets Rails
|
144
158
|
|
145
|
-
|
146
|
-
|
147
|
-
``` shell
|
148
|
-
$ git clone https://github.com/rails/sprockets-rails.git
|
149
|
-
$ cd sprockets-rails/
|
150
|
-
$ bundle install
|
151
|
-
$ bundle exec rake test
|
152
|
-
```
|
153
|
-
|
154
|
-
[![Build Status](https://travis-ci.org/rails/sprockets-rails.svg?branch=master)](https://travis-ci.org/rails/sprockets-rails)
|
159
|
+
Sprockets Rails is work of many contributors. You're encouraged to submit pull requests, propose
|
160
|
+
features and discuss issues.
|
155
161
|
|
162
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
156
163
|
|
157
164
|
## Releases
|
158
165
|
|
@@ -164,9 +171,12 @@ The minor and patch version will be updated according to [semver](http://semver.
|
|
164
171
|
* Any time the sprockets dependency is bumped, there will be a new minor release
|
165
172
|
* Simple bug fixes will be patch releases
|
166
173
|
|
167
|
-
|
168
174
|
## License
|
169
175
|
|
170
|
-
|
176
|
+
Sprockets Rails is released under the [MIT License](MIT-LICENSE).
|
177
|
+
|
178
|
+
## Code Status
|
171
179
|
|
172
|
-
|
180
|
+
* [![Travis CI](https://api.travis-ci.org/rails/sprockets-rails.svg)](http://travis-ci.org/rails/sprockets-rails)
|
181
|
+
* [![Gem Version](https://badge.fury.io/rb/sprockets-rails.svg)](http://badge.fury.io/rb/sprockets-rails)
|
182
|
+
* [![Dependencies](https://gemnasium.com/rails/sprockets-rails.svg)](https://gemnasium.com/rails/sprockets-rails)
|
@@ -7,11 +7,25 @@ module Sprockets
|
|
7
7
|
module Rails
|
8
8
|
module Helper
|
9
9
|
class AssetNotPrecompiled < StandardError
|
10
|
+
include Sprockets::Rails::Utils
|
10
11
|
def initialize(source)
|
11
|
-
msg =
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
msg =
|
13
|
+
if using_sprockets4?
|
14
|
+
"Asset `#{source}` was not declared to be precompiled in production.\n" +
|
15
|
+
"Declare links to your assets in `assets/config/manifest.js`.\n" +
|
16
|
+
"Examples:\n" +
|
17
|
+
"`//= link ../javascripts/application.js`\n" +
|
18
|
+
"`//= link_directory ../javascripts .js`\n" +
|
19
|
+
"`//= link_directory ../stylesheets .css`\n" +
|
20
|
+
"`//= link_tree ../javascripts .js`\n" +
|
21
|
+
"`//= link_tree ../images`\n" +
|
22
|
+
"and restart your server"
|
23
|
+
else
|
24
|
+
"Asset was not declared to be precompiled in production.\n" +
|
25
|
+
"Add `Rails.application.config.assets.precompile += " +
|
26
|
+
"%w( #{source} )` to `config/initializers/assets.rb` and " +
|
27
|
+
"restart your server"
|
28
|
+
end
|
15
29
|
super(msg)
|
16
30
|
end
|
17
31
|
end
|
@@ -20,9 +34,12 @@ module Sprockets
|
|
20
34
|
include ActionView::Helpers::AssetTagHelper
|
21
35
|
include Sprockets::Rails::Utils
|
22
36
|
|
23
|
-
VIEW_ACCESSORS = [
|
24
|
-
|
25
|
-
|
37
|
+
VIEW_ACCESSORS = [
|
38
|
+
:assets_environment, :assets_manifest,
|
39
|
+
:assets_precompile, :precompiled_asset_checker,
|
40
|
+
:assets_prefix, :digest_assets, :debug_assets,
|
41
|
+
:resolve_assets_with
|
42
|
+
]
|
26
43
|
|
27
44
|
def self.included(klass)
|
28
45
|
klass.class_attribute(*VIEW_ACCESSORS)
|
@@ -57,15 +74,23 @@ module Sprockets
|
|
57
74
|
end
|
58
75
|
|
59
76
|
def compute_asset_path(path, options = {})
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
File.join(assets_prefix || "/",
|
77
|
+
debug = options[:debug]
|
78
|
+
|
79
|
+
if asset_path = resolve_asset_path(path, debug)
|
80
|
+
File.join(assets_prefix || "/", legacy_debug_path(asset_path, debug))
|
64
81
|
else
|
65
82
|
super
|
66
83
|
end
|
67
84
|
end
|
68
85
|
|
86
|
+
# Resolve the asset path against the Sprockets manifest or environment.
|
87
|
+
# Returns nil if it's an asset we don't know about.
|
88
|
+
def resolve_asset_path(path, allow_non_precompiled = false) #:nodoc:
|
89
|
+
resolve_asset do |resolver|
|
90
|
+
resolver.asset_path path, digest_assets, allow_non_precompiled
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
69
94
|
# Expand asset path to digested form.
|
70
95
|
#
|
71
96
|
# path - String path
|
@@ -73,21 +98,8 @@ module Sprockets
|
|
73
98
|
#
|
74
99
|
# Returns String path or nil if no asset was found.
|
75
100
|
def asset_digest_path(path, options = {})
|
76
|
-
|
77
|
-
|
78
|
-
return digest_path
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
if environment = assets_environment
|
83
|
-
if asset = environment[path]
|
84
|
-
unless options[:debug]
|
85
|
-
if !precompiled_assets.include?(asset.logical_path)
|
86
|
-
raise AssetNotPrecompiled.new(asset.logical_path)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
return asset.digest_path
|
90
|
-
end
|
101
|
+
resolve_asset do |resolver|
|
102
|
+
resolver.digest_path path, options[:debug]
|
91
103
|
end
|
92
104
|
end
|
93
105
|
|
@@ -98,26 +110,11 @@ module Sprockets
|
|
98
110
|
#
|
99
111
|
# Returns String integrity attribute or nil if no asset was found.
|
100
112
|
def asset_integrity(path, options = {})
|
101
|
-
path = path
|
102
|
-
if extname = compute_asset_extname(path, options)
|
103
|
-
path = "#{path}#{extname}"
|
104
|
-
end
|
105
|
-
|
106
|
-
if manifest = assets_manifest
|
107
|
-
if digest_path = manifest.assets[path]
|
108
|
-
if metadata = manifest.files[digest_path]
|
109
|
-
return metadata["integrity"]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
+
path = path_with_extname(path, options)
|
113
114
|
|
114
|
-
|
115
|
-
|
116
|
-
return asset.integrity
|
117
|
-
end
|
115
|
+
resolve_asset do |resolver|
|
116
|
+
resolver.integrity path
|
118
117
|
end
|
119
|
-
|
120
|
-
nil
|
121
118
|
end
|
122
119
|
|
123
120
|
# Override javascript tag helper to provide debugging support.
|
@@ -125,15 +122,7 @@ module Sprockets
|
|
125
122
|
# Eventually will be deprecated and replaced by source maps.
|
126
123
|
def javascript_include_tag(*sources)
|
127
124
|
options = sources.extract_options!.stringify_keys
|
128
|
-
|
129
|
-
unless request_ssl?
|
130
|
-
options.delete("integrity")
|
131
|
-
end
|
132
|
-
|
133
|
-
case options["integrity"]
|
134
|
-
when true, false, nil
|
135
|
-
compute_integrity = options.delete("integrity")
|
136
|
-
end
|
125
|
+
integrity = compute_integrity?(options)
|
137
126
|
|
138
127
|
if options["debug"] != false && request_debug_assets?
|
139
128
|
sources.map { |source|
|
@@ -151,9 +140,8 @@ module Sprockets
|
|
151
140
|
}.flatten.uniq.join("\n").html_safe
|
152
141
|
else
|
153
142
|
sources.map { |source|
|
154
|
-
|
155
|
-
|
156
|
-
options)
|
143
|
+
options = options.merge('integrity' => asset_integrity(source, :type => :javascript)) if integrity
|
144
|
+
super source, options
|
157
145
|
}.join("\n").html_safe
|
158
146
|
end
|
159
147
|
end
|
@@ -163,15 +151,7 @@ module Sprockets
|
|
163
151
|
# Eventually will be deprecated and replaced by source maps.
|
164
152
|
def stylesheet_link_tag(*sources)
|
165
153
|
options = sources.extract_options!.stringify_keys
|
166
|
-
|
167
|
-
unless request_ssl?
|
168
|
-
options.delete("integrity")
|
169
|
-
end
|
170
|
-
|
171
|
-
case options["integrity"]
|
172
|
-
when true, false, nil
|
173
|
-
compute_integrity = options.delete("integrity")
|
174
|
-
end
|
154
|
+
integrity = compute_integrity?(options)
|
175
155
|
|
176
156
|
if options["debug"] != false && request_debug_assets?
|
177
157
|
sources.map { |source|
|
@@ -189,15 +169,34 @@ module Sprockets
|
|
189
169
|
}.flatten.uniq.join("\n").html_safe
|
190
170
|
else
|
191
171
|
sources.map { |source|
|
192
|
-
|
193
|
-
|
194
|
-
options)
|
172
|
+
options = options.merge('integrity' => asset_integrity(source, :type => :stylesheet)) if integrity
|
173
|
+
super source, options
|
195
174
|
}.join("\n").html_safe
|
196
175
|
end
|
197
176
|
end
|
198
177
|
|
199
178
|
protected
|
200
|
-
|
179
|
+
# This is awkward: `integrity` is a boolean option indicating whether
|
180
|
+
# we want to include or omit the subresource integrity hash, but the
|
181
|
+
# options hash is also passed through as literal tag attributes.
|
182
|
+
# That means we have to delete the shortcut boolean option so it
|
183
|
+
# doesn't bleed into the tag attributes, but also check its value if
|
184
|
+
# it's boolean-ish.
|
185
|
+
def compute_integrity?(options)
|
186
|
+
if secure_subresource_integrity_context?
|
187
|
+
case options['integrity']
|
188
|
+
when nil, false, true
|
189
|
+
options.delete('integrity') == true
|
190
|
+
end
|
191
|
+
else
|
192
|
+
options.delete 'integrity'
|
193
|
+
false
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Only serve integrity metadata for HTTPS requests:
|
198
|
+
# http://www.w3.org/TR/SRI/#non-secure-contexts-remain-non-secure
|
199
|
+
def secure_subresource_integrity_context?
|
201
200
|
respond_to?(:request) && self.request && self.request.ssl?
|
202
201
|
end
|
203
202
|
|
@@ -205,28 +204,152 @@ module Sprockets
|
|
205
204
|
# and replaced by source maps in Sprockets 3.x.
|
206
205
|
def request_debug_assets?
|
207
206
|
debug_assets || (defined?(controller) && controller && params[:debug_assets])
|
208
|
-
rescue
|
209
|
-
|
207
|
+
rescue # FIXME: what exactly are we rescuing?
|
208
|
+
false
|
210
209
|
end
|
211
210
|
|
212
211
|
# Internal method to support multifile debugging. Will
|
213
212
|
# eventually be removed w/ Sprockets 3.x.
|
214
213
|
def lookup_debug_asset(path, options = {})
|
215
|
-
|
214
|
+
path = path_with_extname(path, options)
|
215
|
+
|
216
|
+
resolve_asset do |resolver|
|
217
|
+
resolver.find_debug_asset path
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# compute_asset_extname is in AV::Helpers::AssetUrlHelper
|
222
|
+
def path_with_extname(path, options)
|
216
223
|
path = path.to_s
|
217
|
-
|
218
|
-
|
224
|
+
"#{path}#{compute_asset_extname(path, options)}"
|
225
|
+
end
|
226
|
+
|
227
|
+
# Try each asset resolver and return the first non-nil result.
|
228
|
+
def resolve_asset
|
229
|
+
asset_resolver_strategies.detect do |resolver|
|
230
|
+
if result = yield(resolver)
|
231
|
+
break result
|
232
|
+
end
|
219
233
|
end
|
234
|
+
end
|
220
235
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
236
|
+
# List of resolvers in `config.assets.resolve_with` order.
|
237
|
+
def asset_resolver_strategies
|
238
|
+
@asset_resolver_strategies ||=
|
239
|
+
Array(resolve_assets_with).map do |name|
|
240
|
+
HelperAssetResolvers[name].new(self)
|
225
241
|
end
|
242
|
+
end
|
243
|
+
|
244
|
+
# Append ?body=1 if debug is on and we're on old Sprockets.
|
245
|
+
def legacy_debug_path(path, debug)
|
246
|
+
if debug && !using_sprockets4?
|
247
|
+
"#{path}?body=1"
|
248
|
+
else
|
249
|
+
path
|
226
250
|
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# Use a separate module since Helper is mixed in and we needn't pollute
|
255
|
+
# the class namespace with our internals.
|
256
|
+
module HelperAssetResolvers #:nodoc:
|
257
|
+
def self.[](name)
|
258
|
+
case name
|
259
|
+
when :manifest
|
260
|
+
Manifest
|
261
|
+
when :environment
|
262
|
+
Environment
|
263
|
+
else
|
264
|
+
raise ArgumentError, "Unrecognized asset resolver: #{name.inspect}. Expected :manifest or :environment"
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
class Manifest #:nodoc:
|
269
|
+
def initialize(view)
|
270
|
+
@manifest = view.assets_manifest
|
271
|
+
raise ArgumentError, 'config.assets.resolve_with includes :manifest, but app.assets_manifest is nil' unless @manifest
|
272
|
+
end
|
273
|
+
|
274
|
+
def asset_path(path, digest, allow_non_precompiled = false)
|
275
|
+
if digest
|
276
|
+
digest_path path, allow_non_precompiled
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def digest_path(path, allow_non_precompiled = false)
|
281
|
+
@manifest.assets[path]
|
282
|
+
end
|
283
|
+
|
284
|
+
def integrity(path)
|
285
|
+
if meta = metadata(path)
|
286
|
+
meta["integrity"]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def find_debug_asset(path)
|
291
|
+
nil
|
292
|
+
end
|
293
|
+
|
294
|
+
private
|
295
|
+
def metadata(path)
|
296
|
+
if digest_path = digest_path(path)
|
297
|
+
@manifest.files[digest_path]
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
class Environment #:nodoc:
|
303
|
+
def initialize(view)
|
304
|
+
raise ArgumentError, 'config.assets.resolve_with includes :environment, but app.assets is nil' unless view.assets_environment
|
305
|
+
@env = view.assets_environment
|
306
|
+
@precompiled_asset_checker = view.precompiled_asset_checker
|
307
|
+
end
|
308
|
+
|
309
|
+
def asset_path(path, digest, allow_non_precompiled = false)
|
310
|
+
# Digests enabled? Do the work to calculate the full asset path.
|
311
|
+
if digest
|
312
|
+
digest_path path, allow_non_precompiled
|
313
|
+
|
314
|
+
# Otherwise, ask the Sprockets environment whether the asset exists
|
315
|
+
# and check whether it's also precompiled for production deploys.
|
316
|
+
elsif find_asset(path)
|
317
|
+
raise_unless_precompiled_asset path unless allow_non_precompiled
|
318
|
+
path
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def digest_path(path, allow_non_precompiled = false)
|
323
|
+
if asset = find_asset(path)
|
324
|
+
raise_unless_precompiled_asset path unless allow_non_precompiled
|
325
|
+
asset.digest_path
|
326
|
+
end
|
327
|
+
end
|
227
328
|
|
228
|
-
|
329
|
+
def integrity(path)
|
330
|
+
find_asset(path).try :integrity
|
229
331
|
end
|
332
|
+
|
333
|
+
def find_debug_asset(path)
|
334
|
+
if asset = find_asset(path, pipeline: :debug)
|
335
|
+
raise_unless_precompiled_asset asset.logical_path.sub('.debug', '')
|
336
|
+
asset
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
private
|
341
|
+
def find_asset(path, options = {})
|
342
|
+
@env[path, options]
|
343
|
+
end
|
344
|
+
|
345
|
+
def precompiled?(path)
|
346
|
+
@precompiled_asset_checker.call path
|
347
|
+
end
|
348
|
+
|
349
|
+
def raise_unless_precompiled_asset(path)
|
350
|
+
raise Helper::AssetNotPrecompiled.new(path) unless precompiled?(path)
|
351
|
+
end
|
352
|
+
end
|
230
353
|
end
|
231
354
|
end
|
232
355
|
end
|
@@ -6,11 +6,6 @@ module Sprockets
|
|
6
6
|
def using_sprockets4?
|
7
7
|
Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('4.0.0')
|
8
8
|
end
|
9
|
-
|
10
|
-
# Internal: Generate a Set of all precompiled assets logical paths.
|
11
|
-
def build_precompiled_list(manifest, assets)
|
12
|
-
manifest.find(assets || []).map(&:logical_path)
|
13
|
-
end
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|
data/lib/sprockets/railtie.rb
CHANGED
@@ -8,6 +8,7 @@ require 'sprockets/rails/context'
|
|
8
8
|
require 'sprockets/rails/helper'
|
9
9
|
require 'sprockets/rails/route_wrapper'
|
10
10
|
require 'sprockets/rails/version'
|
11
|
+
require 'set'
|
11
12
|
|
12
13
|
module Rails
|
13
14
|
class Application
|
@@ -27,8 +28,18 @@ module Rails
|
|
27
28
|
# Returns Sprockets::Manifest for app config.
|
28
29
|
attr_accessor :assets_manifest
|
29
30
|
|
30
|
-
#
|
31
|
-
|
31
|
+
# Called from asset helpers to alert you if you reference an asset URL that
|
32
|
+
# isn't precompiled and hence won't be available in production.
|
33
|
+
def asset_precompiled?(logical_path)
|
34
|
+
precompiled_assets.include? logical_path
|
35
|
+
end
|
36
|
+
|
37
|
+
# Lazy-load the precompile list so we don't cause asset compilation at app
|
38
|
+
# boot time, but ensure we cache the list so we don't recompute it for each
|
39
|
+
# request or test case.
|
40
|
+
def precompiled_assets
|
41
|
+
@precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
|
42
|
+
end
|
32
43
|
end
|
33
44
|
|
34
45
|
class Engine < Railtie
|
@@ -37,7 +48,6 @@ module Rails
|
|
37
48
|
initializer :append_assets_path, :group => :all do |app|
|
38
49
|
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
39
50
|
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
40
|
-
app.config.assets.paths.unshift(*paths["app"].existent_directories.grep(/\/assets\z/))
|
41
51
|
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
42
52
|
end
|
43
53
|
end
|
@@ -79,11 +89,6 @@ module Sprockets
|
|
79
89
|
config.assets.paths.each { |path| env.append_path(path) }
|
80
90
|
end
|
81
91
|
|
82
|
-
config.assets.configure do |env|
|
83
|
-
env.js_compressor = config.assets.js_compressor
|
84
|
-
env.css_compressor = config.assets.css_compressor
|
85
|
-
end
|
86
|
-
|
87
92
|
config.assets.configure do |env|
|
88
93
|
env.context_class.send :include, ::Sprockets::Rails::Context
|
89
94
|
env.context_class.assets_prefix = config.assets.prefix
|
@@ -123,16 +128,23 @@ module Sprockets
|
|
123
128
|
|
124
129
|
env = Sprockets::Environment.new(app.root.to_s)
|
125
130
|
|
131
|
+
config = app.config
|
132
|
+
|
126
133
|
# Run app.assets.configure blocks
|
127
|
-
|
134
|
+
config.assets._blocks.each do |block|
|
128
135
|
block.call(env)
|
129
136
|
end
|
130
137
|
|
138
|
+
# Set compressors after the configure blocks since they can
|
139
|
+
# define new compressors and we only accept existent compressors.
|
140
|
+
env.js_compressor = config.assets.js_compressor
|
141
|
+
env.css_compressor = config.assets.css_compressor
|
142
|
+
|
131
143
|
# No more configuration changes at this point.
|
132
144
|
# With cache classes on, Sprockets won't check the FS when files
|
133
145
|
# change. Preferable in production when the FS only changes on
|
134
146
|
# deploys when the app restarts.
|
135
|
-
if
|
147
|
+
if config.cache_classes
|
136
148
|
env = env.cached
|
137
149
|
end
|
138
150
|
|
@@ -153,10 +165,14 @@ module Sprockets
|
|
153
165
|
app.routes.prepend do
|
154
166
|
mount app.assets => config.assets.prefix
|
155
167
|
end
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
168
|
+
end
|
169
|
+
|
170
|
+
app.assets_manifest = build_manifest(app)
|
171
|
+
|
172
|
+
if config.assets.resolve_with.nil?
|
173
|
+
config.assets.resolve_with = []
|
174
|
+
config.assets.resolve_with << :manifest if config.assets.digest && !config.assets.debug
|
175
|
+
config.assets.resolve_with << :environment if config.assets.compile
|
160
176
|
end
|
161
177
|
|
162
178
|
ActionDispatch::Routing::RouteWrapper.class_eval do
|
@@ -182,7 +198,11 @@ module Sprockets
|
|
182
198
|
|
183
199
|
self.assets_environment = app.assets
|
184
200
|
self.assets_manifest = app.assets_manifest
|
185
|
-
|
201
|
+
|
202
|
+
self.resolve_assets_with = config.assets.resolve_with
|
203
|
+
|
204
|
+
# Expose the app precompiled asset check to the view
|
205
|
+
self.precompiled_asset_checker = -> logical_path { app.asset_precompiled? logical_path }
|
186
206
|
end
|
187
207
|
end
|
188
208
|
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.0.0
|
4
|
+
version: 3.0.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: 2015-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -114,7 +114,6 @@ executables: []
|
|
114
114
|
extensions: []
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
|
-
- LICENSE
|
118
117
|
- README.md
|
119
118
|
- lib/sprockets/rails.rb
|
120
119
|
- lib/sprockets/rails/context.rb
|
@@ -139,14 +138,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
138
|
version: 1.9.3
|
140
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
140
|
requirements:
|
142
|
-
- - "
|
141
|
+
- - ">="
|
143
142
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
143
|
+
version: '0'
|
145
144
|
requirements: []
|
146
145
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.4.
|
146
|
+
rubygems_version: 2.4.5.1
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: Sprockets Rails integration
|
151
150
|
test_files: []
|
152
|
-
has_rdoc:
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Joshua Peek
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|