cjohansen-juicer 0.2.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +17 -5
- data/Manifest.txt +33 -15
- data/Rakefile +22 -1
- data/Readme.rdoc +68 -32
- data/bin/juicer +1 -0
- data/lib/juicer.rb +26 -1
- data/lib/juicer/binary.rb +173 -0
- data/lib/juicer/cache_buster.rb +45 -0
- data/lib/juicer/chainable.rb +1 -0
- data/lib/juicer/cli.rb +13 -8
- data/lib/juicer/command/install.rb +59 -0
- data/lib/juicer/command/list.rb +50 -0
- data/lib/juicer/command/merge.rb +130 -31
- data/lib/juicer/command/util.rb +32 -0
- data/lib/juicer/command/verify.rb +60 -0
- data/lib/juicer/core.rb +61 -0
- data/lib/juicer/css_cache_buster.rb +106 -0
- data/lib/juicer/install/base.rb +186 -0
- data/lib/juicer/install/jslint_installer.rb +51 -0
- data/lib/juicer/install/rhino_installer.rb +52 -0
- data/lib/juicer/install/yui_compressor_installer.rb +66 -0
- data/lib/juicer/jslint.rb +90 -0
- data/lib/juicer/merger/base.rb +74 -72
- data/lib/juicer/merger/dependency_resolver.rb +34 -16
- data/lib/juicer/merger/stylesheet_merger.rb +71 -1
- data/lib/juicer/minifyer/yui_compressor.rb +20 -43
- data/tasks/test/setup.rake +35 -0
- data/test/juicer/command/test_install.rb +53 -0
- data/test/juicer/command/test_list.rb +69 -0
- data/test/juicer/command/test_merge.rb +160 -0
- data/test/juicer/command/test_util.rb +54 -0
- data/test/juicer/command/test_verify.rb +33 -0
- data/test/juicer/install/test_installer_base.rb +195 -0
- data/test/juicer/install/test_jslint_installer.rb +54 -0
- data/test/juicer/install/test_rhino_installer.rb +57 -0
- data/test/juicer/install/test_yui_compressor_installer.rb +56 -0
- data/test/juicer/merger/test_base.rb +2 -3
- data/test/juicer/merger/test_css_dependency_resolver.rb +8 -4
- data/test/juicer/merger/test_javascript_dependency_resolver.rb +6 -7
- data/test/juicer/merger/test_javascript_merger.rb +1 -2
- data/test/juicer/merger/test_stylesheet_merger.rb +118 -2
- data/test/juicer/minifyer/test_yui_compressor.rb +109 -29
- data/test/juicer/test_cache_buster.rb +58 -0
- data/test/juicer/test_chainable.rb +7 -0
- data/test/juicer/test_core.rb +47 -0
- data/test/juicer/test_css_cache_buster.rb +91 -0
- data/test/juicer/test_jslint.rb +33 -0
- data/test/test_helper.rb +65 -196
- metadata +77 -26
- data/.gitignore +0 -2
- data/juicer.gemspec +0 -38
- data/lib/juicer/minifyer/compressor.rb +0 -125
- data/test/juicer/minifyer/test_compressor.rb +0 -36
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestVerifyCommand < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@io = StringIO.new
|
7
|
+
@command = Juicer::Command::Verify.new(Logger.new(@io))
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_no_files
|
11
|
+
assert_raise ArgumentError do
|
12
|
+
@command.execute []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_installer_not_found
|
17
|
+
Juicer.home = path("somewhere")
|
18
|
+
|
19
|
+
assert_raise FileNotFoundError do
|
20
|
+
@command.execute path("a.js")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_verify_several_files
|
25
|
+
Juicer.home = path(".juicer")
|
26
|
+
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
27
|
+
installer.install unless installer.installed?
|
28
|
+
|
29
|
+
@command.execute([path("ok.js"), path("not-ok.js"), path("a.js")])
|
30
|
+
assert_match(/OK!/, @io.string)
|
31
|
+
assert_match(/Problems detected/, @io.string)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. lib juicer install base]))
|
3
|
+
|
4
|
+
module Juicer
|
5
|
+
module Install
|
6
|
+
class SomeMagicInstaller < Juicer::Install::Base
|
7
|
+
def install(version = nil)
|
8
|
+
version ||= "1.0.0"
|
9
|
+
ver = super(version)
|
10
|
+
File.open(File.join(@install_dir, path, "bin", ver + ".app"), "w") do |file|
|
11
|
+
file.puts version
|
12
|
+
end
|
13
|
+
|
14
|
+
version
|
15
|
+
end
|
16
|
+
|
17
|
+
def uninstall(version = "1.0.0")
|
18
|
+
super(version) do |path, version|
|
19
|
+
File.delete(File.join(path, "bin", version + ".app"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SomeOtherInstaller < Juicer::Install::SomeMagicInstaller
|
25
|
+
def install(version = nil)
|
26
|
+
version ||= "1.0.0"
|
27
|
+
super(version)
|
28
|
+
end
|
29
|
+
|
30
|
+
def latest
|
31
|
+
"1.0.0"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestInstallerBase < Test::Unit::TestCase
|
38
|
+
|
39
|
+
def initialize(*args)
|
40
|
+
super
|
41
|
+
@juicer_home = File.expand_path(File.join("test", "data", ".juicer"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup
|
45
|
+
FileUtils.rm_rf @juicer_home
|
46
|
+
@installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_default_installation_directory_should_be_juicer_home
|
50
|
+
installer = Juicer::Install::SomeMagicInstaller.new
|
51
|
+
assert_equal Juicer.home, installer.install_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_override_installation_directory
|
55
|
+
installer = Juicer::Install::SomeMagicInstaller.new("/home/baluba")
|
56
|
+
assert_equal "/home/baluba", installer.install_dir
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_latest_method_should_raise_NotImplementedError
|
60
|
+
assert_raise NotImplementedError do
|
61
|
+
@installer.latest
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_path
|
66
|
+
assert_equal "lib/some_magic", @installer.path
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_bin_path
|
70
|
+
assert_equal "lib/some_magic/bin", @installer.bin_path
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_name
|
74
|
+
assert_equal "Some Magic", @installer.name
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_installed
|
78
|
+
assert !@installer.installed?("x.y.z")
|
79
|
+
@installer.install("x.y.z")
|
80
|
+
assert @installer.installed?("x.y.z")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_installation_should_fail_when_already_installed
|
84
|
+
@installer.install("1.0.0")
|
85
|
+
|
86
|
+
assert_raise RuntimeError do
|
87
|
+
@installer.install("1.0.0")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_installation_should_create_bin_and_release_folders
|
92
|
+
assert_equal "1.0.0", @installer.install("1.0.0")
|
93
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/bin"))
|
94
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_uninstall_should_remove_library_path_when_only_version_is_uninstalled
|
98
|
+
@installer.install("1.0.0")
|
99
|
+
@installer.uninstall("1.0.0")
|
100
|
+
assert !File.exists?(File.join(@juicer_home, "lib/some_magic"))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_uninstall_should_keep_other_versions
|
104
|
+
@installer.install("1.0.0")
|
105
|
+
@installer.install("1.0.1")
|
106
|
+
@installer.uninstall("1.0.0")
|
107
|
+
assert !File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
108
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic"))
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_download_should_cache_files_and_only_redownload_when_forced_to_do_so
|
112
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/")
|
113
|
+
filename = File.join(@juicer_home, "download/some_magic/yuicompressor")
|
114
|
+
assert File.exists?(filename)
|
115
|
+
sleep(0.5)
|
116
|
+
|
117
|
+
mtime = File.stat(filename).mtime
|
118
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/")
|
119
|
+
assert_equal mtime, File.stat(filename).mtime
|
120
|
+
sleep(0.5)
|
121
|
+
|
122
|
+
@installer.download("http://www.julienlecomte.net/yuicompressor/", true)
|
123
|
+
assert_not_equal mtime, File.stat(filename).mtime
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_installer_should_not_report_true_when_missing_dependencies
|
127
|
+
@installer.install
|
128
|
+
|
129
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
130
|
+
assert !installer.installed?("1.0.1"), "Installer should be installed"
|
131
|
+
|
132
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
133
|
+
assert !installer.installed?("1.0.1"), "Installer should not report as being installed when missing dependencies"
|
134
|
+
end
|
135
|
+
|
136
|
+
def installer_with_single_dependency_should_have_it_installed_on_install
|
137
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
138
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
139
|
+
installer.install "1.0.0"
|
140
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
141
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_installed_dependency_should_not_cause_error
|
145
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
146
|
+
installer.dependency Juicer::Install::SomeOtherInstaller
|
147
|
+
|
148
|
+
dep = Juicer::Install::SomeOtherInstaller.new
|
149
|
+
dep.install unless dep.installed?
|
150
|
+
|
151
|
+
assert_nothing_raised do
|
152
|
+
installer.install "1.0.0"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_single_dependency_symbol
|
157
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
158
|
+
installer.dependency :some_other
|
159
|
+
installer.install "1.0.0"
|
160
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
161
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_single_dependency_string
|
165
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
166
|
+
installer.dependency "some_other"
|
167
|
+
installer.install "1.0.0"
|
168
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
169
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_multiple_dependencies
|
173
|
+
installer = Juicer::Install::SomeMagicInstaller.new(@juicer_home)
|
174
|
+
installer.dependency :some_other
|
175
|
+
installer.dependency :some_other, "2.0.4"
|
176
|
+
installer.dependency :some_other, "3.0.5"
|
177
|
+
installer.install "1.0.0"
|
178
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_magic/1.0.0"))
|
179
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/1.0.0"))
|
180
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/2.0.4"))
|
181
|
+
assert File.exists?(File.join(@juicer_home, "lib/some_other/3.0.5"))
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_get_class
|
185
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(Juicer::Install::SomeMagicInstaller)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_get_class_from_symbol
|
189
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get(:some_magic)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_get_class_from_string
|
193
|
+
assert_equal Juicer::Install::SomeMagicInstaller, Juicer::Install.get("some_magic")
|
194
|
+
end
|
195
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestJsLintInstaller < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_install_should_download_js
|
13
|
+
@installer.install unless @installer.installed?
|
14
|
+
|
15
|
+
assert File.exists?(path(".juicer"))
|
16
|
+
assert File.exists?(path(".juicer/lib"))
|
17
|
+
assert File.exists?(path(".juicer/lib/jslint"))
|
18
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
19
|
+
assert_match(/jslint-\d\.\d\.js/, Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
23
|
+
@installer.install
|
24
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
25
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
26
|
+
|
27
|
+
@installer.uninstall
|
28
|
+
assert !File.exists?(path(".juicer/lib/jslint"))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_install_specific_version
|
32
|
+
@installer.install("1.0")
|
33
|
+
|
34
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
35
|
+
assert_equal "jslint-1.0.js", File.basename(Dir.glob(path(".juicer/lib/jslint/bin/*"))[0])
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_install_should_install_rhino_also
|
39
|
+
assert !File.exists?(path(".juicer/lib/rhino"))
|
40
|
+
@installer.install
|
41
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
45
|
+
@installer.install
|
46
|
+
@installer.install("1.1")
|
47
|
+
assert File.exists?(path(".juicer/lib/jslint/bin"))
|
48
|
+
assert_equal 2, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
49
|
+
|
50
|
+
@installer.uninstall("1.1")
|
51
|
+
assert File.exists?(path(".juicer/lib/jslint"))
|
52
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/jslint/**/*")).find_all { |f| File.file?(f) }.length
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestRhinoInstaller < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::RhinoInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_installation
|
13
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
14
|
+
assert !@installer.installed?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_install_should_download_jar_and_license
|
18
|
+
@installer.install
|
19
|
+
|
20
|
+
assert File.exists?(path(".juicer"))
|
21
|
+
assert File.exists?(path(".juicer/lib"))
|
22
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
23
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
24
|
+
assert_match(/rhino\d\_\d[^\.]*\.jar/, Dir.glob(path(".juicer/lib/rhino/bin/*"))[0])
|
25
|
+
|
26
|
+
files = Dir.glob(path(".juicer/lib/rhino/*_*/**/*"))
|
27
|
+
assert_equal ["LICENSE.txt"], files.collect { |file| file.split("/").pop }.sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
31
|
+
@installer.install
|
32
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
33
|
+
assert_equal 2, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
34
|
+
|
35
|
+
@installer.uninstall
|
36
|
+
assert !File.exists?(path(".juicer/lib/rhino"))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_install_specific_version
|
40
|
+
@installer.install("1.7R2-RC1")
|
41
|
+
|
42
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
43
|
+
assert File.exists?(path(".juicer/lib/rhino/1_7R2-RC1"))
|
44
|
+
assert_equal "rhino1_7R2-RC1.jar", File.basename(Dir.glob(path(".juicer/lib/rhino/bin/*"))[0])
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
48
|
+
@installer.install
|
49
|
+
@installer.install("1.7R1")
|
50
|
+
assert File.exists?(path(".juicer/lib/rhino/bin"))
|
51
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
52
|
+
|
53
|
+
@installer.uninstall("1.7R2-RC1")
|
54
|
+
assert File.exists?(path(".juicer/lib/rhino"))
|
55
|
+
assert_equal 1, Dir.glob(path(".juicer/lib/rhino/**/*")).find_all { |f| File.file?(f) }.length
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestYuiCompressorInstall < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@installer = Juicer::Install::YuiCompressorInstaller.new(path(".juicer"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_installation
|
13
|
+
assert !@installer.installed?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_install_should_download_jar_and_readme
|
17
|
+
@installer.install
|
18
|
+
|
19
|
+
assert File.exists?(path(".juicer"))
|
20
|
+
assert File.exists?(path(".juicer/lib"))
|
21
|
+
assert File.exists?(path(".juicer/lib/yui_compressor"))
|
22
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
23
|
+
assert_match(/yuicompressor-\d\.\d\.\d\.jar/, Dir.glob(path(".juicer/lib/yui_compressor/bin/*"))[0])
|
24
|
+
|
25
|
+
files = Dir.glob(path(".juicer/lib/yui_compressor/*.*.*/**/*"))
|
26
|
+
assert_equal ["CHANGELOG", "README"], files.collect { |file| file.split("/").pop }.sort
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_uninstall_should_remove_all_files_and_empty_directories
|
30
|
+
@installer.install
|
31
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
32
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
33
|
+
|
34
|
+
@installer.uninstall
|
35
|
+
assert !File.exists?(path(".juicer/lib/yui_compressor"))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_install_specific_version
|
39
|
+
@installer.install("2.3.5")
|
40
|
+
|
41
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
42
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/2.3.5"))
|
43
|
+
assert_equal "yuicompressor-2.3.5.jar", File.basename(Dir.glob(path(".juicer/lib/yui_compressor/bin/*"))[0])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_uninstall_should_leave_directories_when_other_versions_are_installed
|
47
|
+
@installer.install
|
48
|
+
@installer.install("2.3.5")
|
49
|
+
assert File.exists?(path(".juicer/lib/yui_compressor/bin"))
|
50
|
+
assert_equal 6, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
51
|
+
|
52
|
+
@installer.uninstall("2.3.5")
|
53
|
+
assert File.exists?(path(".juicer/lib/yui_compressor"))
|
54
|
+
assert_equal 3, Dir.glob(path(".juicer/lib/yui_compressor/**/*")).find_all { |f| File.file?(f) }.length
|
55
|
+
end
|
56
|
+
end
|
@@ -4,8 +4,7 @@ class TestMergerBase < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@file_merger = Juicer::Merger::Base.new
|
7
|
-
|
8
|
-
@file_setup.create!
|
7
|
+
Juicer::Test::FileSetup.new.create
|
9
8
|
end
|
10
9
|
|
11
10
|
def teardown
|
@@ -118,6 +117,6 @@ end
|
|
118
117
|
|
119
118
|
class MockImportResolver
|
120
119
|
def resolve(file)
|
121
|
-
|
120
|
+
[file]
|
122
121
|
end
|
123
122
|
end
|
@@ -3,8 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper]
|
|
3
3
|
class TestCssDependencyResolver < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
@resolver = Juicer::Merger::CssDependencyResolver.new
|
6
|
-
|
7
|
-
@file_setup.create!
|
6
|
+
Juicer::Test::FileSetup.new.create
|
8
7
|
end
|
9
8
|
|
10
9
|
def test_init
|
@@ -12,8 +11,8 @@ class TestCssDependencyResolver < Test::Unit::TestCase
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def test_resolve
|
15
|
-
b_file =
|
16
|
-
a_file =
|
14
|
+
b_file = path('b.css')
|
15
|
+
a_file = path('a.css')
|
17
16
|
|
18
17
|
files = @resolver.resolve(path('a.css')) do |file|
|
19
18
|
assert b_file == file || a_file == file
|
@@ -29,4 +28,9 @@ class TestCssDependencyResolver < Test::Unit::TestCase
|
|
29
28
|
|
30
29
|
assert_equal [a_file, b_file], files.sort
|
31
30
|
end
|
31
|
+
|
32
|
+
def test_load_order
|
33
|
+
files = @resolver.resolve(path("a1.css")).collect { |file| file.split("/").pop }
|
34
|
+
assert_equal "d1.cssb1.cssc1.cssa1.css", files.join
|
35
|
+
end
|
32
36
|
end
|