sprockets-helpers 1.2.0 → 1.4.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 +5 -5
- data/Appraisals +5 -1
- data/README.md +5 -1
- data/gemfiles/sprockets_2.2.gemfile +1 -1
- data/gemfiles/sprockets_2.3.gemfile +1 -1
- data/gemfiles/sprockets_2.4.gemfile +1 -1
- data/gemfiles/sprockets_2.5.gemfile +1 -1
- data/gemfiles/sprockets_2.6.gemfile +1 -1
- data/gemfiles/sprockets_2.7.gemfile +1 -1
- data/gemfiles/sprockets_2.8.gemfile +1 -1
- data/gemfiles/sprockets_2.9.gemfile +1 -1
- data/gemfiles/sprockets_3.0.gemfile +1 -1
- data/gemfiles/sprockets_3.1.gemfile +1 -1
- data/gemfiles/sprockets_3.2.gemfile +1 -1
- data/gemfiles/sprockets_4.0.gemfile +7 -0
- data/lib/sprockets/helpers.rb +58 -82
- data/lib/sprockets/helpers/asset_path.rb +15 -5
- data/lib/sprockets/helpers/base_path.rb +6 -2
- data/lib/sprockets/helpers/file_path.rb +1 -1
- data/lib/sprockets/helpers/manifest_path.rb +2 -1
- data/lib/sprockets/helpers/settings.rb +66 -0
- data/lib/sprockets/helpers/version.rb +3 -1
- data/spec/sprockets-helpers_spec.rb +19 -19
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '068064e923da4422a80742ce0e1f6a840799722e22294992e6c6e35e44dff080'
|
4
|
+
data.tar.gz: c0a762b6b31bad8b4384fa7ef5a90ab84b5d56c0e576934f71b5b76f0e4acbd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07eeb179f20c73a09b4ee1c24f0ccd91ff0b18e8584ae46db83013fdc52e8b211f5c15328794e55ac958916c7190875e5431093b459155994cf6b713402ed9e0
|
7
|
+
data.tar.gz: bcb76256c24bfe98c34c60b07ab10ab81933da61fd7baee351c434b4b93eaf4de9c44ad9fb8f58dd96ed388b1bf33e15f7ea2cb65333360362b13e493a93cd06
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sprockets-helpers
|
2
2
|
|
3
|
-
**Asset path helpers for Sprockets 3.x & <= 2.2 applications**
|
3
|
+
**Asset path helpers for Sprockets 4.x & 3.x & <= 2.2 applications**
|
4
4
|
|
5
5
|
Sprockets::Helpers adds the asset_path helpers, familiar to Rails developers, to Sprockets 2.x assets and applications.
|
6
6
|
|
@@ -222,6 +222,10 @@ class App < Sinatra::Base
|
|
222
222
|
end
|
223
223
|
```
|
224
224
|
|
225
|
+
## Roda Integration
|
226
|
+
|
227
|
+
See: https://github.com/hmdne/roda-sprockets
|
228
|
+
|
225
229
|
## Copyright
|
226
230
|
|
227
231
|
Copyright (c) 2011 [Peter Browne](http://petebrowne.com). See LICENSE for details.
|
data/lib/sprockets/helpers.rb
CHANGED
@@ -4,78 +4,30 @@ require 'sprockets/helpers/base_path'
|
|
4
4
|
require 'sprockets/helpers/asset_path'
|
5
5
|
require 'sprockets/helpers/file_path'
|
6
6
|
require 'sprockets/helpers/manifest_path'
|
7
|
+
require 'sprockets/helpers/settings'
|
7
8
|
require 'uri'
|
9
|
+
require 'forwardable'
|
8
10
|
|
9
11
|
module Sprockets
|
10
12
|
module Helpers
|
11
13
|
class << self
|
12
|
-
|
13
|
-
attr_accessor :are_using_sprockets_3
|
14
|
+
extend Forwardable
|
14
15
|
|
15
|
-
#
|
16
|
-
attr_accessor :
|
16
|
+
# Indicates whenever we are using Sprockets 3.x or higher.
|
17
|
+
attr_accessor :are_using_sprockets_3_plus
|
17
18
|
|
18
|
-
#
|
19
|
-
attr_accessor :
|
19
|
+
# Indicates whenever we are using Sprockets 4.x or higher.
|
20
|
+
attr_accessor :are_using_sprockets_4_plus
|
20
21
|
|
21
|
-
#
|
22
|
-
attr_accessor :
|
22
|
+
# Settings of Sprockets::Helpers
|
23
|
+
attr_accessor :settings
|
23
24
|
|
24
|
-
#
|
25
|
-
|
26
|
-
# :expand => true
|
27
|
-
# :digest => false
|
28
|
-
# :manifest => false
|
29
|
-
attr_accessor :debug
|
30
|
-
|
31
|
-
# Set the Sprockets environment to search for assets.
|
32
|
-
# This defaults to the context's #environment method.
|
33
|
-
attr_accessor :environment
|
34
|
-
|
35
|
-
# The manifest file used for lookup
|
36
|
-
attr_accessor :manifest
|
37
|
-
|
38
|
-
# The base URL the Sprocket environment is mapped to.
|
39
|
-
# This defaults to '/assets'.
|
40
|
-
def prefix
|
41
|
-
@prefix ||= '/assets'
|
42
|
-
@prefix.respond_to?(:first) ? "/#{@prefix.first}" : @prefix
|
43
|
-
end
|
44
|
-
attr_writer :prefix
|
45
|
-
|
46
|
-
# Customize the protocol when using asset hosts.
|
47
|
-
# If the value is :relative, A relative protocol ('//')
|
48
|
-
# will be used.
|
49
|
-
def protocol
|
50
|
-
@protocol ||= 'http://'
|
51
|
-
end
|
52
|
-
attr_writer :protocol
|
53
|
-
|
54
|
-
# The path to the public directory, where the assets
|
55
|
-
# not managed by Sprockets will be located.
|
56
|
-
# Defaults to './public'
|
57
|
-
def public_path
|
58
|
-
@public_path ||= './public'
|
59
|
-
end
|
60
|
-
attr_writer :public_path
|
61
|
-
|
62
|
-
# The default options for each asset path method. This is where you
|
63
|
-
# can change your default directories for the fallback directory.
|
64
|
-
def default_path_options
|
65
|
-
@default_path_options ||= {
|
66
|
-
:audio_path => { :dir => 'audios' },
|
67
|
-
:font_path => { :dir => 'fonts' },
|
68
|
-
:image_path => { :dir => 'images' },
|
69
|
-
:javascript_path => { :dir => 'javascripts', :ext => 'js' },
|
70
|
-
:stylesheet_path => { :dir => 'stylesheets', :ext => 'css' },
|
71
|
-
:video_path => { :dir => 'videos' }
|
72
|
-
}
|
73
|
-
end
|
74
|
-
attr_writer :default_path_options
|
25
|
+
# Access the settings directly for compatibility purposes.
|
26
|
+
def_delegators :@settings, *Settings.public_instance_methods(false)
|
75
27
|
|
76
28
|
# Convience method for configuring Sprockets::Helpers.
|
77
29
|
def configure
|
78
|
-
yield
|
30
|
+
yield settings
|
79
31
|
end
|
80
32
|
|
81
33
|
# Hack to ensure methods from Sprockets::Helpers override the
|
@@ -92,8 +44,11 @@ module Sprockets
|
|
92
44
|
end
|
93
45
|
end
|
94
46
|
|
47
|
+
@settings = Settings.new
|
48
|
+
|
95
49
|
# We are checking here to skip this at runtime
|
96
|
-
@
|
50
|
+
@are_using_sprockets_3_plus = Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('3.0')
|
51
|
+
@are_using_sprockets_4_plus = Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new('4.0')
|
97
52
|
|
98
53
|
# Returns the path to an asset either in the Sprockets environment
|
99
54
|
# or the public directory. External URIs are untouched.
|
@@ -128,9 +83,9 @@ module Sprockets
|
|
128
83
|
uri = URI.parse(source)
|
129
84
|
return source if uri.absolute?
|
130
85
|
|
131
|
-
options[:prefix] =
|
86
|
+
options[:prefix] = sprockets_helpers_settings.prefix unless options[:prefix]
|
132
87
|
|
133
|
-
if
|
88
|
+
if sprockets_helpers_settings.debug || options[:debug]
|
134
89
|
options[:manifest] = false
|
135
90
|
options[:digest] = false
|
136
91
|
options[:asset_host] = false
|
@@ -153,7 +108,9 @@ module Sprockets
|
|
153
108
|
|
154
109
|
def asset_tag(source, options = {}, &block)
|
155
110
|
raise ::ArgumentError, 'block missing' unless block
|
156
|
-
options = { :expand => !!
|
111
|
+
options = { :expand => (!!sprockets_helpers_settings.debug && !::Sprockets::Helpers.are_using_sprockets_4_plus) ||
|
112
|
+
!!sprockets_helpers_settings.expand,
|
113
|
+
:debug => sprockets_helpers_settings.debug }.merge(options)
|
157
114
|
|
158
115
|
path = asset_path(source, options)
|
159
116
|
output = if options[:expand] && path.respond_to?(:map)
|
@@ -167,18 +124,18 @@ module Sprockets
|
|
167
124
|
end
|
168
125
|
|
169
126
|
def javascript_tag(source, options = {})
|
170
|
-
options =
|
127
|
+
options = sprockets_helpers_settings.default_path_options[:javascript_path].merge(options)
|
171
128
|
asset_tag(source, options) do |path|
|
172
|
-
%Q(<script src="#{path}"></script>)
|
129
|
+
%Q(<script src="#{path}" type="text/javascript"></script>)
|
173
130
|
end
|
174
131
|
end
|
175
132
|
|
176
133
|
def stylesheet_tag(source, options = {})
|
177
134
|
media = options.delete(:media)
|
178
135
|
media_attr = media.nil? ? nil : " media=\"#{media}\""
|
179
|
-
options =
|
136
|
+
options = sprockets_helpers_settings.default_path_options[:stylesheet_path].merge(options)
|
180
137
|
asset_tag(source, options) do |path|
|
181
|
-
%Q(<link rel="stylesheet" href="#{path}"#{media_attr}>)
|
138
|
+
%Q(<link rel="stylesheet" type="text/css" href="#{path}"#{media_attr}>)
|
182
139
|
end
|
183
140
|
end
|
184
141
|
|
@@ -202,7 +159,7 @@ module Sprockets
|
|
202
159
|
# audio_path 'http://www.example.com/img/audio.mp3' # => 'http://www.example.com/img/audio.mp3'
|
203
160
|
#
|
204
161
|
def audio_path(source, options = {})
|
205
|
-
asset_path source,
|
162
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:audio_path].merge(options)
|
206
163
|
end
|
207
164
|
alias_method :path_to_audio, :audio_path
|
208
165
|
|
@@ -226,7 +183,7 @@ module Sprockets
|
|
226
183
|
# font_path 'http://www.example.com/img/font.ttf' # => 'http://www.example.com/img/font.ttf'
|
227
184
|
#
|
228
185
|
def font_path(source, options = {})
|
229
|
-
asset_path source,
|
186
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:font_path].merge(options)
|
230
187
|
end
|
231
188
|
alias_method :path_to_font, :font_path
|
232
189
|
|
@@ -250,7 +207,7 @@ module Sprockets
|
|
250
207
|
# image_path 'http://www.example.com/img/edit.png' # => 'http://www.example.com/img/edit.png'
|
251
208
|
#
|
252
209
|
def image_path(source, options = {})
|
253
|
-
asset_path source,
|
210
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:image_path].merge(options)
|
254
211
|
end
|
255
212
|
alias_method :path_to_image, :image_path
|
256
213
|
|
@@ -275,7 +232,7 @@ module Sprockets
|
|
275
232
|
# javascript_path 'http://www.example.com/js/xmlhr.js' # => 'http://www.example.com/js/xmlhr.js'
|
276
233
|
#
|
277
234
|
def javascript_path(source, options = {})
|
278
|
-
asset_path source,
|
235
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:javascript_path].merge(options)
|
279
236
|
end
|
280
237
|
alias_method :path_to_javascript, :javascript_path
|
281
238
|
|
@@ -300,7 +257,7 @@ module Sprockets
|
|
300
257
|
# stylesheet_path 'http://www.example.com/css/style.css' # => 'http://www.example.com/css/style.css'
|
301
258
|
#
|
302
259
|
def stylesheet_path(source, options = {})
|
303
|
-
asset_path source,
|
260
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:stylesheet_path].merge(options)
|
304
261
|
end
|
305
262
|
alias_method :path_to_stylesheet, :stylesheet_path
|
306
263
|
|
@@ -324,7 +281,7 @@ module Sprockets
|
|
324
281
|
# video_path 'http://www.example.com/img/video.mp4' # => 'http://www.example.com/img/video.mp4'
|
325
282
|
#
|
326
283
|
def video_path(source, options = {})
|
327
|
-
asset_path source,
|
284
|
+
asset_path source, sprockets_helpers_settings.default_path_options[:video_path].merge(options)
|
328
285
|
end
|
329
286
|
alias_method :path_to_video, :video_path
|
330
287
|
|
@@ -332,29 +289,48 @@ module Sprockets
|
|
332
289
|
|
333
290
|
# Returns the Sprockets environment #asset_path uses to search for
|
334
291
|
# assets. This can be overridden for more control, if necessary.
|
335
|
-
#
|
292
|
+
# For even more control, you just need to override #sprockets_helper_settings.
|
293
|
+
# Defaults to sprockets_helpers_settings.environment or the environment
|
336
294
|
# returned by #environment.
|
337
295
|
def assets_environment
|
338
|
-
|
296
|
+
sprockets_helpers_settings.environment || environment
|
297
|
+
end
|
298
|
+
|
299
|
+
# Returns the Sprockets helpers settings. This can be overridden for
|
300
|
+
# more control, for instance if you want to support polyinstantiation
|
301
|
+
# in your application.
|
302
|
+
def sprockets_helpers_settings
|
303
|
+
Helpers.settings
|
339
304
|
end
|
340
305
|
|
341
306
|
def find_asset_path(uri, source, options = {})
|
342
|
-
|
343
|
-
|
307
|
+
options = options.merge(:sprockets_helpers_settings => sprockets_helpers_settings,
|
308
|
+
:debug => sprockets_helpers_settings.debug)
|
309
|
+
|
310
|
+
if sprockets_helpers_settings.manifest && options[:manifest] != false
|
311
|
+
manifest_path = sprockets_helpers_settings.manifest.assets[uri.path]
|
344
312
|
return Helpers::ManifestPath.new(uri, manifest_path, options) if manifest_path
|
345
313
|
end
|
346
314
|
|
347
|
-
if Sprockets::Helpers.
|
348
|
-
resolved = assets_environment.resolve(uri.path)
|
315
|
+
if Sprockets::Helpers.are_using_sprockets_4_plus
|
316
|
+
resolved, _ = assets_environment.resolve(uri.path, pipeline: options[:debug] ? :debug : nil)
|
317
|
+
|
318
|
+
if resolved
|
319
|
+
return Helpers::AssetPath.new(uri, assets_environment[uri.path, pipeline: options[:debug] ? :debug : nil], assets_environment, options)
|
320
|
+
else
|
321
|
+
return Helpers::FilePath.new(uri, options)
|
322
|
+
end
|
323
|
+
elsif Sprockets::Helpers.are_using_sprockets_3_plus
|
324
|
+
resolved, _ = assets_environment.resolve(uri.path)
|
349
325
|
|
350
326
|
if resolved
|
351
|
-
return Helpers::AssetPath.new(uri, assets_environment[uri.path], options)
|
327
|
+
return Helpers::AssetPath.new(uri, assets_environment[uri.path], assets_environment, options)
|
352
328
|
else
|
353
329
|
return Helpers::FilePath.new(uri, options)
|
354
330
|
end
|
355
331
|
else
|
356
332
|
assets_environment.resolve(uri.path) do |path|
|
357
|
-
return Helpers::AssetPath.new(uri, assets_environment[path], options)
|
333
|
+
return Helpers::AssetPath.new(uri, assets_environment[path], assets_environment, options)
|
358
334
|
end
|
359
335
|
|
360
336
|
return Helpers::FilePath.new(uri, options)
|
@@ -3,21 +3,31 @@ module Sprockets
|
|
3
3
|
# `AssetPath` generates a full path for an asset
|
4
4
|
# that exists in Sprockets environment.
|
5
5
|
class AssetPath < BasePath
|
6
|
-
def initialize(uri, asset, options = {})
|
6
|
+
def initialize(uri, asset, environment, options = {})
|
7
7
|
@uri = uri
|
8
8
|
@asset = asset
|
9
|
+
@environment = environment
|
10
|
+
@options = options
|
9
11
|
@options = {
|
10
12
|
:body => false,
|
11
|
-
:digest =>
|
12
|
-
:prefix =>
|
13
|
+
:digest => sprockets_helpers_settings.digest,
|
14
|
+
:prefix => sprockets_helpers_settings.prefix
|
13
15
|
}.merge options
|
14
16
|
|
15
17
|
@uri.path = @options[:digest] ? asset.digest_path : asset.logical_path
|
16
18
|
end
|
17
19
|
|
18
20
|
def to_a
|
19
|
-
@asset.to_a
|
20
|
-
|
21
|
+
if @asset.respond_to?(:to_a)
|
22
|
+
@asset.to_a.map do |dependency|
|
23
|
+
AssetPath.new(@uri.clone, dependency, @environment, @options.merge(:body => true)).to_s
|
24
|
+
end
|
25
|
+
elsif @asset.metadata[:included]
|
26
|
+
@asset.metadata[:included].map do |uri|
|
27
|
+
AssetPath.new(@uri.clone, @environment.load(uri), @environment, @options.merge(:body => true)).to_s
|
28
|
+
end
|
29
|
+
else
|
30
|
+
AssetPath.new(@uri.clone, @asset, @environment, @options.merge(:body => true)).to_s
|
21
31
|
end
|
22
32
|
end
|
23
33
|
|
@@ -17,6 +17,10 @@ module Sprockets
|
|
17
17
|
@options = options
|
18
18
|
end
|
19
19
|
|
20
|
+
def sprockets_helpers_settings
|
21
|
+
@options[:sprockets_helpers_settings]
|
22
|
+
end
|
23
|
+
|
20
24
|
# Returns the full path to the asset, complete with
|
21
25
|
# timestamp.
|
22
26
|
def to_s
|
@@ -53,7 +57,7 @@ module Sprockets
|
|
53
57
|
def compute_asset_host # :nodoc:
|
54
58
|
return nil if options[:asset_host] == false
|
55
59
|
|
56
|
-
if host = options[:asset_host] ||
|
60
|
+
if host = options[:asset_host] || sprockets_helpers_settings.asset_host
|
57
61
|
if host.respond_to?(:call)
|
58
62
|
host.call(uri.to_s)
|
59
63
|
elsif host =~ /%d/
|
@@ -69,7 +73,7 @@ module Sprockets
|
|
69
73
|
# Pick a scheme for the protocol if we are using
|
70
74
|
# an asset host.
|
71
75
|
def compute_scheme # :nodoc:
|
72
|
-
protocol = options[:protocol] ||
|
76
|
+
protocol = options[:protocol] || sprockets_helpers_settings.protocol
|
73
77
|
|
74
78
|
if protocol.nil? || protocol == :relative
|
75
79
|
nil
|
@@ -25,7 +25,7 @@ module Sprockets
|
|
25
25
|
# Returns the mtime for the given path (relative to
|
26
26
|
# the output path). Returns nil if the file doesn't exist.
|
27
27
|
def compute_mtime # :nodoc:
|
28
|
-
public_path = File.join(
|
28
|
+
public_path = File.join(sprockets_helpers_settings.public_path, uri.path)
|
29
29
|
|
30
30
|
if File.exist?(public_path)
|
31
31
|
File.mtime(public_path)
|
@@ -5,9 +5,10 @@ module Sprockets
|
|
5
5
|
class ManifestPath < AssetPath
|
6
6
|
def initialize(uri, path, options = {})
|
7
7
|
@uri = uri
|
8
|
+
@options = options
|
8
9
|
@options = {
|
9
10
|
:body => false,
|
10
|
-
:prefix =>
|
11
|
+
:prefix => sprockets_helpers_settings.prefix
|
11
12
|
}.merge options
|
12
13
|
|
13
14
|
@uri.path = path.to_s
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Sprockets
|
2
|
+
module Helpers
|
3
|
+
class Settings
|
4
|
+
# Link to assets from a dedicated server.
|
5
|
+
attr_accessor :asset_host
|
6
|
+
|
7
|
+
# When true, the asset paths will return digest paths.
|
8
|
+
attr_accessor :digest
|
9
|
+
|
10
|
+
# When true, expand assets.
|
11
|
+
attr_accessor :expand
|
12
|
+
|
13
|
+
# When true, force debug mode
|
14
|
+
# :debug => true equals
|
15
|
+
# :expand => true (unless using >= Sprockets 4.0)
|
16
|
+
# :digest => false
|
17
|
+
# :manifest => false
|
18
|
+
attr_accessor :debug
|
19
|
+
|
20
|
+
# Set the Sprockets environment to search for assets.
|
21
|
+
# This defaults to the context's #environment method.
|
22
|
+
attr_accessor :environment
|
23
|
+
|
24
|
+
# The manifest file used for lookup
|
25
|
+
attr_accessor :manifest
|
26
|
+
|
27
|
+
# The base URL the Sprocket environment is mapped to.
|
28
|
+
# This defaults to '/assets'.
|
29
|
+
def prefix
|
30
|
+
@prefix ||= '/assets'
|
31
|
+
@prefix.is_a?(Array) ? "/#{@prefix.first}" : @prefix
|
32
|
+
end
|
33
|
+
attr_writer :prefix
|
34
|
+
|
35
|
+
# Customize the protocol when using asset hosts.
|
36
|
+
# If the value is :relative, A relative protocol ('//')
|
37
|
+
# will be used.
|
38
|
+
def protocol
|
39
|
+
@protocol ||= 'http://'
|
40
|
+
end
|
41
|
+
attr_writer :protocol
|
42
|
+
|
43
|
+
# The path to the public directory, where the assets
|
44
|
+
# not managed by Sprockets will be located.
|
45
|
+
# Defaults to './public'
|
46
|
+
def public_path
|
47
|
+
@public_path ||= './public'
|
48
|
+
end
|
49
|
+
attr_writer :public_path
|
50
|
+
|
51
|
+
# The default options for each asset path method. This is where you
|
52
|
+
# can change your default directories for the fallback directory.
|
53
|
+
def default_path_options
|
54
|
+
@default_path_options ||= {
|
55
|
+
:audio_path => { :dir => 'audios' },
|
56
|
+
:font_path => { :dir => 'fonts' },
|
57
|
+
:image_path => { :dir => 'images' },
|
58
|
+
:javascript_path => { :dir => 'javascripts', :ext => 'js' },
|
59
|
+
:stylesheet_path => { :dir => 'stylesheets', :ext => 'css' },
|
60
|
+
:video_path => { :dir => 'videos' }
|
61
|
+
}
|
62
|
+
end
|
63
|
+
attr_writer :default_path_options
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -536,15 +536,15 @@ describe Sprockets::Helpers do
|
|
536
536
|
|
537
537
|
describe '#javascript_tag' do
|
538
538
|
it 'generates script tag' do
|
539
|
-
expect(context.javascript_tag('/main.js')).to eq('<script src="/main.js"></script>')
|
539
|
+
expect(context.javascript_tag('/main.js')).to eq('<script src="/main.js" type="text/javascript"></script>')
|
540
540
|
end
|
541
541
|
|
542
542
|
it 'appends extension' do
|
543
|
-
expect(context.javascript_tag('/main')).to eq('<script src="/main.js"></script>')
|
543
|
+
expect(context.javascript_tag('/main')).to eq('<script src="/main.js" type="text/javascript"></script>')
|
544
544
|
end
|
545
545
|
|
546
546
|
it 'prepends the javascript dir' do
|
547
|
-
expect(context.javascript_tag('main')).to eq('<script src="/javascripts/main.js"></script>')
|
547
|
+
expect(context.javascript_tag('main')).to eq('<script src="/javascripts/main.js" type="text/javascript"></script>')
|
548
548
|
end
|
549
549
|
|
550
550
|
describe 'when expanding' do
|
@@ -554,9 +554,9 @@ describe Sprockets::Helpers do
|
|
554
554
|
within_construct do |construct|
|
555
555
|
assets_layout(construct)
|
556
556
|
tags = context.javascript_tag('main.js', :expand => true)
|
557
|
-
expect(tags).to include('<script src="/assets/main.self.js?body=1"></script>')
|
558
|
-
expect(tags).to include('<script src="/assets/a.self.js?body=1"></script>')
|
559
|
-
expect(tags).to include('<script src="/assets/b.self.js?body=1"></script>')
|
557
|
+
expect(tags).to include('<script src="/assets/main.self.js?body=1" type="text/javascript"></script>')
|
558
|
+
expect(tags).to include('<script src="/assets/a.self.js?body=1" type="text/javascript"></script>')
|
559
|
+
expect(tags).to include('<script src="/assets/b.self.js?body=1" type="text/javascript"></script>')
|
560
560
|
end
|
561
561
|
end
|
562
562
|
end
|
@@ -568,9 +568,9 @@ describe Sprockets::Helpers do
|
|
568
568
|
assets_layout(construct)
|
569
569
|
tags = context.javascript_tag('main.js', :expand => true)
|
570
570
|
|
571
|
-
expect(tags).to include('<script src="/assets/main.js?body=1"></script>')
|
572
|
-
expect(tags).to include('<script src="/assets/a.js?body=1"></script>')
|
573
|
-
expect(tags).to include('<script src="/assets/b.js?body=1"></script>')
|
571
|
+
expect(tags).to include('<script src="/assets/main.js?body=1" type="text/javascript"></script>')
|
572
|
+
expect(tags).to include('<script src="/assets/a.js?body=1" type="text/javascript"></script>')
|
573
|
+
expect(tags).to include('<script src="/assets/b.js?body=1" type="text/javascript"></script>')
|
574
574
|
end
|
575
575
|
end
|
576
576
|
end
|
@@ -579,19 +579,19 @@ describe Sprockets::Helpers do
|
|
579
579
|
|
580
580
|
describe '#stylesheet_tag' do
|
581
581
|
it 'generates stylesheet tag' do
|
582
|
-
expect(context.stylesheet_tag('/main.css')).to eq('<link rel="stylesheet" href="/main.css">')
|
582
|
+
expect(context.stylesheet_tag('/main.css')).to eq('<link rel="stylesheet" type="text/css" href="/main.css">')
|
583
583
|
end
|
584
584
|
|
585
585
|
it 'appends extension' do
|
586
|
-
expect(context.stylesheet_tag('/main')).to eq('<link rel="stylesheet" href="/main.css">')
|
586
|
+
expect(context.stylesheet_tag('/main')).to eq('<link rel="stylesheet" type="text/css" href="/main.css">')
|
587
587
|
end
|
588
588
|
|
589
589
|
it 'prepends the stylesheets dir' do
|
590
|
-
expect(context.stylesheet_tag('main')).to eq('<link rel="stylesheet" href="/stylesheets/main.css">')
|
590
|
+
expect(context.stylesheet_tag('main')).to eq('<link rel="stylesheet" type="text/css" href="/stylesheets/main.css">')
|
591
591
|
end
|
592
592
|
|
593
593
|
it 'uses media attribute when provided' do
|
594
|
-
expect(context.stylesheet_tag('main', :media => "print")).to eq('<link rel="stylesheet" href="/stylesheets/main.css" media="print">')
|
594
|
+
expect(context.stylesheet_tag('main', :media => "print")).to eq('<link rel="stylesheet" type="text/css" href="/stylesheets/main.css" media="print">')
|
595
595
|
end
|
596
596
|
|
597
597
|
describe 'when expanding' do
|
@@ -601,9 +601,9 @@ describe Sprockets::Helpers do
|
|
601
601
|
within_construct do |construct|
|
602
602
|
assets_layout(construct)
|
603
603
|
tags = context.stylesheet_tag('main.css', :expand => true)
|
604
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/main.self.css?body=1">')
|
605
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/a.self.css?body=1">')
|
606
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/b.self.css?body=1">')
|
604
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/main.self.css?body=1">')
|
605
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/a.self.css?body=1">')
|
606
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/b.self.css?body=1">')
|
607
607
|
end
|
608
608
|
end
|
609
609
|
end
|
@@ -614,9 +614,9 @@ describe Sprockets::Helpers do
|
|
614
614
|
within_construct do |construct|
|
615
615
|
assets_layout(construct)
|
616
616
|
tags = context.stylesheet_tag('main.css', :expand => true)
|
617
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/main.css?body=1">')
|
618
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/a.css?body=1">')
|
619
|
-
expect(tags).to include('<link rel="stylesheet" href="/assets/b.css?body=1">')
|
617
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/main.css?body=1">')
|
618
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/a.css?body=1">')
|
619
|
+
expect(tags).to include('<link rel="stylesheet" type="text/css" href="/assets/b.css?body=1">')
|
620
620
|
end
|
621
621
|
end
|
622
622
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Browne
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- gemfiles/sprockets_3.0.gemfile
|
121
121
|
- gemfiles/sprockets_3.1.gemfile
|
122
122
|
- gemfiles/sprockets_3.2.gemfile
|
123
|
+
- gemfiles/sprockets_4.0.gemfile
|
123
124
|
- lib/sinatra/sprockets-helpers.rb
|
124
125
|
- lib/sinatra/sprockets/helpers.rb
|
125
126
|
- lib/sprockets-helpers.rb
|
@@ -128,6 +129,7 @@ files:
|
|
128
129
|
- lib/sprockets/helpers/base_path.rb
|
129
130
|
- lib/sprockets/helpers/file_path.rb
|
130
131
|
- lib/sprockets/helpers/manifest_path.rb
|
132
|
+
- lib/sprockets/helpers/settings.rb
|
131
133
|
- lib/sprockets/helpers/version.rb
|
132
134
|
- spec/spec_helper.rb
|
133
135
|
- spec/sprockets-helpers_spec.rb
|
@@ -136,7 +138,7 @@ homepage: https://github.com/petebrowne/sprockets-helpers
|
|
136
138
|
licenses:
|
137
139
|
- MIT
|
138
140
|
metadata: {}
|
139
|
-
post_install_message:
|
141
|
+
post_install_message:
|
140
142
|
rdoc_options: []
|
141
143
|
require_paths:
|
142
144
|
- lib
|
@@ -151,9 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
153
|
- !ruby/object:Gem::Version
|
152
154
|
version: '0'
|
153
155
|
requirements: []
|
154
|
-
|
155
|
-
|
156
|
-
signing_key:
|
156
|
+
rubygems_version: 3.0.3
|
157
|
+
signing_key:
|
157
158
|
specification_version: 4
|
158
159
|
summary: Asset path helpers for Sprockets 2.x & 3.x applications
|
159
160
|
test_files:
|