juicer 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/lib/juicer.rb +1 -1
- data/lib/juicer/cache_buster.rb +1 -0
- data/lib/juicer/css_cache_buster.rb +3 -3
- data/test/unit/juicer/css_cache_buster_test.rb +60 -38
- metadata +33 -76
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.0.1 / 2010-03-03
|
2
|
+
* Don't crash when trying to cache bust non-existent files, simply
|
3
|
+
skip them
|
4
|
+
* Don't attempt to cache bust data urls
|
5
|
+
|
1
6
|
== 1.0.0 / 2010-02-24
|
2
7
|
* Make sure @import rules with url is removed when files are merged
|
3
8
|
* Dependency resolver supports depending on directories
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/juicer.rb
CHANGED
data/lib/juicer/cache_buster.rb
CHANGED
@@ -79,6 +79,7 @@ module Juicer
|
|
79
79
|
# argument.
|
80
80
|
#
|
81
81
|
def self.path(file, type = :soft, parameter = DEFAULT_PARAMETER)
|
82
|
+
return file if file =~ /data:.*;base64/
|
82
83
|
file = self.clean(file, parameter)
|
83
84
|
filename = file.split("?").first
|
84
85
|
raise ArgumentError.new("#{file} could not be found") unless File.exists?(filename)
|
@@ -42,15 +42,15 @@ module Juicer
|
|
42
42
|
|
43
43
|
urls(file).each do |asset|
|
44
44
|
begin
|
45
|
-
next if used.include?(asset.path)
|
45
|
+
next if used.include?(asset.path)
|
46
46
|
@contents.gsub!(asset.path, asset.path(:cache_buster_type => @type))
|
47
47
|
rescue Errno::ENOENT
|
48
48
|
puts "Unable to locate file #{asset.path}, skipping cache buster"
|
49
49
|
rescue ArgumentError => e
|
50
50
|
if e.message =~ /No document root/
|
51
|
-
|
51
|
+
puts "Unable to resolve path #{asset.path} without :document_root option"
|
52
52
|
else
|
53
|
-
|
53
|
+
puts "Unable to locate #{asset.path}, skipping cache buster"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -11,61 +11,83 @@ class TestCssCacheBuster < Test::Unit::TestCase
|
|
11
11
|
Juicer::Test::FileSetup.new.create
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
context "finding urls" do
|
15
|
+
should "find all urls" do
|
16
|
+
urls = @buster.urls(path("css/test.css"))
|
17
|
+
assert_equal 3, urls.length
|
18
|
+
assert_equal "../a1.css../images/1.png2.gif", urls.collect { |a| a.path }.sort.join.gsub(path("/"), "")
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
context "image references" do
|
23
|
+
should "update image urls" do
|
24
|
+
file = path("css/test.css")
|
25
|
+
buster = Juicer::CssCacheBuster.new
|
26
|
+
buster.save file
|
24
27
|
|
25
|
-
|
26
|
-
|
28
|
+
File.read(file).scan(/url\(([^\)]*)\)/m).each do |path|
|
29
|
+
assert_match(/[^\?]*\?jcb=\d+/, path.first)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
context "absolute paths" do
|
35
|
+
# should "fail without document root" do
|
36
|
+
# file = path("css/test2.css")
|
37
|
+
# buster = Juicer::CssCacheBuster.new
|
33
38
|
|
34
|
-
assert_raise FileNotFoundError do
|
35
|
-
|
36
|
-
end
|
37
|
-
|
39
|
+
# assert_raise FileNotFoundError do
|
40
|
+
# buster.save file
|
41
|
+
# end
|
42
|
+
# end
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
44
|
+
should "resolve with document root" do
|
45
|
+
file = path("css/test.css")
|
46
|
+
buster = Juicer::CssCacheBuster.new :document_root => path("")
|
42
47
|
|
43
|
-
|
44
|
-
|
48
|
+
assert_nothing_raised do
|
49
|
+
buster.save file
|
50
|
+
end
|
51
|
+
|
52
|
+
File.read(file).scan(/url\(([^\)]*)\)/m).each do |path|
|
53
|
+
assert_match(/[^\?]*\?jcb=\d+/, path.first)
|
54
|
+
end
|
45
55
|
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "cache busters" do
|
59
|
+
should "add mtime to urls" do
|
60
|
+
File.open(path("a2.css"), "w") { |f| f.puts "" }
|
61
|
+
file = path("path_test2.css")
|
62
|
+
output = path("path_test3.css")
|
63
|
+
buster = Juicer::CssCacheBuster.new :document_root => path("")
|
64
|
+
buster.save file, output
|
46
65
|
|
47
|
-
|
48
|
-
assert_match(/[^\?]*\?jcb=\d+/, path.first)
|
66
|
+
buster.urls(output).each { |url| assert url !~ /(jcb=\d+).*(jcb=\d+)/, url }
|
49
67
|
end
|
50
68
|
end
|
51
69
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
70
|
+
context "hard cache busters" do
|
71
|
+
should "should alter file name" do
|
72
|
+
File.open(path("a2.css"), "w") { |f| f.puts "" }
|
73
|
+
file = path("path_test2.css")
|
74
|
+
output = path("path_test3.css")
|
75
|
+
buster = Juicer::CssCacheBuster.new :document_root => path(""), :type => :hard
|
76
|
+
buster.save file, output
|
58
77
|
|
59
|
-
|
78
|
+
buster.urls(output).each { |asset| assert_match /-jcb\d+\.[a-z]{3}$/, asset.path }
|
79
|
+
end
|
60
80
|
end
|
61
81
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
buster.save file, output
|
82
|
+
context "non-existent urls" do
|
83
|
+
should "not raise" do
|
84
|
+
File.open(path("a2.css"), "w") { |f| f.puts "a { background: url(i/dont/exist.fck); }" }
|
85
|
+
file = path("a2.css")
|
86
|
+
buster = Juicer::CssCacheBuster.new :document_root => path("")
|
68
87
|
|
69
|
-
|
88
|
+
assert_nothing_raised do
|
89
|
+
buster.save file
|
90
|
+
end
|
91
|
+
end
|
70
92
|
end
|
71
93
|
end
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: juicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
version: 1.0.0
|
4
|
+
version: 1.0.1
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Christian Johansen
|
@@ -14,115 +9,79 @@ autorequire:
|
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
11
|
|
17
|
-
date: 2010-
|
12
|
+
date: 2010-03-03 00:00:00 +01:00
|
18
13
|
default_executable: juicer
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: shoulda
|
22
|
-
|
23
|
-
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 2
|
29
|
-
- 10
|
30
|
-
- 2
|
31
23
|
version: 2.10.2
|
32
|
-
|
33
|
-
version_requirements: *id001
|
24
|
+
version:
|
34
25
|
- !ruby/object:Gem::Dependency
|
35
26
|
name: mocha
|
36
|
-
|
37
|
-
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
30
|
requirements:
|
39
31
|
- - ">="
|
40
32
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
- 9
|
44
|
-
- 8
|
45
33
|
version: 0.9.8
|
46
|
-
|
47
|
-
version_requirements: *id002
|
34
|
+
version:
|
48
35
|
- !ruby/object:Gem::Dependency
|
49
36
|
name: fakefs
|
50
|
-
|
51
|
-
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
40
|
requirements:
|
53
41
|
- - ">="
|
54
42
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
- 2
|
58
|
-
- 1
|
59
43
|
version: 0.2.1
|
60
|
-
|
61
|
-
version_requirements: *id003
|
44
|
+
version:
|
62
45
|
- !ruby/object:Gem::Dependency
|
63
46
|
name: jeweler
|
64
|
-
prerelease: false
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
segments:
|
70
|
-
- 0
|
71
|
-
- 2
|
72
|
-
- 1
|
73
|
-
version: 0.2.1
|
74
47
|
type: :development
|
75
|
-
|
76
|
-
|
77
|
-
name: redgreen
|
78
|
-
prerelease: false
|
79
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
50
|
requirements:
|
81
51
|
- - ">="
|
82
52
|
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
- 2
|
86
|
-
- 2
|
87
|
-
version: 1.2.2
|
88
|
-
type: :development
|
89
|
-
version_requirements: *id005
|
53
|
+
version: 0.2.1
|
54
|
+
version:
|
90
55
|
- !ruby/object:Gem::Dependency
|
91
56
|
name: cmdparse
|
92
|
-
|
93
|
-
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
60
|
requirements:
|
95
61
|
- - ">="
|
96
62
|
- !ruby/object:Gem::Version
|
97
|
-
segments:
|
98
|
-
- 0
|
99
63
|
version: "0"
|
100
|
-
|
101
|
-
version_requirements: *id006
|
64
|
+
version:
|
102
65
|
- !ruby/object:Gem::Dependency
|
103
66
|
name: nokogiri
|
104
|
-
|
105
|
-
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
70
|
requirements:
|
107
71
|
- - ">="
|
108
72
|
- !ruby/object:Gem::Version
|
109
|
-
segments:
|
110
|
-
- 0
|
111
73
|
version: "0"
|
112
|
-
|
113
|
-
version_requirements: *id007
|
74
|
+
version:
|
114
75
|
- !ruby/object:Gem::Dependency
|
115
76
|
name: rubyzip
|
116
|
-
|
117
|
-
|
77
|
+
type: :runtime
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
118
80
|
requirements:
|
119
81
|
- - ">="
|
120
82
|
- !ruby/object:Gem::Version
|
121
|
-
segments:
|
122
|
-
- 0
|
123
83
|
version: "0"
|
124
|
-
|
125
|
-
version_requirements: *id008
|
84
|
+
version:
|
126
85
|
description: Resolve dependencies, merge and minify CSS and JavaScript files with Juicer - the command line tool for frontend engineers
|
127
86
|
email: christian@cjohansen.no
|
128
87
|
executables:
|
@@ -251,20 +210,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
210
|
requirements:
|
252
211
|
- - ">="
|
253
212
|
- !ruby/object:Gem::Version
|
254
|
-
segments:
|
255
|
-
- 0
|
256
213
|
version: "0"
|
214
|
+
version:
|
257
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
216
|
requirements:
|
259
217
|
- - ">="
|
260
218
|
- !ruby/object:Gem::Version
|
261
|
-
segments:
|
262
|
-
- 0
|
263
219
|
version: "0"
|
220
|
+
version:
|
264
221
|
requirements: []
|
265
222
|
|
266
223
|
rubyforge_project: juicer
|
267
|
-
rubygems_version: 1.3.
|
224
|
+
rubygems_version: 1.3.5
|
268
225
|
signing_key:
|
269
226
|
specification_version: 3
|
270
227
|
summary: Command line tool for CSS and JavaScript developers
|