dassets 0.14.2 → 0.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dassets.gemspec +1 -1
- data/lib/dassets/file_store.rb +7 -6
- data/lib/dassets/version.rb +1 -1
- data/test/unit/asset_file_tests.rb +1 -1
- data/test/unit/config_tests.rb +1 -1
- data/test/unit/file_store_tests.rb +19 -16
- metadata +3 -11
- data/test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt +0 -1
- data/test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg +0 -0
- data/test/support/public/nested/a-thing.txt-7413d18f2eba9c695a880aff67fde135.no-use +0 -4
- data/test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
data.tar.gz:
|
4
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 8dbe44e69f1cd555b3d4530bf6776c93ee6adc45
|
4
|
+
metadata.gz: 25630a550508870191515317a401c64a3afa28ac
|
5
5
|
SHA512:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
6
|
+
data.tar.gz: 42a5cb8ee86ff57a117107491c25d7fbc3d813978bb17d0ac67b15e61aa3ced203e6e9fe03b1b7d7d4c0c708f14011021b65401e27bdddf7156be32e7e6b2c48
|
7
|
+
metadata.gz: f11ead1c8a44cf0988602f2fb9ae08ca7c5cc2d7f587c679f504f68bf6f46f838395ce906b491b156565c5ac5c65067aaaa068f870a4228b53b150e741911857
|
data/dassets.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_development_dependency("assert", ["~> 2.16.3"])
|
22
|
-
gem.add_development_dependency('assert-rack-test', ["~> 1.0.
|
22
|
+
gem.add_development_dependency('assert-rack-test', ["~> 1.0.5"])
|
23
23
|
gem.add_development_dependency("sinatra", ["~> 1.4"])
|
24
24
|
|
25
25
|
gem.add_dependency("rack", ["~> 1.0"])
|
data/lib/dassets/file_store.rb
CHANGED
@@ -10,17 +10,17 @@ module Dassets
|
|
10
10
|
@save_mutex = ::Mutex.new
|
11
11
|
end
|
12
12
|
|
13
|
-
def save(
|
13
|
+
def save(url_path, &block)
|
14
14
|
@save_mutex.synchronize do
|
15
|
-
store_path(
|
15
|
+
store_path(url_path).tap do |path|
|
16
16
|
FileUtils.mkdir_p(File.dirname(path))
|
17
17
|
File.open(path, "w"){ |f| f.write(block.call) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def store_path(
|
23
|
-
File.join(@root,
|
22
|
+
def store_path(url_path)
|
23
|
+
File.join(@root, url_path)
|
24
24
|
end
|
25
25
|
|
26
26
|
class NullStore < FileStore
|
@@ -28,8 +28,9 @@ module Dassets
|
|
28
28
|
super('')
|
29
29
|
end
|
30
30
|
|
31
|
-
def save(
|
32
|
-
|
31
|
+
def save(url_path, &block)
|
32
|
+
# no-op, just return the store path like the base does
|
33
|
+
store_path(url_path)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
data/lib/dassets/version.rb
CHANGED
@@ -122,7 +122,7 @@ class Dassets::AssetFile
|
|
122
122
|
@outfile = Dassets.config.file_store.store_path(@asset_file.url)
|
123
123
|
end
|
124
124
|
teardown do
|
125
|
-
FileUtils.
|
125
|
+
FileUtils.rm_rf(Dassets.config.file_store.root.to_s)
|
126
126
|
Dassets.config.file_store Dassets::FileStore::NullStore.new
|
127
127
|
end
|
128
128
|
|
data/test/unit/config_tests.rb
CHANGED
@@ -6,35 +6,37 @@ class Dassets::FileStore
|
|
6
6
|
class UnitTests < Assert::Context
|
7
7
|
desc "Dassets::FileStore"
|
8
8
|
setup do
|
9
|
-
@root
|
10
|
-
@
|
11
|
-
@
|
12
|
-
FileUtils.rm_f(@
|
9
|
+
@root = TEST_SUPPORT_PATH.join('public')
|
10
|
+
@url_path = Factory.url
|
11
|
+
@root_path = File.join(@root, @url_path).to_s
|
12
|
+
FileUtils.rm_f(@root_path)
|
13
13
|
|
14
14
|
@store = Dassets::FileStore.new(@root.to_s)
|
15
15
|
end
|
16
16
|
teardown do
|
17
|
-
FileUtils.
|
17
|
+
FileUtils.rm_rf(@root.to_s)
|
18
18
|
end
|
19
19
|
subject{ @store }
|
20
20
|
|
21
21
|
should have_readers :root
|
22
22
|
should have_imeths :save, :store_path
|
23
23
|
|
24
|
-
should "know its root
|
24
|
+
should "know its root" do
|
25
25
|
assert_equal @root.to_s, subject.root
|
26
26
|
end
|
27
27
|
|
28
|
-
should "build the store path based on a given url" do
|
29
|
-
assert_equal @
|
28
|
+
should "build the store path based on a given url path" do
|
29
|
+
assert_equal @root_path, subject.store_path(@url_path)
|
30
30
|
end
|
31
31
|
|
32
|
-
should "
|
33
|
-
|
34
|
-
|
32
|
+
should "write a file and return the store path on save" do
|
33
|
+
content = Factory.text
|
34
|
+
assert_not_file_exists @root_path
|
35
|
+
path = subject.save(@url_path){ content }
|
35
36
|
|
36
|
-
assert_equal @
|
37
|
-
assert_file_exists @
|
37
|
+
assert_equal @root_path, path
|
38
|
+
assert_file_exists @root_path
|
39
|
+
assert_equal content, File.read(@root_path)
|
38
40
|
end
|
39
41
|
|
40
42
|
end
|
@@ -49,12 +51,13 @@ class Dassets::FileStore
|
|
49
51
|
assert_kind_of Dassets::FileStore, subject
|
50
52
|
end
|
51
53
|
|
52
|
-
should "know its root
|
54
|
+
should "know its root" do
|
53
55
|
assert_equal '', subject.root
|
54
56
|
end
|
55
57
|
|
56
|
-
should "return the store path on save" do
|
57
|
-
assert_equal
|
58
|
+
should "return the store path on save but not save a file" do
|
59
|
+
assert_equal File.join('', @url_path), subject.save(@url_path)
|
60
|
+
assert_not_file_exists @root_path
|
58
61
|
end
|
59
62
|
|
60
63
|
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
|
+
version: 0.14.3
|
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-
|
13
|
+
date: 2017-07-26 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: assert
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0.
|
32
|
+
version: 1.0.5
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id002
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -91,10 +91,6 @@ files:
|
|
91
91
|
- test/support/app/assets/nested/file3.txt
|
92
92
|
- test/support/empty/.gitkeep
|
93
93
|
- test/support/factory.rb
|
94
|
-
- test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt
|
95
|
-
- test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg
|
96
|
-
- test/support/public/nested/a-thing.txt-7413d18f2eba9c695a880aff67fde135.no-use
|
97
|
-
- test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt
|
98
94
|
- test/support/source_files/_ignored.txt
|
99
95
|
- test/support/source_files/nested/_nested_ignored.txt
|
100
96
|
- test/support/source_files/nested/test2.txt
|
@@ -149,10 +145,6 @@ test_files:
|
|
149
145
|
- test/support/app/assets/nested/file3.txt
|
150
146
|
- test/support/empty/.gitkeep
|
151
147
|
- test/support/factory.rb
|
152
|
-
- test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt
|
153
|
-
- test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg
|
154
|
-
- test/support/public/nested/a-thing.txt-7413d18f2eba9c695a880aff67fde135.no-use
|
155
|
-
- test/support/public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt
|
156
148
|
- test/support/source_files/_ignored.txt
|
157
149
|
- test/support/source_files/nested/_nested_ignored.txt
|
158
150
|
- test/support/source_files/nested/test2.txt
|
@@ -1 +0,0 @@
|
|
1
|
-
file2.txt
|
Binary file
|
File without changes
|