rack-pagespeed 1.0.2 → 1.0.3
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
@@ -56,7 +56,15 @@ class Rack::PageSpeed::Filters::CombineCSS < Rack::PageSpeed::Filter
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def unique_id nodes
|
59
|
-
Digest::MD5.hexdigest nodes.map { |node|
|
59
|
+
return Digest::MD5.hexdigest nodes.map { |node|
|
60
|
+
file = file_for node
|
61
|
+
next unless file
|
62
|
+
file.mtime.to_i.to_s + file.read
|
63
|
+
}.join unless @options[:hash]
|
64
|
+
@options[:hash].each do |urls, hash|
|
65
|
+
next unless (nodes.map { |node| node['href'] } & urls).length == urls.length
|
66
|
+
return hash
|
67
|
+
end
|
60
68
|
end
|
61
69
|
|
62
70
|
def group_siblings nodes
|
@@ -52,7 +52,15 @@ class Rack::PageSpeed::Filters::CombineJavaScripts < Rack::PageSpeed::Filter
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def unique_id nodes
|
55
|
-
Digest::MD5.hexdigest nodes.map { |node|
|
55
|
+
return Digest::MD5.hexdigest nodes.map { |node|
|
56
|
+
file = file_for node
|
57
|
+
next unless file
|
58
|
+
file.mtime.to_i.to_s + file.read
|
59
|
+
}.join unless @options[:hash]
|
60
|
+
@options[:hash].each do |urls, hash|
|
61
|
+
next unless (nodes.map { |node| node['src'] } & urls).length == urls.length
|
62
|
+
return hash
|
63
|
+
end
|
56
64
|
end
|
57
65
|
|
58
66
|
def group_siblings nodes
|
data/rack-pagespeed.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-pagespeed}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Julio Cesar Ody"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-24}
|
13
13
|
s.description = %q{Web page speed optimizations at the Rack level}
|
14
14
|
s.email = %q{julio@awesomebydesign.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -39,10 +39,20 @@ describe 'the combine_javascripts filter' do
|
|
39
39
|
result = @filter.send :group_siblings, nodes
|
40
40
|
result.should == [[nodes[0].previous_element, nodes[0]], [nodes[1].previous_element, nodes[1]]]
|
41
41
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
|
43
|
+
context 'the #unique_id method' do
|
44
|
+
it "generates a hash thats unique to the nodes' combination of content + mtime in the absence of @options[:hash]" do
|
45
|
+
nodes = Fixtures.complex.css('script[src$=".js"]:not([src^="http"]) + script[src$=".js"]:not([src^="http"])')
|
46
|
+
@filter.send(:unique_id, nodes).should == Digest::MD5.hexdigest(nodes.map { |node| file = @filter.send(:file_for, node); file.mtime.to_i.to_s + file.read }.join)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "uses values for hashes estipulated in @options[:hash] if any" do
|
50
|
+
nodes = []
|
51
|
+
nodes << Fixtures.complex.at_css('script[src="ohno.js"]')
|
52
|
+
nodes << Fixtures.complex.at_css('script[src="foo.js"]')
|
53
|
+
filter = Rack::PageSpeed::Filters::CombineJavaScripts.new :store => {}, :hash => { %W(ohno.js foo.js) => "romanking" }
|
54
|
+
filter.send(:unique_id, nodes).should == "romanking"
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
@@ -19,7 +19,7 @@ RSpec.configure do |config|
|
|
19
19
|
store :disk => Dir.tmpdir + '/pagespeed'
|
20
20
|
inline_javascripts
|
21
21
|
inline_css
|
22
|
-
combine_javascripts
|
22
|
+
combine_javascripts :hash => { %W(js/jquery-1.4.2.min.js js/awesomebydesign.js) => "omghash" }
|
23
23
|
combine_css
|
24
24
|
end
|
25
25
|
run lambda { |env| [200, { 'Content-Type' => 'text/html' }, [File.read(File.join(zecoolwebsite, 'index.html')) ] ] }
|
@@ -31,23 +31,23 @@ feature "playing out in the real world" do
|
|
31
31
|
visit '/'
|
32
32
|
page.body.should include(fixture('zecoolwebsite/js/sayhi.js'))
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
scenario "bundles jquery and awesomebydesign.js together" do
|
36
36
|
visit '/'
|
37
|
-
page.should have_css('script[src*="rack-pagespeed"]')
|
37
|
+
page.should have_css('script[src*="rack-pagespeed-omghash"]')
|
38
38
|
page.should_not have_css('script[src*="jquery"]')
|
39
|
-
page.should_not have_css('script[src*="awesomebydesign"]')
|
40
|
-
|
39
|
+
page.should_not have_css('script[src*="awesomebydesign"]')
|
40
|
+
|
41
41
|
visit page.find('script[src*="rack-pagespeed"]')['src']
|
42
42
|
page.body.should == [fixture('zecoolwebsite/js/jquery-1.4.2.min.js'), fixture('zecoolwebsite/js/awesomebydesign.js')].join(';')
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
scenario "bundles reset.css and awesomebydesign.css together" do
|
46
46
|
visit '/'
|
47
47
|
page.should have_css('link[rel="stylesheet"][href*="rack-pagespeed"]')
|
48
48
|
page.should_not have_css('link[rel="stylesheet"][href*="reset.css"]')
|
49
|
-
page.should_not have_css('link[rel="stylesheet"][href*="awesomebydesign.css"]')
|
50
|
-
|
49
|
+
page.should_not have_css('link[rel="stylesheet"][href*="awesomebydesign.css"]')
|
50
|
+
|
51
51
|
visit page.find('link[rel="stylesheet"][href*="rack-pagespeed"]')['href']
|
52
52
|
page.body.should == [fixture('zecoolwebsite/css/reset.css'), fixture('zecoolwebsite/css/awesomebydesign.css')].join("\n")
|
53
53
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-pagespeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Julio Cesar Ody
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-24 00:00:00 +11:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - "="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
28
30
|
segments:
|
29
31
|
- 1
|
30
32
|
- 4
|
@@ -40,6 +42,7 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - "="
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
43
46
|
segments:
|
44
47
|
- 1
|
45
48
|
- 2
|
@@ -55,6 +58,7 @@ dependencies:
|
|
55
58
|
requirements:
|
56
59
|
- - "="
|
57
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 19
|
58
62
|
segments:
|
59
63
|
- 1
|
60
64
|
- 0
|
@@ -70,6 +74,7 @@ dependencies:
|
|
70
74
|
requirements:
|
71
75
|
- - "="
|
72
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 21
|
73
78
|
segments:
|
74
79
|
- 1
|
75
80
|
- 0
|
@@ -85,6 +90,7 @@ dependencies:
|
|
85
90
|
requirements:
|
86
91
|
- - "="
|
87
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 15
|
88
94
|
segments:
|
89
95
|
- 1
|
90
96
|
- 4
|
@@ -100,6 +106,7 @@ dependencies:
|
|
100
106
|
requirements:
|
101
107
|
- - "="
|
102
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 29
|
103
110
|
segments:
|
104
111
|
- 1
|
105
112
|
- 2
|
@@ -115,6 +122,7 @@ dependencies:
|
|
115
122
|
requirements:
|
116
123
|
- - "="
|
117
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 19
|
118
126
|
segments:
|
119
127
|
- 1
|
120
128
|
- 0
|
@@ -130,6 +138,7 @@ dependencies:
|
|
130
138
|
requirements:
|
131
139
|
- - "="
|
132
140
|
- !ruby/object:Gem::Version
|
141
|
+
hash: 47
|
133
142
|
segments:
|
134
143
|
- 1
|
135
144
|
- 16
|
@@ -144,6 +153,7 @@ dependencies:
|
|
144
153
|
requirements:
|
145
154
|
- - "="
|
146
155
|
- !ruby/object:Gem::Version
|
156
|
+
hash: 21
|
147
157
|
segments:
|
148
158
|
- 1
|
149
159
|
- 0
|
@@ -159,6 +169,7 @@ dependencies:
|
|
159
169
|
requirements:
|
160
170
|
- - "="
|
161
171
|
- !ruby/object:Gem::Version
|
172
|
+
hash: 11
|
162
173
|
segments:
|
163
174
|
- 2
|
164
175
|
- 1
|
@@ -174,6 +185,7 @@ dependencies:
|
|
174
185
|
requirements:
|
175
186
|
- - "="
|
176
187
|
- !ruby/object:Gem::Version
|
188
|
+
hash: 23
|
177
189
|
segments:
|
178
190
|
- 1
|
179
191
|
- 0
|
@@ -189,6 +201,7 @@ dependencies:
|
|
189
201
|
requirements:
|
190
202
|
- - "="
|
191
203
|
- !ruby/object:Gem::Version
|
204
|
+
hash: 15
|
192
205
|
segments:
|
193
206
|
- 0
|
194
207
|
- 4
|
@@ -285,6 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
285
298
|
requirements:
|
286
299
|
- - ">="
|
287
300
|
- !ruby/object:Gem::Version
|
301
|
+
hash: 3
|
288
302
|
segments:
|
289
303
|
- 0
|
290
304
|
version: "0"
|
@@ -293,6 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
307
|
requirements:
|
294
308
|
- - ">="
|
295
309
|
- !ruby/object:Gem::Version
|
310
|
+
hash: 3
|
296
311
|
segments:
|
297
312
|
- 0
|
298
313
|
version: "0"
|