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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- data.tar.gz: 434e3a03c8c5bd4b34ae7bb48feb16cd98a6e2e0
4
- metadata.gz: d6cc4fb4b577a182a90b73e1bfa682d231f11d9f
5
2
  SHA512:
6
- data.tar.gz: ddd7939d9f0273ba6c74a86db795afee1910c0a4d6ae289bdaf7cc77500a65566b963fc0a12b217aa1a1c2756db7e668d2423782f13f7cc4d5598cdb507fed4f
7
- metadata.gz: 8862732285c774b66b688524136f96964d92ad667aeabc263c08e7e142c2c1c8f8c20e02e31f5f0bd2ba01dce7067d394c728f1ce9acdcad22ad2a0b9c401bb1
3
+ metadata.gz: 6c67ff2dc34e83e2aad70042aa2c8cb97ab7fe0fc62999965795f993843c4ba7d600bf398edb2ff7dc5723047903b2053f42ed88c932588ea0a6da884225069d
4
+ data.tar.gz: 1eb545fcb9b88bfef7d310132b9488e5237fa6cd64ed16c51d3e57a55d2749ed98de18623eadbc6ad18de68a14c27584c5cb742ff46befce8c8df72c332ab0e1
5
+ SHA1:
6
+ metadata.gz: 283666dcd8471f7e2e66482e6777457894373451
7
+ data.tar.gz: 9c213ba859d5bd3b3bd0ba24f57c1f4d746284b0
@@ -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
- @asset_files[digest_path] ||= AssetFile.new(digest_path).tap do |af|
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
@@ -33,7 +33,7 @@ class Dassets::Server
33
33
  end
34
34
 
35
35
  def asset_file
36
- @asset_file ||= Dassets[asset_path]
36
+ @asset_file ||= Dassets.asset_file(asset_path)
37
37
  end
38
38
 
39
39
  private
@@ -1,3 +1,3 @@
1
1
  module Dassets
2
- VERSION = "0.14.4"
2
+ VERSION = "0.14.5"
3
3
  end
@@ -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 a their digest path using the index operator" do
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', file.digest_path
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
- # complain with an unknown file with a valid fingerprint
60
+ # not find an unknown file with a valid fingerprint
62
61
  req = file_request('GET', '/some-file-daa05c683a4913b268653f7a7e36a5b4.txt')
63
- assert_raises(Dassets::AssetFileError){ req.for_asset_file? }
62
+ assert_not req.for_asset_file?
64
63
  end
65
64
 
66
- should "return an asset path and complain if request not for asset file" do
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
- assert_raises(Dassets::AssetFileError){ req.asset_file }
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
- assert_raises(Dassets::AssetFileError) do
64
- Dassets['not-found-file.txt']
65
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dassets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding