js-asset_paths 0.3.2 → 0.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 +4 -4
- data/lib/js-asset_paths.rb +4 -2
- data/test/unit/digest_values_test.rb +39 -0
- data/test/{lib → unit}/engine_test.rb +0 -0
- data/test/{lib → unit}/generator_test.rb +4 -2
- data/test/unit/js_asset_paths_test.rb +8 -0
- data/test/unit/output_test.rb +45 -0
- metadata +27 -9
- data/test/integration/bundler_gem_require_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3c8c8ad421a0fd846b3adf40103130df0f7d4e5
|
4
|
+
data.tar.gz: fb8b888dbd741ce89d2dd1a38468da0e947f907c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 622731a9e97041a459ce39fe7585c81bda1b7451986d97541ceee34115ecc73063351581c6c585e35391f7dbae2a0b45ef2f92e8a9c07330a0820bec002c814d
|
7
|
+
data.tar.gz: 5b3154fbf5e5e370281082256f592c134973b14963192bf22beb6a98730617484459fc3f97992dac662d02454f0b94f3ae5a37a74b268199781438bf37be6c78
|
data/lib/js-asset_paths.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
require 'action_view/helpers/asset_url_helper'
|
2
|
-
|
3
1
|
require 'js_asset_paths/version'
|
4
2
|
require 'js_asset_paths/engine'
|
5
3
|
require 'js_asset_paths/generator'
|
4
|
+
|
5
|
+
module JsAssetPaths
|
6
|
+
ASSET_METHODS = ActionView::Helpers::AssetUrlHelper.public_instance_methods.grep(/^((?!.*asset)[a-z]+)_path$/)
|
7
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
|
4
|
+
describe 'untrue values of config.assets.digest' do
|
5
|
+
before do
|
6
|
+
App.initialize! unless App.initialized?
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'output has corresponding key and value pairs when digest is false' do
|
10
|
+
begin
|
11
|
+
Rails.application.config.assets.digest = false
|
12
|
+
|
13
|
+
JsAssetPaths::Generator.environment = Rails.application
|
14
|
+
@output = JsAssetPaths::Generator.generate!
|
15
|
+
|
16
|
+
map = ExecJS.eval(@output)
|
17
|
+
|
18
|
+
map.each do |key, value|
|
19
|
+
file = key.split('/').second
|
20
|
+
assert_equal file, value
|
21
|
+
end
|
22
|
+
|
23
|
+
ensure
|
24
|
+
Rails.application.config.assets.digest = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'output has corresponding key and value pairs when digest is not boolean' do
|
29
|
+
begin
|
30
|
+
Rails.application.config.assets.digest = :foo
|
31
|
+
|
32
|
+
JsAssetPaths::Generator.environment = Rails.application
|
33
|
+
|
34
|
+
assert_raises(TypeError) { JsAssetPaths::Generator.generate! }
|
35
|
+
ensure
|
36
|
+
Rails.application.config.assets.digest = true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
File without changes
|
@@ -25,14 +25,16 @@ describe JsAssetPaths::Generator do
|
|
25
25
|
assert_kind_of Hash, ExecJS.eval(@output)
|
26
26
|
end
|
27
27
|
|
28
|
-
it 'output has corresponding key and value pairs' do
|
28
|
+
it 'output has corresponding key and value pairs when digest' do
|
29
|
+
assert App.config.assets.digest
|
30
|
+
|
29
31
|
map = ExecJS.eval(@output)
|
30
32
|
|
31
33
|
map.each do |key, value|
|
32
34
|
file = key.split('/').second
|
33
35
|
name, _, ext = file.rpartition('.')
|
34
36
|
|
35
|
-
assert_match /#{name}-[0-9,a-z]{64}.#{ext}
|
37
|
+
assert_match (/#{name}-[0-9,a-z]{64}.#{ext}/), value
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
|
4
|
+
describe 'generated javascript' do
|
5
|
+
before do
|
6
|
+
App.initialize! unless App.initialized?
|
7
|
+
JsAssetPaths::Generator.environment = Rails.application
|
8
|
+
|
9
|
+
js_file_contents = ERB.new(File.read('app/assets/javascripts/js-asset_paths.js.erb')).result(binding)
|
10
|
+
@js_context = ExecJS.compile(js_file_contents)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'PathHelper is an object' do
|
14
|
+
assert_equal 'object', @js_context.eval('typeof PathHelper')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'PathHelper.assetPath is a function' do
|
18
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.assetPath')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'PathHelper.fontPath is a function' do
|
22
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.fontPath')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'PathHelper.imagePath is a function' do
|
26
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.imagePath')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'PathHelper.javascriptPath is a function' do
|
30
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.javascriptPath')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'PathHelper.stylesheetPath is a function' do
|
34
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.stylesheetPath')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'PathHelper.videoPath is a function' do
|
38
|
+
assert_equal 'function', @js_context.eval('typeof PathHelper.videoPath')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'has the correct number of public functions' do
|
42
|
+
assert_equal JsAssetPaths::ASSET_METHODS.length + 1,
|
43
|
+
@js_context.eval('Object.keys(PathHelper).length')
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js-asset_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sonny Michaud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,7 +114,21 @@ dependencies:
|
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
-
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: codeclimate-test-reporter
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1'
|
131
|
+
description:
|
118
132
|
email:
|
119
133
|
- michaud.sonny@gmail.com
|
120
134
|
executables: []
|
@@ -123,9 +137,11 @@ extra_rdoc_files: []
|
|
123
137
|
files:
|
124
138
|
- lib/js-asset_paths.rb
|
125
139
|
- lib/js_asset_paths.rb
|
126
|
-
- test/
|
127
|
-
- test/
|
128
|
-
- test/
|
140
|
+
- test/unit/digest_values_test.rb
|
141
|
+
- test/unit/engine_test.rb
|
142
|
+
- test/unit/generator_test.rb
|
143
|
+
- test/unit/js_asset_paths_test.rb
|
144
|
+
- test/unit/output_test.rb
|
129
145
|
homepage: https://github.com/sonnym/js-asset_paths
|
130
146
|
licenses:
|
131
147
|
- MIT
|
@@ -151,6 +167,8 @@ signing_key:
|
|
151
167
|
specification_version: 4
|
152
168
|
summary: Access paths to compiled assets from in javascript.
|
153
169
|
test_files:
|
154
|
-
- test/
|
155
|
-
- test/
|
156
|
-
- test/
|
170
|
+
- test/unit/engine_test.rb
|
171
|
+
- test/unit/generator_test.rb
|
172
|
+
- test/unit/digest_values_test.rb
|
173
|
+
- test/unit/js_asset_paths_test.rb
|
174
|
+
- test/unit/output_test.rb
|