dassets 0.10.0 → 0.10.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 +4 -4
- data/lib/dassets/source_proxy.rb +3 -3
- data/lib/dassets/version.rb +1 -1
- data/test/unit/source_proxy_tests.rb +88 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6276fedfd2895a526ed5a1593dae1a3a1d0ae726
|
4
|
+
data.tar.gz: 248ce8d0a5548d7454fb5675296df73e52c0ad3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9428c6ed5707756a0bd9e3e81197548394d1da94735d1ccd66d4cf837a024de745bd94db73e0452fd4fdc41053aca798177bc0692cb8cc569da4e9786ed0fc95
|
7
|
+
data.tar.gz: dfa8a1d4831ba49d293650a363ac71020bb6d62cf9d54e09d3c6c9791b2b5acdb9ec9c4f7b9d4c61b85fff82b39840a35c1e838ba58bcc052af31239cc9f4a0e
|
data/lib/dassets/source_proxy.rb
CHANGED
@@ -5,11 +5,11 @@ require 'dassets/source_file'
|
|
5
5
|
module Dassets; end
|
6
6
|
class Dassets::SourceProxy
|
7
7
|
|
8
|
-
attr_reader :digest_path, :
|
8
|
+
attr_reader :digest_path, :cache, :source_files
|
9
9
|
|
10
10
|
def initialize(digest_path, cache = nil)
|
11
11
|
@digest_path = digest_path
|
12
|
-
@cache
|
12
|
+
@cache = cache || Dassets::Cache::NoCache.new
|
13
13
|
@source_files = get_source_files(@digest_path, @cache)
|
14
14
|
end
|
15
15
|
|
@@ -26,7 +26,7 @@ class Dassets::SourceProxy
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def mtime
|
29
|
-
@source_files.map{ |f| f.mtime }.max
|
29
|
+
@source_files.map{ |f| f.mtime }.compact.max
|
30
30
|
end
|
31
31
|
|
32
32
|
def exists?
|
data/lib/dassets/version.rb
CHANGED
@@ -11,33 +11,33 @@ class Dassets::SourceProxy
|
|
11
11
|
class UnitTests < Assert::Context
|
12
12
|
desc "Dassets::SourceProxy"
|
13
13
|
setup do
|
14
|
-
@source_proxy = Dassets::SourceProxy.new(
|
14
|
+
@source_proxy = Dassets::SourceProxy.new(Factory.string)
|
15
15
|
end
|
16
16
|
subject{ @source_proxy }
|
17
17
|
|
18
|
-
should have_readers :digest_path, :
|
19
|
-
should have_imeths :
|
18
|
+
should have_readers :digest_path, :cache, :source_files
|
19
|
+
should have_imeths :key, :content, :fingerprint, :mtime, :exists?
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
class NotComboTests < UnitTests
|
24
|
+
desc "when the digest path is not a combination"
|
25
|
+
setup do
|
26
|
+
@source_proxy = Dassets::SourceProxy.new('file1.txt')
|
23
27
|
end
|
24
28
|
|
25
|
-
should "know its
|
26
|
-
|
27
|
-
assert_equal 1, subject.source_files.size
|
28
|
-
assert_equal exp_source_file, subject.source_files.first
|
29
|
+
should "know its digest path" do
|
30
|
+
assert_equal 'file1.txt', subject.digest_path
|
29
31
|
end
|
30
32
|
|
31
33
|
should "use a `NoCache` cache handler by default" do
|
32
34
|
assert_kind_of Dassets::Cache::NoCache, subject.cache
|
33
35
|
end
|
34
36
|
|
35
|
-
should "
|
36
|
-
assert_equal subject.source_files.
|
37
|
-
|
38
|
-
|
39
|
-
should "use its source file's mtime as its mtime" do
|
40
|
-
assert_equal subject.source_files.first.mtime, subject.mtime
|
37
|
+
should "have a single source file" do
|
38
|
+
assert_equal 1, subject.source_files.size
|
39
|
+
exp_source_file = Dassets::SourceFile.find_by_digest_path('file1.txt')
|
40
|
+
assert_equal exp_source_file, subject.source_files.first
|
41
41
|
end
|
42
42
|
|
43
43
|
should "use its digest path and mtime as its key" do
|
@@ -45,53 +45,108 @@ class Dassets::SourceProxy
|
|
45
45
|
assert_equal exp_key, subject.key
|
46
46
|
end
|
47
47
|
|
48
|
-
should "get its
|
48
|
+
should "get its content from the compiled source of the single source file" do
|
49
|
+
assert_equal subject.source_files.first.compiled, subject.content
|
50
|
+
end
|
51
|
+
|
52
|
+
should "get its fingerprint by MD5 hashing the content" do
|
49
53
|
exp_fp = Digest::MD5.new.hexdigest(subject.content)
|
50
54
|
assert_equal exp_fp, subject.fingerprint
|
51
55
|
end
|
52
56
|
|
53
|
-
should "
|
54
|
-
assert_equal subject.source_files.first.
|
57
|
+
should "use its single source file's max mtime as its mtime" do
|
58
|
+
assert_equal subject.source_files.first.mtime, subject.mtime
|
59
|
+
end
|
60
|
+
|
61
|
+
should "exist if its single source file exists" do
|
62
|
+
assert_equal subject.source_files.first.exists?, subject.exists?
|
55
63
|
end
|
56
64
|
|
57
65
|
end
|
58
66
|
|
59
|
-
class
|
60
|
-
desc "when the digest path is a combination to multiple source files"
|
67
|
+
class ComboSetupTests < UnitTests
|
61
68
|
setup do
|
62
69
|
Dassets.config.combination 'file3.txt', ['file1.txt', 'file2.txt']
|
63
|
-
|
70
|
+
Dassets.config.combination 'file4.txt', []
|
71
|
+
Dassets.config.combination 'file5.txt', ['file3.txt', 'file4.txt']
|
72
|
+
end
|
73
|
+
teardown do
|
74
|
+
Dassets.config.combinations.delete('file5.txt')
|
75
|
+
Dassets.config.combinations.delete('file4.txt')
|
76
|
+
Dassets.config.combinations.delete('file3.txt')
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
class ComboTests < ComboSetupTests
|
82
|
+
desc "when the digest path is a combination to multiple source files"
|
83
|
+
setup do
|
64
84
|
@exp_source_files = [
|
65
85
|
Dassets::SourceFile.find_by_digest_path('file1.txt'),
|
66
86
|
Dassets::SourceFile.find_by_digest_path('file2.txt')
|
67
87
|
]
|
68
|
-
|
69
|
-
teardown do
|
70
|
-
Dassets.config.combinations.delete('file3.txt')
|
88
|
+
@source_proxy = Dassets::SourceProxy.new('file3.txt')
|
71
89
|
end
|
72
90
|
|
73
91
|
should "know its digest path" do
|
74
92
|
assert_equal 'file3.txt', subject.digest_path
|
75
93
|
end
|
76
94
|
|
77
|
-
should "know its source
|
95
|
+
should "know its source files" do
|
78
96
|
assert_equal 2, subject.source_files.size
|
79
97
|
assert_equal @exp_source_files, subject.source_files
|
80
98
|
end
|
81
99
|
|
82
|
-
should "
|
83
|
-
|
84
|
-
assert_equal
|
100
|
+
should "get its content from the compiled source of its source files" do
|
101
|
+
exp_content = subject.source_files.map{ |f| f.compiled }.join("\n")
|
102
|
+
assert_equal exp_content, subject.content
|
85
103
|
end
|
86
104
|
|
87
|
-
should "use its source
|
88
|
-
exp_mtime =
|
105
|
+
should "use its source files' max mtime as its mtime" do
|
106
|
+
exp_mtime = subject.source_files.map{ |f| f.mtime }.max
|
89
107
|
assert_equal exp_mtime, subject.mtime
|
90
108
|
end
|
91
109
|
|
92
|
-
should "
|
93
|
-
|
94
|
-
assert_equal
|
110
|
+
should "exist if its all its source files exist" do
|
111
|
+
exp_exists = subject.source_files.inject(true){ |res, f| res && f.exists? }
|
112
|
+
assert_equal exp_exists, subject.exists?
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
class EmptyComboTests < ComboSetupTests
|
118
|
+
desc "when the digest path is an empty combination"
|
119
|
+
setup do
|
120
|
+
@source_proxy = Dassets::SourceProxy.new('file4.txt')
|
121
|
+
end
|
122
|
+
|
123
|
+
should "not have any source files" do
|
124
|
+
assert_equal 0, subject.source_files.size
|
125
|
+
end
|
126
|
+
|
127
|
+
should "have empty content" do
|
128
|
+
assert_equal '', subject.content
|
129
|
+
end
|
130
|
+
|
131
|
+
should "have no mtime" do
|
132
|
+
assert_nil subject.mtime
|
133
|
+
end
|
134
|
+
|
135
|
+
should "exist" do
|
136
|
+
assert_true subject.exists?
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
class ComboWithEmptyComboTests < ComboSetupTests
|
142
|
+
desc "when the digest path is a combination that includes an empty combination"
|
143
|
+
setup do
|
144
|
+
@source_proxy = Dassets::SourceProxy.new('file5.txt')
|
145
|
+
end
|
146
|
+
|
147
|
+
should "ignore the mtime of the empty combination" do
|
148
|
+
exp_mtime = subject.source_files.map{ |f| f.mtime }.compact.max
|
149
|
+
assert_equal exp_mtime, subject.mtime
|
95
150
|
end
|
96
151
|
|
97
152
|
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: assert
|