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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb9ec997921585c4bd0ef6818de7e925be9495dafbcfd10a199bee5475801a32
4
- data.tar.gz: 9a48688a2b80d12d47f5a5f8940b513bd542d0a218472bd4f9741104560e2392
3
+ metadata.gz: 91a536e9415ef30fb8bc7e40401a72d0874b9a7df7bbc377934f1a69459860d7
4
+ data.tar.gz: 15ef2327c79b8bb7e8e92fd1a31516c2fa94c58d2918bc7459dab0351e11b158
5
5
  SHA512:
6
- metadata.gz: fb10f54a0d1905245a75687838d827784cb5804b6579d30007e03851d06c6821e2c87c274b019a1cffe8ad29e862bd42a9a642d665cd991c78bbe293c4a1bc7e
7
- data.tar.gz: fbd9955d3e219fcda0d213957591bf39cf7c6f8da05e5d25e523cbcee60f41b5efcb000c13d0a69bd03ff1f7b71f7b1a68b342db098c88b091bfdbcb641a5731
6
+ metadata.gz: f345f8b35a2251db14f02f0c1fc6e1bafc9eace650761b80a675374810f65a697db7ef710b1a129422df9a0c1fe22b78685c810b44119953543be50b39f186ba
7
+ data.tar.gz: a8cc249ea9d27ac7160c73d07ad8f39fcad25a66a2f8cb1187d39a2898dde5a7c1a8205cff4050369014d9e9064d076c21fc8d7b47f9ae97ab8431f4ac0d825b
data/Appraisals CHANGED
@@ -40,4 +40,8 @@ end
40
40
 
41
41
  appraise 'sprockets-3.2' do
42
42
  gem 'sprockets', '~> 3.2.0'
43
- end
43
+ end
44
+
45
+ appraise 'sprockets-4.0' do
46
+ gem 'sprockets', '~> 4.0.0'
47
+ end
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.3.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.4.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.5.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.6.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.7.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.8.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 2.9.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 3.0.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 3.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "sprockets", "~> 3.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sprockets", "~> 4.0.0"
6
+
7
+ gemspec path: "../"
@@ -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.map do |dependency|
20
- AssetPath.new(@uri.clone, dependency, @options.merge(:body => true)).to_s
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
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sprockets
2
4
  module Helpers
3
- VERSION = '1.2.3'.freeze
5
+ VERSION = '1.3.0'
4
6
  end
5
7
  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.2.3
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-03-26 00:00:00.000000000 Z
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