magnum-pi 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/magnum-pi.rb +1 -0
- data/lib/magnum-pi/api/consumer.rb +10 -1
- data/lib/magnum-pi/version.rb +1 -1
- data/magnum-pi.gemspec +1 -0
- data/test/unit/api/test_consumer.rb +8 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDRjMjBkMWFjOTk2YjMzMDJhMGVmMmM3OTNiMDQ4N2ExNDI1ZTI2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDYzODBlY2VmYmQxMTViNTc3MjYxNjM3MjljNTJhNjgxOTUyODNhYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWNiMWExYzFmNDVkOGRkNmRmNmY5MjRiMDA1OWQyYjFhZWY3YjRmYjNlMmYx
|
10
|
+
ODI3Yzg2NmIyMmQ2NGM3MjA5YWZkZGRkYWMxNjVlOWNkNjhiZTRmNjcxNDYz
|
11
|
+
ZDUzMWEwMTdmYzljZDRlNDc2NzdhN2FkNTViNTIzYWI3Zjc1YmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWY3YzFiOGVhYWU5MmE0ODk4ZjM0NjgwMGQ0YmY1MzgzMTA1NmQ2YzA1NWUx
|
14
|
+
NjRkMzUwZDJhMmFhZDAyNGNlNTk5Mzk1YzE5ZWZhNzEzOWYwZTEzNmUxYTBl
|
15
|
+
YTNhYmUyZGIxZDA1ZmZmYmMxYTc1M2ViZDlmMmU2ZDIwMjIzZTk=
|
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/lib/magnum-pi.rb
CHANGED
@@ -16,7 +16,16 @@ module MagnumPI
|
|
16
16
|
def download(target, method, *args)
|
17
17
|
url, params = parse_args *args
|
18
18
|
File.delete target if File.exists? target
|
19
|
-
|
19
|
+
FileUtils.mkdir_p File.dirname(target)
|
20
|
+
file = File.open target, "w"
|
21
|
+
begin
|
22
|
+
request = Typhoeus::Request.new url, :method => method, :params => params
|
23
|
+
request.on_headers {|response| raise "Failed to download #{target}" unless (response.response_code / 200) == 1}
|
24
|
+
request.on_body {|chunk| file.write chunk.force_encoding("UTF-8")}
|
25
|
+
request.run
|
26
|
+
ensure
|
27
|
+
file.close
|
28
|
+
end
|
20
29
|
true
|
21
30
|
end
|
22
31
|
|
data/lib/magnum-pi/version.rb
CHANGED
data/magnum-pi.gemspec
CHANGED
@@ -44,9 +44,14 @@ module Unit
|
|
44
44
|
end
|
45
45
|
describe "#download" do
|
46
46
|
it "downloads using the Mechanize agent" do
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
file, request = mock, mock
|
48
|
+
FileUtils.expects(:mkdir_p).with("path/to")
|
49
|
+
File.expects(:open).with("path/to/target", "w").returns(file)
|
50
|
+
Typhoeus::Request.expects(:new).with("http://foo.bar", :method => :get, :params => {:foo => "bar"}).returns(request)
|
51
|
+
file.expects(:close)
|
52
|
+
request.expects(:on_headers)
|
53
|
+
request.expects(:on_body)
|
54
|
+
request.expects(:run)
|
50
55
|
@consumer.download "path/to/target", :get, :foo => "bar"
|
51
56
|
end
|
52
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magnum-pi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Engel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: oj
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|