sprockets-helpers 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +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 +3 -3
- data/lib/sprockets/helpers/asset_path.rb +12 -3
- data/lib/sprockets/helpers/version.rb +3 -1
- data/spec/sprockets-helpers_spec.rb +19 -19
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91a536e9415ef30fb8bc7e40401a72d0874b9a7df7bbc377934f1a69459860d7
|
4
|
+
data.tar.gz: 15ef2327c79b8bb7e8e92fd1a31516c2fa94c58d2918bc7459dab0351e11b158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f345f8b35a2251db14f02f0c1fc6e1bafc9eace650761b80a675374810f65a697db7ef710b1a129422df9a0c1fe22b78685c810b44119953543be50b39f186ba
|
7
|
+
data.tar.gz: a8cc249ea9d27ac7160c73d07ad8f39fcad25a66a2f8cb1187d39a2898dde5a7c1a8205cff4050369014d9e9064d076c21fc8d7b47f9ae97ab8431f4ac0d825b
|
data/Appraisals
CHANGED
data/lib/sprockets/helpers.rb
CHANGED
@@ -345,16 +345,16 @@ module Sprockets
|
|
345
345
|
end
|
346
346
|
|
347
347
|
if Sprockets::Helpers.are_using_sprockets_3
|
348
|
-
resolved = assets_environment.resolve(uri.path)
|
348
|
+
resolved, _ = assets_environment.resolve(uri.path)
|
349
349
|
|
350
350
|
if resolved
|
351
|
-
return Helpers::AssetPath.new(uri, assets_environment[uri.path], options)
|
351
|
+
return Helpers::AssetPath.new(uri, assets_environment[uri.path], assets_environment, options)
|
352
352
|
else
|
353
353
|
return Helpers::FilePath.new(uri, options)
|
354
354
|
end
|
355
355
|
else
|
356
356
|
assets_environment.resolve(uri.path) do |path|
|
357
|
-
return Helpers::AssetPath.new(uri, assets_environment[path], options)
|
357
|
+
return Helpers::AssetPath.new(uri, assets_environment[path], assets_environment, options)
|
358
358
|
end
|
359
359
|
|
360
360
|
return Helpers::FilePath.new(uri, options)
|
@@ -3,9 +3,10 @@ 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
|
9
10
|
@options = {
|
10
11
|
:body => false,
|
11
12
|
:digest => Helpers.digest,
|
@@ -16,8 +17,16 @@ module Sprockets
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def to_a
|
19
|
-
@asset.to_a
|
20
|
-
|
20
|
+
if @asset.respond_to?(:to_a)
|
21
|
+
@asset.to_a.map do |dependency|
|
22
|
+
AssetPath.new(@uri.clone, dependency, @environment, @options.merge(:body => true)).to_s
|
23
|
+
end
|
24
|
+
elsif @asset.metadata[:included]
|
25
|
+
@asset.metadata[:included].map do |uri|
|
26
|
+
AssetPath.new(@uri.clone, @environment.load(uri), @environment, @options.merge(:body => true)).to_s
|
27
|
+
end
|
28
|
+
else
|
29
|
+
AssetPath.new(@uri.clone, @asset, @environment, @options.merge(:body => true)).to_s
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
@@ -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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Browne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-23 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
|