pinch 0.0.4 → 0.0.6
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/lib/pinch.rb +10 -6
- data/spec/pinch_spec.rb +18 -1
- metadata +1 -1
data/lib/pinch.rb
CHANGED
@@ -3,7 +3,7 @@ require 'net/http'
|
|
3
3
|
require 'zlib'
|
4
4
|
|
5
5
|
class Pinch
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.6"
|
7
7
|
|
8
8
|
attr_reader :uri
|
9
9
|
attr_reader :file_name
|
@@ -47,12 +47,16 @@ private
|
|
47
47
|
raise Errno::ENOENT if file_headers[file_name].nil?
|
48
48
|
|
49
49
|
req = Net::HTTP::Get.new(uri.path)
|
50
|
+
padding = 16
|
51
|
+
|
50
52
|
req.set_range(file_headers[file_name][16],
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
30 +
|
54
|
+
file_headers[file_name][16] +
|
55
|
+
file_headers[file_name][8] +
|
56
|
+
file_headers[file_name][10] +
|
57
|
+
file_headers[file_name][11] +
|
58
|
+
file_headers[file_name][12] +
|
59
|
+
padding)
|
56
60
|
|
57
61
|
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
58
62
|
http.request(req)
|
data/spec/pinch_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Pinch do
|
|
14
14
|
it "should return the contents of the file" do
|
15
15
|
data = Pinch.get @url, @file
|
16
16
|
data.must_match(/Morphic graphics architecture/)
|
17
|
-
data.size.must_equal
|
17
|
+
data.size.must_equal 26431
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -31,6 +31,23 @@ describe Pinch do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe "when calling get on the example zip file" do
|
35
|
+
before do
|
36
|
+
@url = 'http://peterhellberg.github.com/pinch/test.zip'
|
37
|
+
@file = 'data.json'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should retrieve the contents of the file data.json" do
|
41
|
+
data = Pinch.get @url, @file
|
42
|
+
data.must_equal "{\"gem\":\"pinch\",\"authors\":[\"Peter Hellberg\",\"Edward Patel\"],\"github_url\":\"https://github.com/peterhellberg/pinch\"}\n"
|
43
|
+
data.size.must_equal 114
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should contain three files" do
|
47
|
+
Pinch.file_list(@url).size.must_equal 3
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
34
51
|
describe "#file_list" do
|
35
52
|
before do
|
36
53
|
@url = 'http://memention.com/ericjohnson-canabalt-ios-ef43b7d.zip'
|