ngzip 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/lib/ngzip.rb +2 -2
- data/lib/ngzip/builder.rb +5 -8
- data/lib/ngzip/version.rb +1 -1
- data/test/data/a/A filename with whitespace.txt +1 -0
- data/test/lib/ngzip/builder_test.rb +12 -8
- metadata +6 -4
- data/CHANGELOG +0 -7
data/CHANGELOG.md
ADDED
data/lib/ngzip.rb
CHANGED
data/lib/ngzip/builder.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'zlib'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module Ngzip
|
4
5
|
|
5
6
|
class Builder
|
6
7
|
|
7
8
|
BUFFER_SIZE = 8 * 1024
|
8
|
-
|
9
|
+
|
9
10
|
# Public: Build the files manifest for mod_zip, see http://wiki.nginx.org/NginxNgxZip for the specs.
|
10
11
|
#
|
11
12
|
# files - An Array of absolute file path elements
|
@@ -23,14 +24,13 @@ module Ngzip
|
|
23
24
|
list = file_list(files)
|
24
25
|
prefix = detect_common_prefix(list)
|
25
26
|
list.map do |f|
|
26
|
-
sprintf(
|
27
|
+
sprintf('%s %d %s %s',
|
27
28
|
compute_crc32(f, settings),
|
28
29
|
File.size(f).to_i,
|
29
|
-
f,
|
30
|
+
URI.escape(f),
|
30
31
|
f.gsub(prefix, '')
|
31
32
|
)
|
32
|
-
end.join("\n")
|
33
|
-
|
33
|
+
end.join("\n")
|
34
34
|
end
|
35
35
|
|
36
36
|
# Public: Get the special header to signal the mod_zip
|
@@ -70,7 +70,6 @@ module Ngzip
|
|
70
70
|
e
|
71
71
|
end
|
72
72
|
end.flatten
|
73
|
-
|
74
73
|
end
|
75
74
|
|
76
75
|
|
@@ -99,8 +98,6 @@ module Ngzip
|
|
99
98
|
crc32.to_s(16)
|
100
99
|
end
|
101
100
|
|
102
|
-
|
103
|
-
|
104
101
|
end
|
105
102
|
|
106
103
|
end
|
data/lib/ngzip/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "../../test_helper"
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
describe Ngzip do
|
4
5
|
|
@@ -13,6 +14,7 @@ describe Ngzip::Builder do
|
|
13
14
|
let(:builder) {Ngzip::Builder.new()}
|
14
15
|
let(:lorem) {File.expand_path('../../../data/a/lorem.txt', __FILE__)}
|
15
16
|
let(:ipsum) {File.expand_path('../../../data/a/ipsum.txt', __FILE__)}
|
17
|
+
let(:whitespaced) {File.expand_path('../../../data/a/A filename with whitespace.txt', __FILE__)}
|
16
18
|
let(:cargo) {File.expand_path('../../../data/b/Cargo.png', __FILE__)}
|
17
19
|
let(:sit) {File.expand_path('../../../data/sit.txt', __FILE__)}
|
18
20
|
let(:a) {File.expand_path('../../../data/a', __FILE__)}
|
@@ -51,13 +53,21 @@ describe Ngzip::Builder do
|
|
51
53
|
builder.build(cargo, options).must_equal expected
|
52
54
|
end
|
53
55
|
|
56
|
+
it 'must escape the path name' do
|
57
|
+
expected = "8f92322f 446 #{URI.escape(whitespaced)} A filename with whitespace.txt"
|
58
|
+
builder.build(whitespaced, options).must_equal expected
|
59
|
+
end
|
60
|
+
|
54
61
|
it 'must return a correct list for all files in a directory' do
|
55
|
-
expected = "8f92322f 446 #{
|
62
|
+
expected = "8f92322f 446 #{URI.escape(whitespaced)} A filename with whitespace.txt"
|
63
|
+
expected << "\n8f92322f 446 #{ipsum} ipsum.txt"
|
64
|
+
expected << "\n8f92322f 446 #{lorem} lorem.txt"
|
56
65
|
builder.build(a,options).must_equal expected
|
57
66
|
end
|
58
67
|
|
59
68
|
it 'must allow to mix files and directories' do
|
60
|
-
expected = "8f92322f 446 #{
|
69
|
+
expected = "8f92322f 446 #{URI.escape(whitespaced)} a/A filename with whitespace.txt"
|
70
|
+
expected << "\n8f92322f 446 #{ipsum} a/ipsum.txt"
|
61
71
|
expected << "\n8f92322f 446 #{lorem} a/lorem.txt"
|
62
72
|
expected << "\nf7c0867d 1342 #{sit} sit.txt"
|
63
73
|
builder.build([a,sit], options).must_equal expected
|
@@ -77,13 +87,7 @@ describe Ngzip::Builder do
|
|
77
87
|
expected = "#{invalid_but_cached} 446 #{lorem} lorem.txt"
|
78
88
|
builder.build(lorem, options.merge(:crc_cache => {lorem => invalid_but_cached})).must_equal expected
|
79
89
|
end
|
80
|
-
|
81
90
|
|
82
91
|
end
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
93
|
end
|
89
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngzip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -53,7 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
55
|
- .rvmrc
|
56
|
-
- CHANGELOG
|
56
|
+
- CHANGELOG.md
|
57
57
|
- Gemfile
|
58
58
|
- LICENSE.txt
|
59
59
|
- README.md
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/ngzip/builder.rb
|
63
63
|
- lib/ngzip/version.rb
|
64
64
|
- ngzip.gemspec
|
65
|
+
- test/data/a/A filename with whitespace.txt
|
65
66
|
- test/data/a/ipsum.txt
|
66
67
|
- test/data/a/lorem.txt
|
67
68
|
- test/data/b/Cargo.png
|
@@ -85,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
86
|
version: '0'
|
86
87
|
segments:
|
87
88
|
- 0
|
88
|
-
hash:
|
89
|
+
hash: 3803006848080428378
|
89
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
91
|
none: false
|
91
92
|
requirements:
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
segments:
|
96
97
|
- 0
|
97
|
-
hash:
|
98
|
+
hash: 3803006848080428378
|
98
99
|
requirements: []
|
99
100
|
rubyforge_project:
|
100
101
|
rubygems_version: 1.8.25
|
@@ -102,6 +103,7 @@ signing_key:
|
|
102
103
|
specification_version: 3
|
103
104
|
summary: Provides a nginx mod_zip compatible file manifest for streaming support
|
104
105
|
test_files:
|
106
|
+
- test/data/a/A filename with whitespace.txt
|
105
107
|
- test/data/a/ipsum.txt
|
106
108
|
- test/data/a/lorem.txt
|
107
109
|
- test/data/b/Cargo.png
|