dassets 0.14.5 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.ruby-version +1 -0
- data/Gemfile +3 -1
- data/README.md +15 -17
- data/dassets.gemspec +7 -6
- data/lib/dassets.rb +20 -18
- data/lib/dassets/asset_file.rb +14 -12
- data/lib/dassets/cache.rb +27 -33
- data/lib/dassets/config.rb +55 -51
- data/lib/dassets/engine.rb +11 -23
- data/lib/dassets/file_store.rb +27 -28
- data/lib/dassets/server.rb +27 -28
- data/lib/dassets/server/request.rb +43 -41
- data/lib/dassets/server/response.rb +93 -81
- data/lib/dassets/source.rb +13 -8
- data/lib/dassets/source_file.rb +100 -82
- data/lib/dassets/source_proxy.rb +32 -16
- data/lib/dassets/version.rb +3 -1
- data/test/helper.rb +18 -24
- data/test/support/app.rb +3 -5
- data/test/support/factory.rb +1 -2
- data/test/support/linked_source_files/linked_file.txt +0 -0
- data/test/support/source_files/linked +1 -0
- data/test/support/source_files/linked_file2.txt +1 -0
- data/test/system/rack_tests.rb +55 -59
- data/test/unit/asset_file_tests.rb +63 -59
- data/test/unit/cache_tests.rb +14 -35
- data/test/unit/config_tests.rb +53 -49
- data/test/unit/dassets_tests.rb +25 -40
- data/test/unit/engine_tests.rb +7 -43
- data/test/unit/file_store_tests.rb +33 -25
- data/test/unit/server/request_tests.rb +43 -48
- data/test/unit/server/response_tests.rb +79 -81
- data/test/unit/server_tests.rb +3 -9
- data/test/unit/source_file_tests.rb +73 -72
- data/test/unit/source_proxy_tests.rb +78 -89
- data/test/unit/source_tests.rb +58 -50
- metadata +78 -62
data/test/unit/source_tests.rb
CHANGED
@@ -1,35 +1,37 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "dassets/source"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "dassets/engine"
|
5
5
|
|
6
6
|
class Dassets::Source
|
7
|
-
|
8
7
|
class UnitTests < Assert::Context
|
9
8
|
desc "Dassets::Source"
|
9
|
+
subject { Dassets::Source.new(@source_path) }
|
10
|
+
|
10
11
|
setup do
|
11
12
|
@source_path = TEST_SUPPORT_PATH.join("source_files")
|
12
|
-
@source = Dassets::Source.new(@source_path)
|
13
13
|
end
|
14
|
-
subject{ @source }
|
15
14
|
|
16
15
|
should have_reader :path, :engines, :response_headers
|
17
16
|
should have_imeth :files, :filter, :engine
|
18
17
|
|
19
18
|
should "know its path and default filter" do
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
assert_that(subject.path).equals(@source_path.to_s)
|
20
|
+
assert_that(subject.filter).is_kind_of(Proc)
|
21
|
+
assert_that(subject.filter.call(["file1", "file2"]))
|
22
|
+
.equals(["file1", "file2"])
|
23
23
|
end
|
24
24
|
|
25
25
|
should "know its files" do
|
26
26
|
exp_files = [
|
27
|
-
@source_path.join(
|
28
|
-
@source_path.join(
|
29
|
-
@source_path.join(
|
30
|
-
@source_path.join(
|
27
|
+
@source_path.join("test1.txt").to_s,
|
28
|
+
@source_path.join("_ignored.txt").to_s,
|
29
|
+
@source_path.join("nested/test2.txt").to_s,
|
30
|
+
@source_path.join("nested/_nested_ignored.txt").to_s,
|
31
|
+
@source_path.join("linked/linked_file.txt").to_s,
|
32
|
+
@source_path.join("linked_file2.txt").to_s,
|
31
33
|
].sort
|
32
|
-
|
34
|
+
assert_that(subject.files).equals(exp_files)
|
33
35
|
end
|
34
36
|
|
35
37
|
should "run the supplied source filter on the paths" do
|
@@ -37,30 +39,33 @@ class Dassets::Source
|
|
37
39
|
paths.reject{ |path| File.basename(path) =~ /^_/ }
|
38
40
|
end
|
39
41
|
exp_files = [
|
40
|
-
@source_path.join(
|
41
|
-
@source_path.join(
|
42
|
+
@source_path.join("test1.txt").to_s,
|
43
|
+
@source_path.join("nested/test2.txt").to_s,
|
44
|
+
@source_path.join("linked/linked_file.txt").to_s,
|
45
|
+
@source_path.join("linked_file2.txt").to_s,
|
42
46
|
].sort
|
43
47
|
|
44
|
-
|
48
|
+
assert_that(subject.files).equals(exp_files)
|
45
49
|
end
|
46
50
|
|
47
|
-
should "know its engines and return
|
48
|
-
|
49
|
-
|
51
|
+
should "know its extension-specific engines and return an empty Array by "\
|
52
|
+
"default" do
|
53
|
+
assert_that(subject.engines).is_kind_of(::Hash)
|
54
|
+
assert_that(subject.engines["something"]).equals([])
|
50
55
|
end
|
51
56
|
|
52
57
|
should "know its response headers" do
|
53
|
-
|
58
|
+
assert_that(subject.response_headers).equals(Hash.new)
|
54
59
|
|
55
60
|
name, value = Factory.string, Factory.string
|
56
61
|
subject.response_headers[name] = value
|
57
|
-
|
62
|
+
assert_that(subject.response_headers[name]).equals(value)
|
58
63
|
end
|
59
|
-
|
60
64
|
end
|
61
65
|
|
62
66
|
class EmptySourceTests < UnitTests
|
63
67
|
desc "with no source files"
|
68
|
+
|
64
69
|
setup do
|
65
70
|
@empty_source_path = TEST_SUPPORT_PATH.join("empty")
|
66
71
|
@empty_source = Dassets::Source.new(@empty_source_path)
|
@@ -70,8 +75,8 @@ class Dassets::Source
|
|
70
75
|
end
|
71
76
|
|
72
77
|
should "have no files" do
|
73
|
-
|
74
|
-
|
78
|
+
assert_that(@empty_source.files).is_empty
|
79
|
+
assert_that(@no_exist_source.files).is_empty
|
75
80
|
end
|
76
81
|
|
77
82
|
should "hand filters an empty path list" do
|
@@ -82,47 +87,50 @@ class Dassets::Source
|
|
82
87
|
paths.reject{ |path| File.basename(path) =~ /^_/ }
|
83
88
|
end
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
assert_that(@empty_source.files).is_empty
|
91
|
+
assert_that(@no_exist_source.files).is_empty
|
87
92
|
end
|
88
|
-
|
89
93
|
end
|
90
94
|
|
91
95
|
class EngineRegistrationTests < UnitTests
|
92
96
|
desc "when registering an engine"
|
97
|
+
|
93
98
|
setup do
|
94
|
-
@empty_engine =
|
95
|
-
|
96
|
-
|
97
|
-
|
99
|
+
@empty_engine =
|
100
|
+
Class.new(Dassets::Engine) do
|
101
|
+
def ext(input_ext); ""; end
|
102
|
+
def compile(input); ""; end
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
should "allow registering new engines" do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
+
assert_that(subject.engines["empty"]).equals([])
|
108
|
+
|
109
|
+
subject.engine "empty", @empty_engine, "an" => "opt"
|
110
|
+
assert_that(subject.engines["empty"]).is_kind_of(Array)
|
111
|
+
assert_that(subject.engines["empty"].size).equals(1)
|
112
|
+
assert_that(subject.engines["empty"].first.opts["an"]).equals("opt")
|
113
|
+
assert_that(subject.engines["empty"].first.ext("empty")).equals("")
|
114
|
+
assert_that(subject.engines["empty"].first.compile("some content")).equals("")
|
107
115
|
end
|
108
116
|
|
109
117
|
should "register with the source path as a default option" do
|
110
|
-
subject.engine
|
111
|
-
exp_opts = {
|
112
|
-
|
118
|
+
subject.engine "empty", @empty_engine
|
119
|
+
exp_opts = { "source_path" => subject.path }
|
120
|
+
assert_that(subject.engines["empty"].first.opts).equals(exp_opts)
|
113
121
|
|
114
|
-
subject.
|
122
|
+
subject.engines["empty"] = []
|
123
|
+
subject.engine "empty", @empty_engine, "an" => "opt"
|
115
124
|
exp_opts = {
|
116
|
-
|
117
|
-
|
125
|
+
"source_path" => subject.path,
|
126
|
+
"an" => "opt"
|
118
127
|
}
|
119
|
-
|
128
|
+
assert_that(subject.engines["empty"].first.opts).equals(exp_opts)
|
120
129
|
|
121
|
-
subject.
|
122
|
-
|
123
|
-
|
130
|
+
subject.engines["empty"] = []
|
131
|
+
subject.engine "empty", @empty_engine, "source_path" => "something"
|
132
|
+
exp_opts = { "source_path" => "something" }
|
133
|
+
assert_that(subject.engines["empty"].first.opts).equals(exp_opts)
|
124
134
|
end
|
125
|
-
|
126
135
|
end
|
127
|
-
|
128
136
|
end
|
metadata
CHANGED
@@ -1,69 +1,82 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dassets
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Kelly Redding
|
8
8
|
- Collin Redding
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: assert
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
version: 2.16.3
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.19.0
|
23
21
|
type: :development
|
24
|
-
version_requirements: *id001
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: assert-rack-test
|
27
22
|
prerelease: false
|
28
|
-
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.19.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: assert-rack-test
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.0
|
33
35
|
type: :development
|
34
|
-
version_requirements: *id002
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: sinatra
|
37
36
|
prerelease: false
|
38
|
-
|
39
|
-
requirements:
|
40
|
-
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: sinatra
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.1'
|
43
49
|
type: :development
|
44
|
-
version_requirements: *id003
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: rack
|
47
50
|
prerelease: false
|
48
|
-
|
49
|
-
requirements:
|
50
|
-
- - ~>
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.1'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rack
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.1'
|
53
63
|
type: :runtime
|
54
|
-
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.1'
|
55
70
|
description: Digest and serve HTML asset files
|
56
|
-
email:
|
71
|
+
email:
|
57
72
|
- kelly@kellyredding.com
|
58
73
|
- collin.redding@me.com
|
59
74
|
executables: []
|
60
|
-
|
61
75
|
extensions: []
|
62
|
-
|
63
76
|
extra_rdoc_files: []
|
64
|
-
|
65
|
-
|
66
|
-
- .
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".ruby-version"
|
67
80
|
- Gemfile
|
68
81
|
- LICENSE
|
69
82
|
- README.md
|
@@ -91,7 +104,10 @@ files:
|
|
91
104
|
- test/support/app/assets/nested/file3.txt
|
92
105
|
- test/support/empty/.gitkeep
|
93
106
|
- test/support/factory.rb
|
107
|
+
- test/support/linked_source_files/linked_file.txt
|
94
108
|
- test/support/source_files/_ignored.txt
|
109
|
+
- test/support/source_files/linked
|
110
|
+
- test/support/source_files/linked_file2.txt
|
95
111
|
- test/support/source_files/nested/_nested_ignored.txt
|
96
112
|
- test/support/source_files/nested/test2.txt
|
97
113
|
- test/support/source_files/test1.txt
|
@@ -110,32 +126,29 @@ files:
|
|
110
126
|
- test/unit/source_tests.rb
|
111
127
|
- tmp/.gitkeep
|
112
128
|
homepage: http://github.com/redding/dassets
|
113
|
-
licenses:
|
129
|
+
licenses:
|
114
130
|
- MIT
|
115
131
|
metadata: {}
|
116
|
-
|
117
132
|
post_install_message:
|
118
133
|
rdoc_options: []
|
119
|
-
|
120
|
-
require_paths:
|
134
|
+
require_paths:
|
121
135
|
- lib
|
122
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
-
|
125
|
-
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '2.5'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
131
146
|
requirements: []
|
132
|
-
|
133
|
-
rubyforge_project:
|
134
|
-
rubygems_version: 2.6.6
|
147
|
+
rubygems_version: 3.1.2
|
135
148
|
signing_key:
|
136
149
|
specification_version: 4
|
137
150
|
summary: Digested asset files
|
138
|
-
test_files:
|
151
|
+
test_files:
|
139
152
|
- test/helper.rb
|
140
153
|
- test/support/app.rb
|
141
154
|
- test/support/app/assets/file1.txt
|
@@ -145,7 +158,10 @@ test_files:
|
|
145
158
|
- test/support/app/assets/nested/file3.txt
|
146
159
|
- test/support/empty/.gitkeep
|
147
160
|
- test/support/factory.rb
|
161
|
+
- test/support/linked_source_files/linked_file.txt
|
148
162
|
- test/support/source_files/_ignored.txt
|
163
|
+
- test/support/source_files/linked
|
164
|
+
- test/support/source_files/linked_file2.txt
|
149
165
|
- test/support/source_files/nested/_nested_ignored.txt
|
150
166
|
- test/support/source_files/nested/test2.txt
|
151
167
|
- test/support/source_files/test1.txt
|