pinch 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/pinch.rb +10 -6
  2. data/spec/pinch_spec.rb +18 -1
  3. 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.4"
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
- file_headers[file_name][16] +
52
- file_headers[file_name][8] +
53
- file_headers[file_name][10] +
54
- file_headers[file_name][11] +
55
- file_headers[file_name][12] + 30)
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 26424
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'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pinch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter Hellberg