dassets 0.14.4 → 0.14.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/dassets.rb +6 -2
- data/lib/dassets/server/request.rb +1 -1
- data/lib/dassets/version.rb +1 -1
- data/test/unit/dassets_tests.rb +17 -3
- data/test/unit/server/request_tests.rb +4 -5
- data/test/unit/server/response_tests.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
data.tar.gz: 434e3a03c8c5bd4b34ae7bb48feb16cd98a6e2e0
|
4
|
-
metadata.gz: d6cc4fb4b577a182a90b73e1bfa682d231f11d9f
|
5
2
|
SHA512:
|
6
|
-
|
7
|
-
|
3
|
+
metadata.gz: 6c67ff2dc34e83e2aad70042aa2c8cb97ab7fe0fc62999965795f993843c4ba7d600bf398edb2ff7dc5723047903b2053f42ed88c932588ea0a6da884225069d
|
4
|
+
data.tar.gz: 1eb545fcb9b88bfef7d310132b9488e5237fa6cd64ed16c51d3e57a55d2749ed98de18623eadbc6ad18de68a14c27584c5cb742ff46befce8c8df72c332ab0e1
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: 283666dcd8471f7e2e66482e6777457894373451
|
7
|
+
data.tar.gz: 9c213ba859d5bd3b3bd0ba24f57c1f4d746284b0
|
data/lib/dassets.rb
CHANGED
@@ -20,8 +20,12 @@ module Dassets
|
|
20
20
|
self.config.reset
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.asset_file(digest_path)
|
24
|
+
@asset_files[digest_path] ||= AssetFile.new(digest_path)
|
25
|
+
end
|
26
|
+
|
23
27
|
def self.[](digest_path)
|
24
|
-
|
28
|
+
self.asset_file(digest_path).tap do |af|
|
25
29
|
if af.fingerprint.nil?
|
26
30
|
msg = "error digesting `#{digest_path}`.\n\nMake sure Dassets has " \
|
27
31
|
"either a combination or source file for this digest path. If " \
|
@@ -36,7 +40,7 @@ module Dassets
|
|
36
40
|
values = Dassets.combinations[key].sort
|
37
41
|
msg << (
|
38
42
|
["#{bullet}#{values.first}"] +
|
39
|
-
values[1..-1].map{ |v| "#{' '*bullet.size}#{v}" }
|
43
|
+
(values[1..-1] || []).map{ |v| "#{' '*bullet.size}#{v}" }
|
40
44
|
).join("\n")
|
41
45
|
msg << "\n\n"
|
42
46
|
end
|
data/lib/dassets/version.rb
CHANGED
data/test/unit/dassets_tests.rb
CHANGED
@@ -11,7 +11,7 @@ module Dassets
|
|
11
11
|
subject{ Dassets }
|
12
12
|
|
13
13
|
should have_imeths :config, :configure, :init, :reset
|
14
|
-
should have_imeths :[], :source_files, :combinations
|
14
|
+
should have_imeths :asset_file, :[], :source_files, :combinations
|
15
15
|
|
16
16
|
should "return a `Config` instance with the `config` method" do
|
17
17
|
assert_kind_of Config, subject.config
|
@@ -30,15 +30,26 @@ module Dassets
|
|
30
30
|
assert_true config_reset_called
|
31
31
|
end
|
32
32
|
|
33
|
-
should "return asset files given
|
33
|
+
should "return asset files given their digest path " do
|
34
|
+
file = subject.asset_file('nested/file3.txt')
|
35
|
+
|
36
|
+
assert_kind_of subject::AssetFile, file
|
37
|
+
assert_equal 'nested/file3.txt', file.digest_path
|
38
|
+
assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.fingerprint
|
39
|
+
|
34
40
|
file = subject['nested/file3.txt']
|
35
41
|
|
36
42
|
assert_kind_of subject::AssetFile, file
|
37
|
-
assert_equal 'nested/file3.txt',
|
43
|
+
assert_equal 'nested/file3.txt', file.digest_path
|
38
44
|
assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.fingerprint
|
39
45
|
end
|
40
46
|
|
41
47
|
should "cache asset files" do
|
48
|
+
file1 = subject.asset_file('nested/file3.txt')
|
49
|
+
file2 = subject.asset_file('nested/file3.txt')
|
50
|
+
|
51
|
+
assert_same file2, file1
|
52
|
+
|
42
53
|
file1 = subject['nested/file3.txt']
|
43
54
|
file2 = subject['nested/file3.txt']
|
44
55
|
|
@@ -46,6 +57,9 @@ module Dassets
|
|
46
57
|
end
|
47
58
|
|
48
59
|
should "complain if digest path is not found using the index operator" do
|
60
|
+
assert_nothing_raised do
|
61
|
+
subject.asset_file('path/not/found.txt')
|
62
|
+
end
|
49
63
|
assert_raises AssetFileError do
|
50
64
|
subject['path/not/found.txt']
|
51
65
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'assert'
|
2
2
|
require 'dassets/server/request'
|
3
3
|
|
4
|
-
require 'dassets'
|
5
4
|
require 'dassets/asset_file'
|
6
5
|
|
7
6
|
class Dassets::Server::Request
|
@@ -58,16 +57,16 @@ class Dassets::Server::Request
|
|
58
57
|
req = file_request('GET', '/some-file.txt')
|
59
58
|
assert_not req.for_asset_file?
|
60
59
|
|
61
|
-
#
|
60
|
+
# not find an unknown file with a valid fingerprint
|
62
61
|
req = file_request('GET', '/some-file-daa05c683a4913b268653f7a7e36a5b4.txt')
|
63
|
-
|
62
|
+
assert_not req.for_asset_file?
|
64
63
|
end
|
65
64
|
|
66
|
-
should "return an
|
65
|
+
should "return an empty path and file if request not for an asset file" do
|
67
66
|
req = file_request('GET', '/some-file.txt')
|
68
67
|
|
69
68
|
assert_equal '', req.asset_path
|
70
|
-
|
69
|
+
assert_equal Dassets::AssetFile.new(''), req.asset_file
|
71
70
|
end
|
72
71
|
|
73
72
|
protected
|
@@ -2,7 +2,6 @@ require 'assert'
|
|
2
2
|
require 'dassets/server/response'
|
3
3
|
|
4
4
|
require 'rack/utils'
|
5
|
-
require 'dassets'
|
6
5
|
require 'dassets/asset_file'
|
7
6
|
|
8
7
|
class Dassets::Server::Response
|
@@ -60,9 +59,13 @@ class Dassets::Server::Response
|
|
60
59
|
end
|
61
60
|
|
62
61
|
should "handle not found files" do
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
af = Dassets.asset_file('not-found-file.txt')
|
63
|
+
resp = Dassets::Server::Response.new(@env, af)
|
64
|
+
|
65
|
+
assert_equal 404, resp.status
|
66
|
+
assert_equal ['Not Found'], resp.body
|
67
|
+
assert_equal Rack::Utils::HeaderHash.new, resp.headers
|
68
|
+
assert_equal [404, {}, ['Not Found']], resp.to_rack
|
66
69
|
end
|
67
70
|
|
68
71
|
end
|