asset_symlink 0.3.0 → 0.3.1

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
- SHA1:
3
- metadata.gz: 0f653f11927575868c5293b464c465a120147d03
4
- data.tar.gz: 1e3b4df540e8af8cda325e4374bb900e6aebf922
2
+ SHA256:
3
+ metadata.gz: 995bdeda8031a07c821d7d49c77e06e2ed0ce7657d13086f15a83f36b2e99bf7
4
+ data.tar.gz: 867bab482dea0f5bc0f0274b6265e22eacff2fc7a3af8651d9c518be55550257
5
5
  SHA512:
6
- metadata.gz: 2259de8c1a1dc937267f9904d495604a95998bce634ec51434da8e109ed476d26795f6f7b6249eadc2e27da903d7cef8588f25d5ace924a1dd07703ab6c75afb
7
- data.tar.gz: c5fa5908996b9129b678ba3f18ffe0243a731c0e2b12a1e3dcfda8e83173a7120e972c7e05479d22304da9c4b48d7bacf8018776d443732c467c5e85d399a486
6
+ metadata.gz: 986054a9a3ff531ea17b0b2bf9c5667dab9c006cfbc9a6681fd00d476e29948d68edb44ff6f96ff45682c3b71fd2bc1d1f88ca567ba61d56979dd82584f2a75b
7
+ data.tar.gz: a1f8ba4c7dcb1e91b723282c0f2dd3a1279de457adc52fa85169040963d7fa03037e221edb2d59b4c16672e879dc09b50324cf59ad664bdeb253ead8981b25e2
data/.travis.yml CHANGED
@@ -1,11 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- - 2.3.5
5
- - 2.4.2
3
+ - 2.4.6
4
+ - 2.5.5
6
5
  install: bundle install
7
6
  gemfile:
8
7
  - gemfiles/4.2.10.gemfile
9
8
  - gemfiles/5.0.gemfile
10
9
  - gemfiles/5.1.gemfile
10
+ - gemfiles/5.2.gemfile
11
+
11
12
  script: "bundle exec rake spec"
data/Appraisals CHANGED
@@ -2,7 +2,7 @@ appraise "4.2.10" do
2
2
  gem "rails", "4.2.10"
3
3
  end
4
4
 
5
- (0..1).each do |version|
5
+ (0..2).each do |version|
6
6
  appraise "5.#{version}" do
7
7
  gem "rails", "~> 5.#{version}.0"
8
8
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "appraisal"
22
- spec.add_runtime_dependency "rails", '>=4', '<5.2'
22
+ spec.add_runtime_dependency "rails", '>=4', '< 6.0'
23
23
  spec.add_development_dependency "bundler", "~> 1.5"
24
24
  spec.add_development_dependency "rake", '< 11.0'
25
25
  spec.add_development_dependency "rspec", "~>2.14.0"
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ..
3
3
  specs:
4
4
  asset_symlink (0.3.0)
5
- rails (>= 4, < 5.2)
5
+ rails (>= 4, <= 5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -125,4 +125,4 @@ DEPENDENCIES
125
125
  rspec (~> 2.14.0)
126
126
 
127
127
  BUNDLED WITH
128
- 1.16.0
128
+ 1.17.1
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ..
3
3
  specs:
4
4
  asset_symlink (0.3.0)
5
- rails (>= 4, < 5.2)
5
+ rails (>= 4, <= 5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -132,4 +132,4 @@ DEPENDENCIES
132
132
  rspec (~> 2.14.0)
133
133
 
134
134
  BUNDLED WITH
135
- 1.16.0
135
+ 1.17.1
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ..
3
3
  specs:
4
4
  asset_symlink (0.3.0)
5
- rails (>= 4, < 5.2)
5
+ rails (>= 4, <= 5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -132,4 +132,4 @@ DEPENDENCIES
132
132
  rspec (~> 2.14.0)
133
133
 
134
134
  BUNDLED WITH
135
- 1.16.0
135
+ 1.17.1
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.2.0"
6
+ gem "appraisal"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ asset_symlink (0.3.0)
5
+ rails (>= 4, <= 5.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.0)
11
+ actionpack (= 5.2.0)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.0)
15
+ actionpack (= 5.2.0)
16
+ actionview (= 5.2.0)
17
+ activejob (= 5.2.0)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.0)
21
+ actionview (= 5.2.0)
22
+ activesupport (= 5.2.0)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.0)
28
+ activesupport (= 5.2.0)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.0)
34
+ activesupport (= 5.2.0)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.0)
37
+ activesupport (= 5.2.0)
38
+ activerecord (5.2.0)
39
+ activemodel (= 5.2.0)
40
+ activesupport (= 5.2.0)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.0)
43
+ actionpack (= 5.2.0)
44
+ activerecord (= 5.2.0)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.0)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ appraisal (2.2.0)
52
+ bundler
53
+ rake
54
+ thor (>= 0.14.0)
55
+ arel (9.0.0)
56
+ builder (3.2.3)
57
+ concurrent-ruby (1.1.3)
58
+ crass (1.0.4)
59
+ diff-lcs (1.3)
60
+ erubi (1.7.1)
61
+ globalid (0.4.1)
62
+ activesupport (>= 4.2.0)
63
+ i18n (1.1.1)
64
+ concurrent-ruby (~> 1.0)
65
+ loofah (2.2.3)
66
+ crass (~> 1.0.2)
67
+ nokogiri (>= 1.5.9)
68
+ mail (2.7.1)
69
+ mini_mime (>= 0.1.1)
70
+ marcel (0.3.3)
71
+ mimemagic (~> 0.3.2)
72
+ method_source (0.9.1)
73
+ mimemagic (0.3.2)
74
+ mini_mime (1.0.1)
75
+ mini_portile2 (2.3.0)
76
+ minitest (5.11.3)
77
+ nio4r (2.3.1)
78
+ nokogiri (1.8.5)
79
+ mini_portile2 (~> 2.3.0)
80
+ rack (2.0.6)
81
+ rack-test (1.1.0)
82
+ rack (>= 1.0, < 3)
83
+ rails (5.2.0)
84
+ actioncable (= 5.2.0)
85
+ actionmailer (= 5.2.0)
86
+ actionpack (= 5.2.0)
87
+ actionview (= 5.2.0)
88
+ activejob (= 5.2.0)
89
+ activemodel (= 5.2.0)
90
+ activerecord (= 5.2.0)
91
+ activestorage (= 5.2.0)
92
+ activesupport (= 5.2.0)
93
+ bundler (>= 1.3.0)
94
+ railties (= 5.2.0)
95
+ sprockets-rails (>= 2.0.0)
96
+ rails-dom-testing (2.0.3)
97
+ activesupport (>= 4.2.0)
98
+ nokogiri (>= 1.6)
99
+ rails-html-sanitizer (1.0.4)
100
+ loofah (~> 2.2, >= 2.2.2)
101
+ railties (5.2.0)
102
+ actionpack (= 5.2.0)
103
+ activesupport (= 5.2.0)
104
+ method_source
105
+ rake (>= 0.8.7)
106
+ thor (>= 0.18.1, < 2.0)
107
+ rake (10.5.0)
108
+ rspec (2.14.1)
109
+ rspec-core (~> 2.14.0)
110
+ rspec-expectations (~> 2.14.0)
111
+ rspec-mocks (~> 2.14.0)
112
+ rspec-core (2.14.8)
113
+ rspec-expectations (2.14.5)
114
+ diff-lcs (>= 1.1.3, < 2.0)
115
+ rspec-mocks (2.14.6)
116
+ sprockets (3.7.2)
117
+ concurrent-ruby (~> 1.0)
118
+ rack (> 1, < 3)
119
+ sprockets-rails (3.2.1)
120
+ actionpack (>= 4.0)
121
+ activesupport (>= 4.0)
122
+ sprockets (>= 3.0.0)
123
+ thor (0.20.0)
124
+ thread_safe (0.3.6)
125
+ tzinfo (1.2.5)
126
+ thread_safe (~> 0.1)
127
+ websocket-driver (0.7.0)
128
+ websocket-extensions (>= 0.1.0)
129
+ websocket-extensions (0.1.3)
130
+
131
+ PLATFORMS
132
+ ruby
133
+
134
+ DEPENDENCIES
135
+ appraisal
136
+ asset_symlink!
137
+ bundler (~> 1.5)
138
+ rails (~> 5.2.0)
139
+ rake (< 11.0)
140
+ rspec (~> 2.14.0)
141
+
142
+ BUNDLED WITH
143
+ 1.17.1
data/lib/asset_symlink.rb CHANGED
@@ -11,7 +11,7 @@ module AssetSymlink
11
11
  Sprockets::Railtie.build_manifest(Rails.application)
12
12
  else
13
13
  Rails.application.assets_manifest
14
- end
14
+ end
15
15
  manifest.assets[private_name]
16
16
  end
17
17
  digested_location = Rails.root.join('public','assets', asset)
@@ -27,11 +27,20 @@ module AssetSymlink
27
27
 
28
28
  def self.normalize_configuration config
29
29
  case config
30
- when Hash
30
+ when :all
31
+ result = {}
32
+ manifest_file = Rails.application.config.assets.manifest
33
+ if manifest_file.nil?
34
+ raise ArgumentError, "please set config.assets.manifest = 'path/to/your/manifest.json'"
35
+ end
36
+ JSON.parse(File.read(manifest_file))["files"].map do |digested_name, value|
37
+ [value['logical_path'], value['logical_path']]
38
+ end.to_h
39
+ when Hash
31
40
  config
32
41
  when String
33
42
  {config => config}
34
- when Array
43
+ when Array
35
44
  config.inject({}) do |result, element|
36
45
  result.merge(normalize_configuration(element))
37
46
  end
@@ -1,3 +1,3 @@
1
1
  module AssetSymlink
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -4,20 +4,27 @@ describe AssetSymlink do
4
4
 
5
5
  describe 'execute' do
6
6
  let(:sandbox) {File.join(File.dirname(__FILE__),'..','tmp')}
7
+ let(:manifest) {File.join(sandbox, 'manifest.json')}
7
8
  let(:assets) {Pathname.new(sandbox).join('public', 'assets')}
8
9
 
9
10
  before(:each) do
10
11
  FileUtils.rm_rf assets, :secure => true
11
12
  FileUtils.mkdir_p(assets)
12
13
  @assets_stub = double()
14
+ Rails.stub_chain(:application,:config,:assets,:manifest => manifest)
13
15
  Rails.stub_chain(:application,:assets => @assets_stub)
14
16
  Rails.stub(:root).and_return(Pathname.new(sandbox))
17
+ File.open(manifest, 'w'){ |f| f.write({"files" => {}}.to_json) }
15
18
  end
16
19
 
17
20
  def add_fake_asset(name, location)
18
21
  @assets_stub.stub(:find_asset).with(name).and_return(double(:digest_path => location))
19
22
  FileUtils.mkdir_p(assets.join(location).dirname)
20
23
  File.open(assets.join(location), 'w'){}
24
+ manifest_hash = JSON.parse(File.read(manifest))
25
+ manifest_hash["files"][location] = {}
26
+ manifest_hash["files"][location]["logical_path"] = name
27
+ File.open(manifest, 'w'){ |f| f.write(manifest_hash.to_json) }
21
28
  end
22
29
 
23
30
  it 'should symlink items at the top level of the assets folder' do
@@ -46,6 +53,14 @@ describe AssetSymlink do
46
53
  AssetSymlink.execute('widget.js')
47
54
  expect(assets.join('widget.js')).to be_a_symlink_to('widget-abc123.js')
48
55
  end
56
+
57
+ it 'should create all asset symlinks by manifest.json' do
58
+ add_fake_asset('external/widget.js', 'external/widget-abc123.js')
59
+ add_fake_asset('external/widget1.js', 'external/widget-abc1234.js')
60
+ AssetSymlink.execute(:all)
61
+ expect(assets.join('external/widget.js')).to be_a_symlink_to('widget-abc123.js')
62
+ expect(assets.join('external/widget1.js')).to be_a_symlink_to('widget-abc1234.js')
63
+ end
49
64
  end
50
65
 
51
66
  describe 'normalize_configuration' do
@@ -66,7 +81,7 @@ describe AssetSymlink do
66
81
  end
67
82
 
68
83
  it 'should convert an array of hashes by merging them' do
69
- AssetSymlink.normalize_configuration([{'foo.js' => 'v1/foo.js'},
84
+ AssetSymlink.normalize_configuration([{'foo.js' => 'v1/foo.js'},
70
85
  {'bar.js' => 'v1/bar.js'}]).should == {'foo.js' => 'v1/foo.js',
71
86
  'bar.js' => 'v1/bar.js'}
72
87
  end
@@ -80,4 +95,4 @@ describe AssetSymlink do
80
95
  expect {AssetSymlink.normalize_configuration([1])}.to raise_error(ArgumentError)
81
96
  end
82
97
  end
83
- end
98
+ end
@@ -5,12 +5,12 @@ describe 'Integration specs' do
5
5
  end
6
6
  let(:assets) {test_app_location.join('public', 'assets')}
7
7
  def run_in_test_app(command)
8
- Dir.chdir(test_app_location) do
8
+ Dir.chdir(test_app_location) do
9
9
  output = Kernel.send :`,command
10
10
  raise output unless $? == 0
11
11
  end
12
12
  end
13
-
13
+
14
14
  before :all do
15
15
  FileUtils.rm_rf(test_app_location.join('public', 'assets'))
16
16
  run_in_test_app('rake assets:precompile 2>&1')
@@ -29,4 +29,4 @@ describe 'Integration specs' do
29
29
  def find_asset_name(path)
30
30
  File.basename(Dir.chdir(assets) { Dir.glob(path).first })
31
31
  end
32
- end
32
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_symlink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederick Cheung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '4'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '5.2'
36
+ version: '6.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '4'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '5.2'
46
+ version: '6.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,8 @@ files:
107
107
  - gemfiles/5.0.gemfile.lock
108
108
  - gemfiles/5.1.gemfile
109
109
  - gemfiles/5.1.gemfile.lock
110
+ - gemfiles/5.2.gemfile
111
+ - gemfiles/5.2.gemfile.lock
110
112
  - lib/asset_symlink.rb
111
113
  - lib/asset_symlink/railtie.rb
112
114
  - lib/asset_symlink/tasks/symlink.rake
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  version: '0'
166
168
  requirements: []
167
169
  rubyforge_project:
168
- rubygems_version: 2.6.14
170
+ rubygems_version: 2.7.6.2
169
171
  signing_key:
170
172
  specification_version: 4
171
173
  summary: easily make assets available under a consistent public name