panda 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/lib/panda/adapters/faraday.rb +6 -5
- data/lib/panda/connection.rb +2 -2
- data/lib/panda/modules/destroyers.rb +2 -2
- data/lib/panda/version.rb +1 -1
- data/spec/cloud_spec.rb +1 -1
- data/spec/video_spec.rb +16 -3
- metadata +33 -33
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Panda gem provides an interface to access the [Panda](http://pandastream.com) AP
|
|
19
19
|
access_key "panda_access_key"
|
20
20
|
secret_key "panda_secret_key"
|
21
21
|
cloud_id "panda_cloud_id"
|
22
|
-
# api_host "api
|
22
|
+
# api_host "api-eu.pandastream.com" ## for EU accounts
|
23
23
|
# api_port 80 ## to use http (default 443)
|
24
24
|
end
|
25
25
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'yajl/json_gem'
|
3
|
+
require 'typhoeus'
|
3
4
|
|
4
5
|
module Panda
|
5
6
|
module Adapter
|
@@ -51,16 +52,16 @@ module Panda
|
|
51
52
|
private
|
52
53
|
|
53
54
|
def connection
|
54
|
-
@conn ||= ::Faraday
|
55
|
-
builder.
|
56
|
-
builder.
|
55
|
+
@conn ||= ::Faraday.new(:url => @api_url) do |builder|
|
56
|
+
builder.request :url_encoded
|
57
|
+
builder.adapter :typhoeus
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
61
|
def rescue_json_parsing(&block)
|
61
62
|
begin
|
62
|
-
yield
|
63
|
-
rescue ::
|
63
|
+
Yajl::Parser.parse(yield)
|
64
|
+
rescue Yajl::ParseError => e
|
64
65
|
raise(ServiceNotAvailable)
|
65
66
|
end
|
66
67
|
end
|
data/lib/panda/connection.rb
CHANGED
@@ -2,7 +2,7 @@ module Panda
|
|
2
2
|
|
3
3
|
API_PORT=443
|
4
4
|
US_API_HOST="api.pandastream.com"
|
5
|
-
EU_API_HOST="api
|
5
|
+
EU_API_HOST="api-eu.pandastream.com"
|
6
6
|
|
7
7
|
class Connection
|
8
8
|
attr_accessor :api_host, :api_port, :access_key, :secret_key, :api_version, :cloud_id
|
@@ -58,7 +58,7 @@ module Panda
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def api_scheme
|
61
|
-
api_port == 443 ? 'https' : 'http'
|
61
|
+
api_port.to_i == 443 ? 'https' : 'http'
|
62
62
|
end
|
63
63
|
|
64
64
|
# Shortcut to setup your bucket
|
@@ -8,9 +8,9 @@ module Panda
|
|
8
8
|
module ClassMethods
|
9
9
|
|
10
10
|
def delete(id)
|
11
|
-
uri =
|
11
|
+
uri = create_rest_url(one_path,{:id =>id})
|
12
12
|
response = connection.delete(uri)
|
13
|
-
response['deleted']
|
13
|
+
!!response['deleted']
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
data/lib/panda/version.rb
CHANGED
data/spec/cloud_spec.rb
CHANGED
data/spec/video_spec.rb
CHANGED
@@ -122,14 +122,27 @@ describe Panda::Video do
|
|
122
122
|
region "eu"
|
123
123
|
end
|
124
124
|
|
125
|
-
stub_http_request(:get, /api
|
125
|
+
stub_http_request(:get, /api-eu.pandastream.com:443/).
|
126
|
+
to_return(:body => "{\"id\":\"123\"}")
|
127
|
+
Panda::Video.find "123"
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should accept a string as a port" do
|
131
|
+
Panda.configure do
|
132
|
+
access_key "my_access_key"
|
133
|
+
secret_key "my_secret_key"
|
134
|
+
cloud_id 'my_cloud_id'
|
135
|
+
api_port '443'
|
136
|
+
end
|
137
|
+
|
138
|
+
stub_http_request(:get, /https:\/\/api.pandastream.com:443/).
|
126
139
|
to_return(:body => "{\"id\":\"123\"}")
|
127
140
|
Panda::Video.find "123"
|
128
141
|
end
|
129
142
|
|
130
143
|
it "should connect to eu and trigger the request" do
|
131
144
|
cloud_json = "{\"s3_videos_bucket\":\"my_bucket\",\"id\":\"my_cloud_id\"}"
|
132
|
-
stub_http_request(:get, /api
|
145
|
+
stub_http_request(:get, /api-eu.pandastream.com:80\/v2\/clouds\/my_cloud_id.json/).
|
133
146
|
to_return(:body => cloud_json)
|
134
147
|
|
135
148
|
Panda.configure do |c|
|
@@ -139,7 +152,7 @@ describe Panda::Video do
|
|
139
152
|
c.region "eu"
|
140
153
|
end
|
141
154
|
|
142
|
-
stub_http_request(:get, /api
|
155
|
+
stub_http_request(:get, /api-eu.pandastream.com:443/).
|
143
156
|
to_return(:body => "{\"id\":\"123\"}")
|
144
157
|
Panda::Video.find "123"
|
145
158
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 4
|
10
|
+
version: 1.4.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- New Bamboo
|
@@ -15,12 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-25 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
22
|
none: false
|
25
23
|
requirements:
|
26
24
|
- - ">="
|
@@ -31,12 +29,12 @@ dependencies:
|
|
31
29
|
- 3
|
32
30
|
- 2
|
33
31
|
version: 0.3.2
|
32
|
+
name: ruby-hmac
|
34
33
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rest-client
|
38
34
|
prerelease: false
|
39
|
-
requirement:
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
38
|
none: false
|
41
39
|
requirements:
|
42
40
|
- - ">="
|
@@ -45,12 +43,12 @@ dependencies:
|
|
45
43
|
segments:
|
46
44
|
- 0
|
47
45
|
version: "0"
|
46
|
+
name: rest-client
|
48
47
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: json
|
52
48
|
prerelease: false
|
53
|
-
requirement:
|
49
|
+
requirement: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
52
|
none: false
|
55
53
|
requirements:
|
56
54
|
- - ">="
|
@@ -59,12 +57,12 @@ dependencies:
|
|
59
57
|
segments:
|
60
58
|
- 0
|
61
59
|
version: "0"
|
60
|
+
name: json
|
62
61
|
type: :runtime
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rake
|
66
62
|
prerelease: false
|
67
|
-
requirement:
|
63
|
+
requirement: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
66
|
none: false
|
69
67
|
requirements:
|
70
68
|
- - ">="
|
@@ -73,12 +71,12 @@ dependencies:
|
|
73
71
|
segments:
|
74
72
|
- 0
|
75
73
|
version: "0"
|
74
|
+
name: rake
|
76
75
|
type: :development
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: timecop
|
80
76
|
prerelease: false
|
81
|
-
requirement:
|
77
|
+
requirement: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
82
80
|
none: false
|
83
81
|
requirements:
|
84
82
|
- - ">="
|
@@ -87,12 +85,12 @@ dependencies:
|
|
87
85
|
segments:
|
88
86
|
- 0
|
89
87
|
version: "0"
|
88
|
+
name: timecop
|
90
89
|
type: :development
|
91
|
-
version_requirements: *id005
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
|
-
name: rspec
|
94
90
|
prerelease: false
|
95
|
-
requirement:
|
91
|
+
requirement: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
96
94
|
none: false
|
97
95
|
requirements:
|
98
96
|
- - "="
|
@@ -103,12 +101,12 @@ dependencies:
|
|
103
101
|
- 4
|
104
102
|
- 0
|
105
103
|
version: 2.4.0
|
104
|
+
name: rspec
|
106
105
|
type: :development
|
107
|
-
version_requirements: *id006
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
name: webmock
|
110
106
|
prerelease: false
|
111
|
-
requirement:
|
107
|
+
requirement: *id006
|
108
|
+
- !ruby/object:Gem::Dependency
|
109
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
112
110
|
none: false
|
113
111
|
requirements:
|
114
112
|
- - ">="
|
@@ -117,8 +115,10 @@ dependencies:
|
|
117
115
|
segments:
|
118
116
|
- 0
|
119
117
|
version: "0"
|
118
|
+
name: webmock
|
120
119
|
type: :development
|
121
|
-
|
120
|
+
prerelease: false
|
121
|
+
requirement: *id007
|
122
122
|
description: Panda Client
|
123
123
|
email:
|
124
124
|
- info@pandastream.com
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
requirements: []
|
204
204
|
|
205
205
|
rubyforge_project: panda
|
206
|
-
rubygems_version: 1.8.
|
206
|
+
rubygems_version: 1.8.6
|
207
207
|
signing_key:
|
208
208
|
specification_version: 3
|
209
209
|
summary: Panda Client
|