dassets 0.2.0 → 0.3.0
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.
- data/README.md +15 -5
- data/lib/dassets.rb +59 -12
- data/lib/dassets/asset_file.rb +15 -14
- data/lib/dassets/cmds/cache_cmd.rb +33 -0
- data/lib/dassets/cmds/digest_cmd.rb +53 -0
- data/lib/dassets/{digests_file.rb → digests.rb} +14 -23
- data/lib/dassets/engine.rb +33 -0
- data/lib/dassets/runner.rb +10 -4
- data/lib/dassets/server/response.rb +1 -1
- data/lib/dassets/source_file.rb +71 -0
- data/lib/dassets/version.rb +1 -1
- data/test/support/app/assets/.digests +1 -0
- data/test/support/app/assets/file1.txt +1 -0
- data/test/support/app/assets/file2.txt +1 -0
- data/test/support/app/assets/grumpy_cat.jpg +0 -0
- data/test/support/app/assets/nested/a-thing.txt.useless.dumb +1 -0
- data/test/support/app/assets/nested/file3.txt +0 -0
- data/test/support/app/assets/public/nested/a-thing.txt.no-use +4 -0
- data/test/support/config/assets.rb +12 -1
- data/test/support/example.digests +3 -3
- data/test/support/public/nested/a-thing.txt-7413d18f2eba9c695a880aff67fde135.no-use +4 -0
- data/test/support/source_files/_ignored.txt +0 -0
- data/test/support/source_files/nested/_nested_ignored.txt +0 -0
- data/test/support/source_files/nested/test2.txt +0 -0
- data/test/support/source_files/test1.txt +0 -0
- data/test/system/cache_cmd_run_tests.rb +27 -0
- data/test/system/digest_cmd_run_tests.rb +70 -0
- data/test/unit/asset_file_tests.rb +11 -11
- data/test/unit/cmds/cache_cmd_tests.rb +33 -0
- data/test/unit/cmds/digest_cmd_tests.rb +23 -0
- data/test/unit/config_tests.rb +52 -7
- data/test/unit/dassets_tests.rb +59 -5
- data/test/unit/digests_tests.rb +79 -0
- data/test/unit/engine_tests.rb +59 -0
- data/test/unit/server/response_tests.rb +5 -5
- data/test/unit/source_file_tests.rb +82 -0
- metadata +45 -13
- data/lib/dassets/runner/cache_command.rb +0 -46
- data/lib/dassets/runner/digest_command.rb +0 -65
- data/test/unit/digests_file_tests.rb +0 -90
- data/test/unit/runner/cache_command_tests.rb +0 -62
- data/test/unit/runner/digest_command_tests.rb +0 -83
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'dassets/runner/cache_command'
|
4
|
-
|
5
|
-
class Dassets::Runner::CacheCommand
|
6
|
-
|
7
|
-
class BaseTests < Assert::Context
|
8
|
-
desc "Dassets::Runner::CacheCommand"
|
9
|
-
setup do
|
10
|
-
@cache_root_path = File.join(Dassets.config.root_path, 'public')
|
11
|
-
FileUtils.mkdir_p @cache_root_path
|
12
|
-
@cmd = Dassets::Runner::CacheCommand.new(@cache_root_path)
|
13
|
-
end
|
14
|
-
teardown do
|
15
|
-
# FileUtils.rm_rf @cache_root_path
|
16
|
-
end
|
17
|
-
subject{ @cmd }
|
18
|
-
|
19
|
-
should have_readers :files_root_path, :cache_root_path, :digests_file, :asset_files
|
20
|
-
|
21
|
-
should "use the config's files path and its files root path" do
|
22
|
-
assert_equal Dassets.config.files_path, subject.files_root_path.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
should "know its given cache root path" do
|
26
|
-
assert_equal @cache_root_path, subject.cache_root_path.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
should "know it's digests file" do
|
30
|
-
assert_kind_of Dassets::DigestsFile, subject.digests_file
|
31
|
-
end
|
32
|
-
|
33
|
-
should "get it's asset files from the digests file" do
|
34
|
-
assert_equal 4, subject.digests_file.keys.size
|
35
|
-
assert_equal 4, subject.asset_files.size
|
36
|
-
end
|
37
|
-
|
38
|
-
should "use AssetFile objs for the asset files" do
|
39
|
-
assert_kind_of Dassets::AssetFile, subject.asset_files.first
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
class RunTests < BaseTests
|
45
|
-
desc "on run"
|
46
|
-
setup do
|
47
|
-
FileUtils.rm_rf(@cache_root_path)
|
48
|
-
end
|
49
|
-
|
50
|
-
should "create the cache root and write the cache files" do
|
51
|
-
assert_not_file_exists @cache_root_path.to_s
|
52
|
-
subject.run
|
53
|
-
|
54
|
-
assert_file_exists @cache_root_path.to_s
|
55
|
-
subject.asset_files.each do |file|
|
56
|
-
assert_file_exists File.join(@cache_root_path, file.cache_path)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'dassets/runner/digest_command'
|
4
|
-
|
5
|
-
class Dassets::Runner::DigestCommand
|
6
|
-
|
7
|
-
class BaseTests < Assert::Context
|
8
|
-
desc "Dassets::Runner::DigestCommand"
|
9
|
-
setup do
|
10
|
-
@cmd = Dassets::Runner::DigestCommand.new([])
|
11
|
-
end
|
12
|
-
subject{ @cmd }
|
13
|
-
|
14
|
-
should have_instance_methods :asset_files, :digests_file, :run
|
15
|
-
|
16
|
-
should "know it's digests file" do
|
17
|
-
assert_kind_of Dassets::DigestsFile, subject.digests_file
|
18
|
-
end
|
19
|
-
|
20
|
-
should "get it's asset files from the config path by default" do
|
21
|
-
assert_equal 4, subject.asset_files.size
|
22
|
-
assert_equal 4, subject.digests_file.keys.size
|
23
|
-
end
|
24
|
-
|
25
|
-
should "get it's asset files from the args if passed" do
|
26
|
-
path_string = File.join(Dassets.config.files_path, 'file*')
|
27
|
-
digest_cmd = Dassets::Runner::DigestCommand.new([path_string])
|
28
|
-
|
29
|
-
assert_equal 2, digest_cmd.asset_files.size
|
30
|
-
end
|
31
|
-
|
32
|
-
should "use AssetFile objs for the asset files" do
|
33
|
-
assert_kind_of Dassets::AssetFile, subject.asset_files.first
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
class RunTests < BaseTests
|
39
|
-
desc "on run"
|
40
|
-
setup do
|
41
|
-
@cmd.run
|
42
|
-
@addfile = 'addfile.txt'
|
43
|
-
@rmfile = 'file1.txt'
|
44
|
-
@updfile = 'file2.txt'
|
45
|
-
@addfile_path = File.join(File.join(Dassets.config.files_path, @addfile))
|
46
|
-
@rmfile_path = File.join(File.join(Dassets.config.files_path, @rmfile))
|
47
|
-
@updfile_path = File.join(File.join(Dassets.config.files_path, @updfile))
|
48
|
-
|
49
|
-
@rmfilecontents = File.read(@rmfile_path)
|
50
|
-
@updfilecontents = File.read(@updfile_path)
|
51
|
-
@orig_updfile_md5 = subject.digests_file[@updfile]
|
52
|
-
|
53
|
-
FileUtils.touch @addfile_path
|
54
|
-
FileUtils.rm @rmfile_path
|
55
|
-
File.open(@updfile_path, "w+"){ |f| f.write('an update') }
|
56
|
-
end
|
57
|
-
teardown do
|
58
|
-
File.open(@updfile_path, "w"){ |f| f.write @updfilecontents }
|
59
|
-
File.open(@rmfile_path, "w"){ |f| f.write @rmfilecontents }
|
60
|
-
FileUtils.rm @addfile_path
|
61
|
-
end
|
62
|
-
|
63
|
-
should "update the digests_file on run" do
|
64
|
-
assert_equal 4, subject.digests_file.keys.size
|
65
|
-
assert_not_includes @addfile, subject.digests_file.keys
|
66
|
-
assert_includes @rmfile, subject.digests_file.keys
|
67
|
-
assert_equal @orig_updfile_md5, subject.digests_file[@updfile]
|
68
|
-
|
69
|
-
# recreate the cmd to reload asset files
|
70
|
-
@cmd = Dassets::Runner::DigestCommand.new([])
|
71
|
-
# run without writing the file
|
72
|
-
subject.run(false)
|
73
|
-
|
74
|
-
# see the add, update and removal
|
75
|
-
assert_equal 4, subject.digests_file.keys.size
|
76
|
-
assert_includes @addfile, subject.digests_file.keys
|
77
|
-
assert_not_includes @rmfile, subject.digests_file.keys
|
78
|
-
assert_not_equal @orig_updfile_md5, subject.digests_file[@updfile]
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|