dassets 0.14.3 → 0.14.4

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
  SHA1:
3
- data.tar.gz: 8dbe44e69f1cd555b3d4530bf6776c93ee6adc45
4
- metadata.gz: 25630a550508870191515317a401c64a3afa28ac
3
+ data.tar.gz: 434e3a03c8c5bd4b34ae7bb48feb16cd98a6e2e0
4
+ metadata.gz: d6cc4fb4b577a182a90b73e1bfa682d231f11d9f
5
5
  SHA512:
6
- data.tar.gz: 42a5cb8ee86ff57a117107491c25d7fbc3d813978bb17d0ac67b15e61aa3ced203e6e9fe03b1b7d7d4c0c708f14011021b65401e27bdddf7156be32e7e6b2c48
7
- metadata.gz: f11ead1c8a44cf0988602f2fb9ae08ca7c5cc2d7f587c679f504f68bf6f46f838395ce906b491b156565c5ac5c65067aaaa068f870a4228b53b150e741911857
6
+ data.tar.gz: ddd7939d9f0273ba6c74a86db795afee1910c0a4d6ae289bdaf7cc77500a65566b963fc0a12b217aa1a1c2756db7e668d2423782f13f7cc4d5598cdb507fed4f
7
+ metadata.gz: 8862732285c774b66b688524136f96964d92ad667aeabc263c08e7e142c2c1c8f8c20e02e31f5f0bd2ba01dce7067d394c728f1ce9acdcad22ad2a0b9c401bb1
data/lib/dassets.rb CHANGED
@@ -21,13 +21,43 @@ module Dassets
21
21
  end
22
22
 
23
23
  def self.[](digest_path)
24
- @asset_files[digest_path] ||= AssetFile.new(digest_path)
24
+ @asset_files[digest_path] ||= AssetFile.new(digest_path).tap do |af|
25
+ if af.fingerprint.nil?
26
+ msg = "error digesting `#{digest_path}`.\n\nMake sure Dassets has " \
27
+ "either a combination or source file for this digest path. If " \
28
+ "this path is for a combination, make sure Dassets has either " \
29
+ "a combination or source file for each digest path of the " \
30
+ "combination.\n\n"
31
+
32
+ msg << "\nCombination digest paths:"
33
+ msg << (Dassets.combinations.keys.empty? ? " (none)\n\n" : "\n\n")
34
+ Dassets.combinations.keys.sort.each do |key|
35
+ bullet = "#{key} => "
36
+ values = Dassets.combinations[key].sort
37
+ msg << (
38
+ ["#{bullet}#{values.first}"] +
39
+ values[1..-1].map{ |v| "#{' '*bullet.size}#{v}" }
40
+ ).join("\n")
41
+ msg << "\n\n"
42
+ end
43
+
44
+ msg << "\nSource file digest paths:"
45
+ msg << (Dassets.source_files.keys.empty? ? " (none)\n\n" : "\n\n")
46
+ msg << Dassets.source_files.keys.sort.join("\n")
47
+
48
+ raise AssetFileError, msg
49
+ end
50
+ end
25
51
  end
26
52
 
27
53
  def self.source_files
28
54
  @source_files
29
55
  end
30
56
 
57
+ def self.combinations
58
+ self.config.combinations
59
+ end
60
+
31
61
  module SourceFiles
32
62
 
33
63
  def self.new(sources)
@@ -45,6 +75,8 @@ module Dassets
45
75
 
46
76
  end
47
77
 
78
+ AssetFileError = Class.new(RuntimeError)
79
+
48
80
  end
49
81
 
50
82
  Dassets.init
@@ -1,3 +1,3 @@
1
1
  module Dassets
2
- VERSION = "0.14.3"
2
+ VERSION = "0.14.4"
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
14
+ should have_imeths :[], :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
@@ -45,9 +45,10 @@ module Dassets
45
45
  assert_same file2, file1
46
46
  end
47
47
 
48
- should "return an asset file that doesn't exist if digest path not found" do
49
- file = subject['path/not/found.txt']
50
- assert_not file.exists?
48
+ should "complain if digest path is not found using the index operator" do
49
+ assert_raises AssetFileError do
50
+ subject['path/not/found.txt']
51
+ end
51
52
  end
52
53
 
53
54
  should "know its list of configured source files" do
@@ -55,6 +56,11 @@ module Dassets
55
56
  assert_equal exp, subject.source_files
56
57
  end
57
58
 
59
+ should "know its configured combinations" do
60
+ exp = subject.config.combinations
61
+ assert_equal exp, subject.combinations
62
+ end
63
+
58
64
  end
59
65
 
60
66
  end
@@ -1,6 +1,7 @@
1
1
  require 'assert'
2
2
  require 'dassets/server/request'
3
3
 
4
+ require 'dassets'
4
5
  require 'dassets/asset_file'
5
6
 
6
7
  class Dassets::Server::Request
@@ -45,28 +46,28 @@ class Dassets::Server::Request
45
46
  req = file_request('GET', '/file1-d41d8cd98f00b204e9800998ecf8427e.txt')
46
47
  assert req.for_asset_file?
47
48
 
48
- # no find on invalid fingerprint
49
- req = file_request('GET', '/file1-daa05c683a4913b268653f7a7e36a.txt')
49
+ # not find an invalid fingerprint
50
+ req = file_request('GET', '/file1-abc123.txt')
50
51
  assert_not req.for_asset_file?
51
52
 
52
- # no find on missing fingerprint
53
+ # not find a missing fingerprint
53
54
  req = file_request('HEAD', '/file1.txt')
54
55
  assert_not req.for_asset_file?
55
56
 
56
- # no find on unknown file
57
+ # not find an unknown file with a missing fingerprint
57
58
  req = file_request('GET', '/some-file.txt')
58
59
  assert_not req.for_asset_file?
59
60
 
60
- # no find on unknown file with an fingerprint
61
+ # complain with an unknown file with a valid fingerprint
61
62
  req = file_request('GET', '/some-file-daa05c683a4913b268653f7a7e36a5b4.txt')
62
- assert_not req.for_asset_file?
63
+ assert_raises(Dassets::AssetFileError){ req.for_asset_file? }
63
64
  end
64
65
 
65
- should "return an asset path and an empty asset file if request not for asset file" do
66
+ should "return an asset path and complain if request not for asset file" do
66
67
  req = file_request('GET', '/some-file.txt')
67
68
 
68
69
  assert_equal '', req.asset_path
69
- assert_equal Dassets::AssetFile.new(''), req.asset_file
70
+ assert_raises(Dassets::AssetFileError){ req.asset_file }
70
71
  end
71
72
 
72
73
  protected
@@ -2,6 +2,7 @@ require 'assert'
2
2
  require 'dassets/server/response'
3
3
 
4
4
  require 'rack/utils'
5
+ require 'dassets'
5
6
  require 'dassets/asset_file'
6
7
 
7
8
  class Dassets::Server::Response
@@ -59,13 +60,9 @@ class Dassets::Server::Response
59
60
  end
60
61
 
61
62
  should "handle not found files" do
62
- af = Dassets['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
63
+ assert_raises(Dassets::AssetFileError) do
64
+ Dassets['not-found-file.txt']
65
+ end
69
66
  end
70
67
 
71
68
  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.3
4
+ version: 0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2017-07-26 00:00:00 Z
13
+ date: 2017-09-28 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: assert