capgun 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/HISTORY.md +4 -0
- data/lib/capgun/config.rb +0 -2
- data/lib/capgun/version.rb +1 -1
- data/spec/capgun/client_spec.rb +13 -13
- data/spec/capgun/config_spec.rb +1 -1
- data/spec/capgun/order_spec.rb +14 -14
- data/spec/capgun/version_spec.rb +1 -1
- data/spec/faraday/response_spec.rb +3 -3
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
HISTORY
|
2
2
|
=======
|
3
3
|
|
4
|
+
0.1.1 - May 24th, 2013
|
5
|
+
--------------------------------------------------------------------------------
|
6
|
+
* clean up
|
7
|
+
|
4
8
|
0.1.0 - May 5, 2013
|
5
9
|
--------------------------------------------------------------------------------
|
6
10
|
* options for capture and estimate can be given in a block
|
data/lib/capgun/config.rb
CHANGED
@@ -37,8 +37,6 @@ module Capgun
|
|
37
37
|
:proxy,
|
38
38
|
]
|
39
39
|
|
40
|
-
#ORDER_OPTIONS = Struct.new(:id, :url, :notify, :cost, :viewport, :packages, :images, :asset_urls, :options, :job)
|
41
|
-
|
42
40
|
attr_accessor *VALID_OPTIONS_KEYS
|
43
41
|
|
44
42
|
# When this module is extended, set all configuration options to their default values
|
data/lib/capgun/version.rb
CHANGED
data/spec/capgun/client_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Capgun::Client do
|
|
11
11
|
specify "not allowed to get estimates without authorization" do
|
12
12
|
stub_request(:post, "https://api.capgun.io/v1/orders/estimate.json").
|
13
13
|
with(:body => "{\"url\":\"http://example.com/test\"}",
|
14
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
14
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
15
15
|
to_return(:status => 401, :body => fixture("unauthorized.json"), :headers => {})
|
16
16
|
|
17
17
|
lambda { Capgun.estimate("http://example.com/test") }.should raise_error(Capgun::Error::Unauthorized, "Unauthorized")
|
@@ -20,7 +20,7 @@ describe Capgun::Client do
|
|
20
20
|
specify "no urls are submitted for capture" do
|
21
21
|
stub_request(:post, "https://api.capgun.io/v1/orders.json").
|
22
22
|
with(:body => "{\"url\":\"http://example.com/test\"}",
|
23
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
23
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
24
24
|
to_return(:status => 401, :body => fixture("unauthorized.json"), :headers => {})
|
25
25
|
|
26
26
|
lambda { Capgun.capture("http://example.com/test") }.should raise_error(Capgun::Error::Unauthorized, "Unauthorized")
|
@@ -28,7 +28,7 @@ describe Capgun::Client do
|
|
28
28
|
|
29
29
|
specify "not allowed to view on order without authorization" do
|
30
30
|
stub_request(:get, "https://api.capgun.io/v1/orders/4fd20a1288f560177600000a.json").
|
31
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
31
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
32
32
|
to_return(:status => 401, :body => fixture("unauthorized.json"), :headers => {})
|
33
33
|
|
34
34
|
lambda { Capgun.order("4fd20a1288f560177600000a") }.should raise_error(Capgun::Error::Unauthorized, "Unauthorized")
|
@@ -36,7 +36,7 @@ describe Capgun::Client do
|
|
36
36
|
|
37
37
|
specify "not allowed to view job status without authorization" do
|
38
38
|
stub_request(:get, "https://api.capgun.io/v1/jobs/4fd20a1288f5601776000012.json").
|
39
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
39
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
40
40
|
to_return(:status => 401, :body => fixture('unauthorized.json'), :headers => {})
|
41
41
|
|
42
42
|
lambda { Capgun.status("4fd20a1288f5601776000012") }.should raise_error(Capgun::Error::Unauthorized, "Unauthorized")
|
@@ -44,7 +44,7 @@ describe Capgun::Client do
|
|
44
44
|
|
45
45
|
specify "not allowed to view account" do
|
46
46
|
stub_request(:get, "https://api.capgun.io/v1/account.json").
|
47
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
47
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
48
48
|
to_return(:status => 401, :body => fixture('unauthorized.json'), :headers => {})
|
49
49
|
|
50
50
|
lambda { Capgun.account }.should raise_error(Capgun::Error::Unauthorized, "Unauthorized")
|
@@ -67,7 +67,7 @@ describe Capgun::Client do
|
|
67
67
|
specify "get an estimate to capture a url" do
|
68
68
|
stub_request(:post, "https://api.capgun.io/v1/orders/estimate.json").
|
69
69
|
with(:body => "{\"url\":\"http://example.com/test\"}",
|
70
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
70
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
71
71
|
to_return(:status => 200, :body => fixture("estimate.json"), :headers => {})
|
72
72
|
|
73
73
|
estimate = Capgun.estimate("http://example.com/test")
|
@@ -77,7 +77,7 @@ describe Capgun::Client do
|
|
77
77
|
specify "estimate with options in a block" do
|
78
78
|
stub_request(:post, "https://api.capgun.io/v1/orders/estimate.json").
|
79
79
|
with(:body => '{"viewport":"1024x2048","packages":["images","viewport"],"url":"http://example.com/test"}',
|
80
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
80
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
81
81
|
to_return(:status => 200, :body => fixture("estimate-with-options.json"), :headers => {})
|
82
82
|
|
83
83
|
estimate = Capgun.estimate("http://example.com/test", :viewport => "200x100") do |options|
|
@@ -90,7 +90,7 @@ describe Capgun::Client do
|
|
90
90
|
specify "urls are submitted for capture" do
|
91
91
|
stub_request(:post, "https://api.capgun.io/v1/orders.json").
|
92
92
|
with(:body => "{\"url\":\"http://example.com/test\"}",
|
93
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
93
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
94
94
|
to_return(:status => 200, :body => fixture("order.json"), :headers => {})
|
95
95
|
|
96
96
|
order = Capgun.capture("http://example.com/test")
|
@@ -101,7 +101,7 @@ describe Capgun::Client do
|
|
101
101
|
specify "capture with options can be in a block" do
|
102
102
|
stub_request(:post, "https://api.capgun.io/v1/orders.json").
|
103
103
|
with(:body => '{"packages":["images","viewport"],"viewport":"1024x2048","url":"http://example.com/test"}',
|
104
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
104
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
105
105
|
to_return(:status => 200, :body => fixture("order-with-options.json"), :headers => {})
|
106
106
|
|
107
107
|
order = Capgun.capture("http://example.com/test", :packages => [ :images, :viewport ], :viewport => "1024x2048")
|
@@ -114,7 +114,7 @@ describe Capgun::Client do
|
|
114
114
|
specify "capture with options can be in a block" do
|
115
115
|
stub_request(:post, "https://api.capgun.io/v1/orders.json").
|
116
116
|
with(:body => '{"viewport":"1024x2048","packages":["images","viewport"],"url":"http://example.com/test"}',
|
117
|
-
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
117
|
+
:headers => {'Accept'=>'application/json', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
118
118
|
to_return(:status => 200, :body => fixture("order-with-options.json"), :headers => {})
|
119
119
|
|
120
120
|
order = Capgun.capture("http://example.com/test", :viewport => "200x100") do |options|
|
@@ -129,7 +129,7 @@ describe Capgun::Client do
|
|
129
129
|
|
130
130
|
specify "showing a capture order" do
|
131
131
|
stub_request(:get, "https://api.capgun.io/v1/orders/4fd20a1288f560177600000a.json").
|
132
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
132
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
133
133
|
to_return(:status => 200, :body => fixture("order.json"), :headers => {})
|
134
134
|
|
135
135
|
order = Capgun.order("4fd20a1288f560177600000a")
|
@@ -139,7 +139,7 @@ describe Capgun::Client do
|
|
139
139
|
|
140
140
|
specify "capture jobs have a status" do
|
141
141
|
stub_request(:get, "https://api.capgun.io/v1/jobs/4fd20a1288f5601776000012.json").
|
142
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
142
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
143
143
|
to_return(:status => 200, :body => fixture('job.json'), :headers => {})
|
144
144
|
|
145
145
|
|
@@ -150,7 +150,7 @@ describe Capgun::Client do
|
|
150
150
|
|
151
151
|
specify "account can be retrieved" do
|
152
152
|
stub_request(:get, "https://api.capgun.io/v1/account.json").
|
153
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
153
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'test', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
154
154
|
to_return(:status => 200, :body => fixture('account.json'), :headers => {})
|
155
155
|
|
156
156
|
account = Capgun.account
|
data/spec/capgun/config_spec.rb
CHANGED
data/spec/capgun/order_spec.rb
CHANGED
@@ -4,41 +4,41 @@ describe Capgun::Order do
|
|
4
4
|
|
5
5
|
describe "#==" do
|
6
6
|
it "should return true when ids and classes are equal" do
|
7
|
-
|
7
|
+
order = Capgun::Order.new('id' => 1)
|
8
8
|
other = Capgun::Order.new('id' => 1)
|
9
|
-
(
|
9
|
+
(order == other).should be_true
|
10
10
|
end
|
11
11
|
it "should return false when classes are not equal" do
|
12
|
-
|
12
|
+
order = Capgun::Order.new('id' => 1)
|
13
13
|
other = Capgun::Job.new('id' => 1)
|
14
|
-
(
|
14
|
+
(order == other).should be_false
|
15
15
|
end
|
16
16
|
it "should return false when ids are not equal" do
|
17
|
-
|
17
|
+
order = Capgun::Order.new('id' => 1)
|
18
18
|
other = Capgun::Order.new('id' => 2)
|
19
|
-
(
|
19
|
+
(order == other).should be_false
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "#created_at" do
|
24
24
|
it "should return a Time when created_at is set" do
|
25
|
-
|
26
|
-
|
25
|
+
order = Capgun::Order.new('created_at' => "Mon Jul 16 12:59:01 +0000.1.17")
|
26
|
+
order.created_at.should be_a Time
|
27
27
|
end
|
28
28
|
it "should return nil when created_at is not set" do
|
29
|
-
|
30
|
-
|
29
|
+
order = Capgun::Order.new
|
30
|
+
order.created_at.should be_nil
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#updated_at" do
|
35
35
|
it "should return a Time when updated_at is set" do
|
36
|
-
|
37
|
-
|
36
|
+
order = Capgun::Order.new('updated_at' => "Mon Jul 16 12:59:01 +0000.1.17")
|
37
|
+
order.updated_at.should be_a Time
|
38
38
|
end
|
39
39
|
it "should return nil when updated_at is not set" do
|
40
|
-
|
41
|
-
|
40
|
+
order = Capgun::Order.new
|
41
|
+
order.updated_at.should be_nil
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
data/spec/capgun/version_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Faraday::Response do
|
|
19
19
|
context "when HTTP status is #{status}" do
|
20
20
|
before do
|
21
21
|
stub_request(:get, "https://api.capgun.io/v1/jobs/abc123.json").
|
22
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
22
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
23
23
|
to_return(:status => status, :body => "", :headers => {})
|
24
24
|
end
|
25
25
|
|
@@ -35,7 +35,7 @@ describe Faraday::Response do
|
|
35
35
|
before do
|
36
36
|
body_message = '{"'+body+'":"test"}' unless body.nil?
|
37
37
|
stub_request(:get, "https://api.capgun.io/v1/jobs/abc123.json").
|
38
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
38
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
39
39
|
to_return(:status => status, :body => body_message, :headers => {})
|
40
40
|
end
|
41
41
|
|
@@ -54,7 +54,7 @@ describe Faraday::Response do
|
|
54
54
|
before do
|
55
55
|
|
56
56
|
stub_request(:get, "https://api.capgun.io/v1/jobs/abc123.json").
|
57
|
-
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.
|
57
|
+
with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'User-Agent'=>'Capgun.io Ruby Gem 0.1.1'}).
|
58
58
|
to_return(:status => 404, :body => fixture('notfound.json'), :headers => {})
|
59
59
|
end
|
60
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capgun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
240
|
version: '0'
|
241
241
|
segments:
|
242
242
|
- 0
|
243
|
-
hash:
|
243
|
+
hash: -3140388304714263018
|
244
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
245
|
none: false
|
246
246
|
requirements:
|
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: -3140388304714263018
|
253
253
|
requirements: []
|
254
254
|
rubyforge_project: capgun
|
255
255
|
rubygems_version: 1.8.23
|