dassets 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/dassets.gemspec +9 -5
- data/lib/dassets.rb +6 -6
- data/lib/dassets/asset_file.rb +15 -14
- data/lib/dassets/config.rb +8 -7
- data/lib/dassets/file_store.rb +4 -4
- data/lib/dassets/server.rb +1 -0
- data/lib/dassets/server/request.rb +2 -1
- data/lib/dassets/server/response.rb +30 -21
- data/lib/dassets/source.rb +2 -1
- data/lib/dassets/source_file.rb +21 -18
- data/lib/dassets/source_proxy.rb +8 -8
- data/lib/dassets/version.rb +1 -1
- data/test/helper.rb +19 -7
- data/test/support/app.rb +2 -0
- data/test/support/empty/{.gitkeep → .keep} +0 -0
- data/test/support/factory.rb +2 -0
- data/test/system/rack_tests.rb +13 -5
- data/test/unit/asset_file_tests.rb +9 -5
- data/test/unit/cache_tests.rb +4 -2
- data/test/unit/config_tests.rb +6 -3
- data/test/unit/dassets_tests.rb +6 -4
- data/test/unit/engine_tests.rb +5 -3
- data/test/unit/file_store_tests.rb +5 -3
- data/test/unit/server/request_tests.rb +7 -4
- data/test/unit/server/response_tests.rb +8 -6
- data/test/unit/server_tests.rb +3 -1
- data/test/unit/source_file_tests.rb +12 -6
- data/test/unit/source_proxy_tests.rb +24 -19
- data/test/unit/source_tests.rb +14 -6
- data/tmp/.gitkeep +0 -0
- metadata +23 -11
- data/.gitignore +0 -19
- data/.ruby-version +0 -1
data/test/unit/server_tests.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "dassets/server"
|
3
5
|
|
4
6
|
class Dassets::Server
|
5
7
|
class UnitTests < Assert::Context
|
6
8
|
desc "Dassets::Server"
|
7
|
-
subject
|
9
|
+
subject{ Dassets::Server.new("test rack app") }
|
8
10
|
|
9
11
|
should have_imeths :call, :call!
|
10
12
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "dassets/source_file"
|
3
5
|
|
@@ -8,7 +10,7 @@ require "dassets/source_proxy"
|
|
8
10
|
class Dassets::SourceFile
|
9
11
|
class UnitTests < Assert::Context
|
10
12
|
desc "Dassets::SourceFile"
|
11
|
-
subject
|
13
|
+
subject{ Dassets::SourceFile.new(@file_path) }
|
12
14
|
|
13
15
|
setup do
|
14
16
|
@file_path = TEST_SUPPORT_PATH.join("app/assets/file1.txt").to_s
|
@@ -106,10 +108,11 @@ class Dassets::NullSourceFile
|
|
106
108
|
assert_that(null_src.exists?).equals(false)
|
107
109
|
assert_that(null_src.compiled).is_nil
|
108
110
|
assert_that(null_src.mtime).is_nil
|
109
|
-
assert_that(null_src.response_headers).equals(
|
111
|
+
assert_that(null_src.response_headers).equals({})
|
110
112
|
end
|
111
113
|
|
112
|
-
should "pass options to a null src when finding by an unknown digest
|
114
|
+
should "pass options to a null src when finding by an unknown digest "\
|
115
|
+
"path" do
|
113
116
|
null_src = Dassets::NullSourceFile.new("not/found/digest/path")
|
114
117
|
null_src_new_called_with = []
|
115
118
|
Assert.stub(Dassets::NullSourceFile, :new) do |*args|
|
@@ -118,10 +121,13 @@ class Dassets::NullSourceFile
|
|
118
121
|
end
|
119
122
|
|
120
123
|
options = {
|
121
|
-
content_cache:
|
124
|
+
content_cache: Dassets::NoCache.new,
|
122
125
|
fingerprint_cache: Dassets::NoCache.new,
|
123
126
|
}
|
124
|
-
Dassets::SourceFile.find_by_digest_path(
|
127
|
+
Dassets::SourceFile.find_by_digest_path(
|
128
|
+
"not/found/digest/path",
|
129
|
+
**options,
|
130
|
+
)
|
125
131
|
|
126
132
|
exp = ["not/found/digest/path", options]
|
127
133
|
assert_that(null_src_new_called_with).equals(exp)
|
@@ -145,7 +151,7 @@ class Dassets::NullSourceFile
|
|
145
151
|
end
|
146
152
|
|
147
153
|
options = {
|
148
|
-
content_cache:
|
154
|
+
content_cache: Dassets::NoCache.new,
|
149
155
|
fingerprint_cache: Dassets::NoCache.new,
|
150
156
|
}
|
151
157
|
Dassets::NullSourceFile.new("file3.txt", **options)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "dassets/source_proxy"
|
3
5
|
|
@@ -9,7 +11,7 @@ require "dassets/source_proxy"
|
|
9
11
|
class Dassets::SourceProxy
|
10
12
|
class UnitTests < Assert::Context
|
11
13
|
desc "Dassets::SourceProxy"
|
12
|
-
subject
|
14
|
+
subject{ Dassets::SourceProxy.new(Factory.string) }
|
13
15
|
|
14
16
|
should have_readers :digest_path, :content_cache, :fingerprint_cache
|
15
17
|
should have_readers :source_files
|
@@ -19,7 +21,7 @@ class Dassets::SourceProxy
|
|
19
21
|
|
20
22
|
class NotComboTests < UnitTests
|
21
23
|
desc "when the digest path is not a combination"
|
22
|
-
subject
|
24
|
+
subject{ Dassets::SourceProxy.new("file1.txt") }
|
23
25
|
|
24
26
|
should "know its digest path" do
|
25
27
|
assert_that(subject.digest_path).equals("file1.txt")
|
@@ -41,7 +43,8 @@ class Dassets::SourceProxy
|
|
41
43
|
assert_that(subject.key).equals(exp)
|
42
44
|
end
|
43
45
|
|
44
|
-
should "get its content from the compiled source of the single
|
46
|
+
should "get its content from the compiled source of the single "\
|
47
|
+
"source file" do
|
45
48
|
assert_that(subject.content).equals(subject.source_files.first.compiled)
|
46
49
|
end
|
47
50
|
|
@@ -54,7 +57,8 @@ class Dassets::SourceProxy
|
|
54
57
|
assert_that(subject.mtime).equals(subject.source_files.first.mtime)
|
55
58
|
end
|
56
59
|
|
57
|
-
should "use its single source file's response headers as its resonse
|
60
|
+
should "use its single source file's response headers as its resonse "\
|
61
|
+
"headers" do
|
58
62
|
assert_that(subject.response_headers)
|
59
63
|
.equals(subject.source_files.first.response_headers)
|
60
64
|
end
|
@@ -80,12 +84,12 @@ class Dassets::SourceProxy
|
|
80
84
|
|
81
85
|
class ComboTests < ComboSetupTests
|
82
86
|
desc "when the digest path is a combination to multiple source files"
|
83
|
-
subject
|
87
|
+
subject{ Dassets::SourceProxy.new("file3.txt") }
|
84
88
|
|
85
89
|
setup do
|
86
90
|
@exp_source_files = [
|
87
91
|
Dassets::SourceFile.find_by_digest_path("file1.txt"),
|
88
|
-
Dassets::SourceFile.find_by_digest_path("file2.txt")
|
92
|
+
Dassets::SourceFile.find_by_digest_path("file2.txt"),
|
89
93
|
]
|
90
94
|
end
|
91
95
|
|
@@ -99,32 +103,33 @@ class Dassets::SourceProxy
|
|
99
103
|
end
|
100
104
|
|
101
105
|
should "get its content from the compiled source of its source files" do
|
102
|
-
exp = subject.source_files.map
|
106
|
+
exp = subject.source_files.map(&:compiled).join("\n")
|
103
107
|
assert_that(subject.content).equals(exp)
|
104
108
|
end
|
105
109
|
|
106
110
|
should "use its source files' max mtime as its mtime" do
|
107
|
-
exp = subject.source_files.map
|
111
|
+
exp = subject.source_files.map(&:mtime).max
|
108
112
|
assert_that(subject.mtime).equals(exp)
|
109
113
|
end
|
110
114
|
|
111
|
-
should "use its source files' merged response headers as its response
|
115
|
+
should "use its source files' merged response headers as its response "\
|
116
|
+
"headers" do
|
112
117
|
exp =
|
113
|
-
subject.source_files.reduce(
|
118
|
+
subject.source_files.reduce({}) do |hash, file|
|
114
119
|
hash.merge!(file.response_headers)
|
115
|
-
|
120
|
+
end
|
116
121
|
assert_that(subject.response_headers).equals(exp)
|
117
122
|
end
|
118
123
|
|
119
124
|
should "exist if its all its source files exist" do
|
120
|
-
exp = subject.source_files.reduce(true)
|
125
|
+
exp = subject.source_files.reduce(true){ |res, f| res && f.exists? }
|
121
126
|
assert_that(subject.exists?).equals(exp)
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
130
|
class EmptyComboTests < ComboSetupTests
|
126
131
|
desc "when the digest path is an empty combination"
|
127
|
-
subject
|
132
|
+
subject{ Dassets::SourceProxy.new("file4.txt") }
|
128
133
|
|
129
134
|
should "not have any source files" do
|
130
135
|
assert_that(subject.source_files.size).equals(0)
|
@@ -146,24 +151,24 @@ class Dassets::SourceProxy
|
|
146
151
|
class ComboWithEmptyComboTests < ComboSetupTests
|
147
152
|
desc "when the digest path is a combination that includes an empty "\
|
148
153
|
"combination"
|
149
|
-
subject
|
154
|
+
subject{ Dassets::SourceProxy.new("file5.txt") }
|
150
155
|
|
151
156
|
should "ignore the mtime of the empty combination" do
|
152
|
-
exp_mtime = subject.source_files.map
|
157
|
+
exp_mtime = subject.source_files.map(&:mtime).compact.max
|
153
158
|
assert_that(subject.mtime).equals(exp_mtime)
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
157
162
|
class NoCacheTests < UnitTests
|
158
163
|
desc "with a `NoCache` cache handler"
|
159
|
-
subject
|
164
|
+
subject do
|
160
165
|
cache = Dassets::NoCache.new
|
161
166
|
Dassets::SourceProxy.new(
|
162
167
|
"file1.txt",
|
163
168
|
content_cache: cache,
|
164
169
|
fingerprint_cache: cache,
|
165
170
|
)
|
166
|
-
|
171
|
+
end
|
167
172
|
|
168
173
|
should "not cache its source content/fingerprint" do
|
169
174
|
content1 = subject.content
|
@@ -178,7 +183,7 @@ class Dassets::SourceProxy
|
|
178
183
|
|
179
184
|
class MemCacheTests < UnitTests
|
180
185
|
desc "with a `MemCache` cache handler"
|
181
|
-
subject
|
186
|
+
subject do
|
182
187
|
content_cache = Dassets::MemCache.new
|
183
188
|
fingerprint_cache = Dassets::MemCache.new
|
184
189
|
|
@@ -187,7 +192,7 @@ class Dassets::SourceProxy
|
|
187
192
|
content_cache: content_cache,
|
188
193
|
fingerprint_cache: fingerprint_cache,
|
189
194
|
)
|
190
|
-
|
195
|
+
end
|
191
196
|
|
192
197
|
should "cache its source content/fingerprint in memory" do
|
193
198
|
content1 = subject.content
|
data/test/unit/source_tests.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "assert"
|
2
4
|
require "dassets/source"
|
3
5
|
|
@@ -6,7 +8,7 @@ require "dassets/engine"
|
|
6
8
|
class Dassets::Source
|
7
9
|
class UnitTests < Assert::Context
|
8
10
|
desc "Dassets::Source"
|
9
|
-
subject
|
11
|
+
subject{ Dassets::Source.new(@source_path) }
|
10
12
|
|
11
13
|
setup do
|
12
14
|
@source_path = TEST_SUPPORT_PATH.join("source_files")
|
@@ -55,7 +57,7 @@ class Dassets::Source
|
|
55
57
|
end
|
56
58
|
|
57
59
|
should "know its response headers" do
|
58
|
-
assert_that(subject.response_headers).equals(
|
60
|
+
assert_that(subject.response_headers).equals({})
|
59
61
|
|
60
62
|
name, value = Factory.string, Factory.string
|
61
63
|
subject.response_headers[name] = value
|
@@ -98,8 +100,13 @@ class Dassets::Source
|
|
98
100
|
setup do
|
99
101
|
@empty_engine =
|
100
102
|
Class.new(Dassets::Engine) do
|
101
|
-
def ext(
|
102
|
-
|
103
|
+
def ext(_input_ext)
|
104
|
+
""
|
105
|
+
end
|
106
|
+
|
107
|
+
def compile(_input)
|
108
|
+
""
|
109
|
+
end
|
103
110
|
end
|
104
111
|
end
|
105
112
|
|
@@ -111,7 +118,8 @@ class Dassets::Source
|
|
111
118
|
assert_that(subject.engines["empty"].size).equals(1)
|
112
119
|
assert_that(subject.engines["empty"].first.opts["an"]).equals("opt")
|
113
120
|
assert_that(subject.engines["empty"].first.ext("empty")).equals("")
|
114
|
-
assert_that(subject.engines["empty"].first.compile("some content"))
|
121
|
+
assert_that(subject.engines["empty"].first.compile("some content"))
|
122
|
+
.equals("")
|
115
123
|
end
|
116
124
|
|
117
125
|
should "register with the source path as a default option" do
|
@@ -123,7 +131,7 @@ class Dassets::Source
|
|
123
131
|
subject.engine "empty", @empty_engine, "an" => "opt"
|
124
132
|
exp_opts = {
|
125
133
|
"source_path" => subject.path,
|
126
|
-
"an" => "opt"
|
134
|
+
"an" => "opt",
|
127
135
|
}
|
128
136
|
assert_that(subject.engines["empty"].first.opts).equals(exp_opts)
|
129
137
|
|
data/tmp/.gitkeep
ADDED
File without changes
|
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.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,36 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: much-style-guide
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.6.0
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.6.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: assert
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
17
31
|
requirements:
|
18
32
|
- - "~>"
|
19
33
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.19.
|
34
|
+
version: 2.19.3
|
21
35
|
type: :development
|
22
36
|
prerelease: false
|
23
37
|
version_requirements: !ruby/object:Gem::Requirement
|
24
38
|
requirements:
|
25
39
|
- - "~>"
|
26
40
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.19.
|
41
|
+
version: 2.19.3
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: assert-rack-test
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
46
|
- - "~>"
|
33
47
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.1.
|
48
|
+
version: 1.1.1
|
35
49
|
type: :development
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
53
|
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.1.
|
55
|
+
version: 1.1.1
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: sinatra
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,8 +89,6 @@ executables: []
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
|
-
- ".gitignore"
|
79
|
-
- ".ruby-version"
|
80
92
|
- Gemfile
|
81
93
|
- LICENSE
|
82
94
|
- README.md
|
@@ -102,7 +114,7 @@ files:
|
|
102
114
|
- test/support/app/assets/grumpy_cat.jpg
|
103
115
|
- test/support/app/assets/nested/a-thing.txt.useless.dumb
|
104
116
|
- test/support/app/assets/nested/file3.txt
|
105
|
-
- test/support/empty/.
|
117
|
+
- test/support/empty/.keep
|
106
118
|
- test/support/factory.rb
|
107
119
|
- test/support/linked_source_files/linked_file.txt
|
108
120
|
- test/support/source_files/_ignored.txt
|
@@ -144,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
156
|
- !ruby/object:Gem::Version
|
145
157
|
version: '0'
|
146
158
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.2.4
|
148
160
|
signing_key:
|
149
161
|
specification_version: 4
|
150
162
|
summary: Digested asset files
|
@@ -156,7 +168,7 @@ test_files:
|
|
156
168
|
- test/support/app/assets/grumpy_cat.jpg
|
157
169
|
- test/support/app/assets/nested/a-thing.txt.useless.dumb
|
158
170
|
- test/support/app/assets/nested/file3.txt
|
159
|
-
- test/support/empty/.
|
171
|
+
- test/support/empty/.keep
|
160
172
|
- test/support/factory.rb
|
161
173
|
- test/support/linked_source_files/linked_file.txt
|
162
174
|
- test/support/source_files/_ignored.txt
|
data/.gitignore
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.5
|