panda 1.3.0 → 1.4.0
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/.gitignore +21 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +2 -14
- data/README.md +38 -32
- data/Rakefile +9 -27
- data/lib/panda.rb +9 -3
- data/lib/panda/adapters/adapter.rb +4 -0
- data/lib/panda/adapters/faraday.rb +70 -0
- data/lib/panda/adapters/restclient.rb +67 -0
- data/lib/panda/api_authentication.rb +2 -0
- data/lib/panda/base.rb +23 -21
- data/lib/panda/config.rb +58 -0
- data/lib/panda/connection.rb +33 -122
- data/lib/panda/errors.rb +17 -0
- data/lib/panda/modules/builders.rb +18 -10
- data/lib/panda/modules/destroyers.rb +25 -0
- data/lib/panda/modules/finders.rb +10 -4
- data/lib/panda/modules/router.rb +16 -10
- data/lib/panda/modules/updatable.rb +3 -2
- data/lib/panda/modules/video_state.rb +16 -0
- data/lib/panda/modules/viewable.rb +19 -0
- data/lib/panda/panda.rb +41 -20
- data/lib/panda/proxies/proxy.rb +3 -1
- data/lib/panda/proxies/scope.rb +34 -28
- data/lib/panda/resources/cloud.rb +13 -11
- data/lib/panda/resources/encoding.rb +4 -19
- data/lib/panda/resources/resource.rb +2 -12
- data/lib/panda/resources/video.rb +4 -1
- data/lib/panda/version.rb +3 -0
- data/panda.gemspec +22 -105
- data/spec/cloud_spec.rb +44 -35
- data/spec/encoding_spec.rb +28 -9
- data/spec/heroku_spec.rb +15 -5
- data/spec/panda_spec.rb +41 -68
- data/spec/profile_spec.rb +6 -6
- data/spec/spec_helper.rb +3 -4
- data/spec/video_spec.rb +68 -19
- metadata +44 -98
- data/VERSION +0 -1
- data/lib/panda/error.rb +0 -29
- data/lib/panda/modules/short_status.rb +0 -13
data/spec/video_spec.rb
CHANGED
@@ -2,13 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe Panda::Video do
|
4
4
|
before(:each) do
|
5
|
-
|
6
|
-
Panda.configure do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
|
6
|
+
Panda.configure do
|
7
|
+
access_key "my_access_key"
|
8
|
+
secret_key "my_secret_key"
|
9
|
+
api_host "api.example.com"
|
10
|
+
cloud_id 'my_cloud_id'
|
11
|
+
api_port 85
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
@@ -50,6 +50,13 @@ describe Panda::Video do
|
|
50
50
|
video.source_url.should == "my_source_url"
|
51
51
|
end
|
52
52
|
|
53
|
+
it "should raise exception if id is nil" do
|
54
|
+
|
55
|
+
lambda {
|
56
|
+
Panda::Video.find(nil)
|
57
|
+
}.should raise_error('find method requires a correct value')
|
58
|
+
|
59
|
+
end
|
53
60
|
|
54
61
|
it "should list all video's encodings" do
|
55
62
|
video_json = "{\"source_url\":\"my_source_url\",\"id\":\"123\"}"
|
@@ -87,7 +94,7 @@ describe Panda::Video do
|
|
87
94
|
|
88
95
|
lambda {
|
89
96
|
Panda::Video.find "abc"
|
90
|
-
}.should raise_error("error-abc: no-abc")
|
97
|
+
}.should raise_error(Panda::APIError, "error-abc: no-abc")
|
91
98
|
end
|
92
99
|
|
93
100
|
it "should have an error object if something goes wrong" do
|
@@ -100,8 +107,7 @@ describe Panda::Video do
|
|
100
107
|
obj.save
|
101
108
|
|
102
109
|
obj.errors.size.should == 1
|
103
|
-
obj.errors.first.
|
104
|
-
obj.errors.first.error_class.should == "error-abc"
|
110
|
+
obj.errors.first.to_s.should == "error-abc: no-abc"
|
105
111
|
obj.attributes.should == original_attrs
|
106
112
|
|
107
113
|
end
|
@@ -109,11 +115,11 @@ describe Panda::Video do
|
|
109
115
|
it "should connect to eu" do
|
110
116
|
|
111
117
|
|
112
|
-
Panda.configure do
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
Panda.configure do
|
119
|
+
access_key "my_access_key"
|
120
|
+
secret_key "my_secret_key"
|
121
|
+
cloud_id 'my_cloud_id'
|
122
|
+
region "eu"
|
117
123
|
end
|
118
124
|
|
119
125
|
stub_http_request(:get, /api.eu.pandastream.com:443/).
|
@@ -127,10 +133,10 @@ describe Panda::Video do
|
|
127
133
|
to_return(:body => cloud_json)
|
128
134
|
|
129
135
|
Panda.configure do |c|
|
130
|
-
c.access_key
|
131
|
-
c.secret_key
|
132
|
-
c.cloud_id
|
133
|
-
c.region
|
136
|
+
c.access_key "my_access_key"
|
137
|
+
c.secret_key "my_secret_key"
|
138
|
+
c.cloud_id 'my_cloud_id'
|
139
|
+
c.region "eu"
|
134
140
|
end
|
135
141
|
|
136
142
|
stub_http_request(:get, /api.eu.pandastream.com:443/).
|
@@ -177,6 +183,20 @@ describe Panda::Video do
|
|
177
183
|
video.id.should == "123"
|
178
184
|
end
|
179
185
|
|
186
|
+
it "should create a video using class method and a block" do
|
187
|
+
video_json = "{\"source_url\":\"url_panda.mp4\",\"id\":\"123\"}"
|
188
|
+
|
189
|
+
stub_http_request(:post, /api.example.com:85\/v2\/videos.json/).
|
190
|
+
with(:body => /source_url=url_panda.mp4/).
|
191
|
+
to_return(:body => video_json)
|
192
|
+
|
193
|
+
video = Panda::Video.create do |v|
|
194
|
+
v.source_url = "url_panda.mp4"
|
195
|
+
end
|
196
|
+
|
197
|
+
video.id.should == "123"
|
198
|
+
end
|
199
|
+
|
180
200
|
it "should return a json on attributes" do
|
181
201
|
video = Panda::Video.new(:attr => "value")
|
182
202
|
video.to_json.should == video.attributes.to_json
|
@@ -225,6 +245,35 @@ describe Panda::Video do
|
|
225
245
|
WebMock.should have_requested(:get, /api.example.com:85\/v2\/videos\/123\/encodings.json/).once
|
226
246
|
end
|
227
247
|
|
248
|
+
it 'should generate json of encodings' do
|
249
|
+
video_json = "{\"source_url\":\"url_panda.mp4\",\"id\":\"123\"}"
|
250
|
+
stub_http_request(:get, /api.example.com:85\/v2\/videos\/123.json/).to_return(:body => video_json)
|
251
|
+
video = Panda::Video.find("123")
|
252
|
+
|
253
|
+
encodings_json = "[{\"abc\":\"my_source_url\",\"id\":\"456\"}]"
|
254
|
+
stub_http_request(:get, /api.example.com:85\/v2\/videos\/123\/encodings.json/).to_return(:body => encodings_json)
|
255
|
+
|
256
|
+
video.encodings.to_json.should == "[{\"abc\":\"my_source_url\",\"id\":\"456\",\"cloud_id\":\"my_cloud_id\"}]"
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should return the video url" do
|
260
|
+
cloud_json = "{\"s3_videos_bucket\":\"my_bucket\",\"id\":\"my_cloud_id\", \"url\":\"http://my_bucket.s3.amazonaws.com/\"}"
|
261
|
+
stub_http_request(:get, /api.example.com:85\/v2\/clouds\/my_cloud_id.json/).
|
262
|
+
to_return(:body => cloud_json)
|
263
|
+
|
264
|
+
video = Panda::Video.new({:id => "456", :extname => ".ext", :path => "abc/panda", :status => 'success'})
|
265
|
+
video.url.should == "http://my_bucket.s3.amazonaws.com/abc/panda.ext"
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should generate a screenhost array" do
|
269
|
+
cloud_json = "{\"s3_videos_bucket\":\"my_bucket\",\"id\":\"my_cloud_id\", \"url\":\"http://my_bucket.s3.amazonaws.com/\"}"
|
270
|
+
stub_http_request(:get, /api.example.com:85\/v2\/clouds\/my_cloud_id.json/).
|
271
|
+
to_return(:body => cloud_json)
|
272
|
+
|
273
|
+
video = Panda::Video.new({:id => "456", :extname => ".ext", :status => "success", :path => "abc/panda"})
|
274
|
+
video.screenshots[0].should == "http://my_bucket.s3.amazonaws.com/abc/panda_1.jpg"
|
275
|
+
end
|
276
|
+
|
228
277
|
it "should call the request if the scope has changed" do
|
229
278
|
video_json = "{\"source_url\":\"url_panda.mp4\",\"id\":\"123\"}"
|
230
279
|
stub_http_request(:get, /api.example.com:85\/v2\/videos\/123.json/).to_return(:body => video_json)
|
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: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- New Bamboo
|
@@ -15,10 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-04 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
name: ruby-hmac
|
23
|
+
prerelease: false
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
@@ -30,11 +32,11 @@ dependencies:
|
|
30
32
|
- 3
|
31
33
|
- 2
|
32
34
|
version: 0.3.2
|
33
|
-
type: :
|
34
|
-
name: ruby-hmac
|
35
|
-
prerelease: false
|
35
|
+
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
name: yajl-ruby
|
39
|
+
prerelease: false
|
38
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
42
|
requirements:
|
@@ -44,11 +46,11 @@ dependencies:
|
|
44
46
|
segments:
|
45
47
|
- 0
|
46
48
|
version: "0"
|
47
|
-
type: :
|
48
|
-
name: rest-client
|
49
|
-
prerelease: false
|
49
|
+
type: :runtime
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
+
name: faraday
|
53
|
+
prerelease: false
|
52
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
55
|
none: false
|
54
56
|
requirements:
|
@@ -58,11 +60,11 @@ dependencies:
|
|
58
60
|
segments:
|
59
61
|
- 0
|
60
62
|
version: "0"
|
61
|
-
type: :
|
62
|
-
name: json
|
63
|
-
prerelease: false
|
63
|
+
type: :runtime
|
64
64
|
version_requirements: *id003
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
|
+
name: timecop
|
67
|
+
prerelease: false
|
66
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
69
|
none: false
|
68
70
|
requirements:
|
@@ -73,128 +75,72 @@ dependencies:
|
|
73
75
|
- 0
|
74
76
|
version: "0"
|
75
77
|
type: :development
|
76
|
-
name: jeweler
|
77
|
-
prerelease: false
|
78
78
|
version_requirements: *id004
|
79
79
|
- !ruby/object:Gem::Dependency
|
80
|
+
name: rspec
|
81
|
+
prerelease: false
|
80
82
|
requirement: &id005 !ruby/object:Gem::Requirement
|
81
83
|
none: false
|
82
84
|
requirements:
|
83
|
-
- - "
|
85
|
+
- - "="
|
84
86
|
- !ruby/object:Gem::Version
|
85
|
-
hash:
|
87
|
+
hash: 31
|
86
88
|
segments:
|
89
|
+
- 2
|
90
|
+
- 4
|
87
91
|
- 0
|
88
|
-
version:
|
92
|
+
version: 2.4.0
|
89
93
|
type: :development
|
90
|
-
name: rake
|
91
|
-
prerelease: false
|
92
94
|
version_requirements: *id005
|
93
95
|
- !ruby/object:Gem::Dependency
|
94
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
|
-
requirements:
|
97
|
-
- - "="
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
hash: 25
|
100
|
-
segments:
|
101
|
-
- 1
|
102
|
-
- 3
|
103
|
-
- 1
|
104
|
-
version: 1.3.1
|
105
|
-
type: :development
|
106
|
-
name: rspec
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: *id006
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - "="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
hash: 13
|
116
|
-
segments:
|
117
|
-
- 1
|
118
|
-
- 6
|
119
|
-
- 1
|
120
|
-
version: 1.6.1
|
121
|
-
type: :development
|
122
96
|
name: webmock
|
123
97
|
prerelease: false
|
124
|
-
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
127
99
|
none: false
|
128
100
|
requirements:
|
129
101
|
- - ">="
|
130
102
|
- !ruby/object:Gem::Version
|
131
|
-
hash:
|
103
|
+
hash: 3
|
132
104
|
segments:
|
133
105
|
- 0
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
type: :runtime
|
138
|
-
name: ruby-hmac
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: *id008
|
141
|
-
- !ruby/object:Gem::Dependency
|
142
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
|
-
requirements:
|
145
|
-
- - ">="
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
hash: 7
|
148
|
-
segments:
|
149
|
-
- 1
|
150
|
-
- 4
|
151
|
-
version: "1.4"
|
152
|
-
type: :runtime
|
153
|
-
name: rest-client
|
154
|
-
prerelease: false
|
155
|
-
version_requirements: *id009
|
156
|
-
- !ruby/object:Gem::Dependency
|
157
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
158
|
-
none: false
|
159
|
-
requirements:
|
160
|
-
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
hash: 11
|
163
|
-
segments:
|
164
|
-
- 1
|
165
|
-
- 2
|
166
|
-
version: "1.2"
|
167
|
-
type: :runtime
|
168
|
-
name: json
|
169
|
-
prerelease: false
|
170
|
-
version_requirements: *id010
|
106
|
+
version: "0"
|
107
|
+
type: :development
|
108
|
+
version_requirements: *id006
|
171
109
|
description: Panda Client
|
172
|
-
email:
|
110
|
+
email:
|
111
|
+
- info@pandastream.com
|
173
112
|
executables: []
|
174
113
|
|
175
114
|
extensions: []
|
176
115
|
|
177
|
-
extra_rdoc_files:
|
178
|
-
|
179
|
-
- README.md
|
116
|
+
extra_rdoc_files: []
|
117
|
+
|
180
118
|
files:
|
119
|
+
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- CHANGELOG.md
|
181
122
|
- Gemfile
|
182
123
|
- LICENSE
|
183
124
|
- README.md
|
184
125
|
- Rakefile
|
185
|
-
- VERSION
|
186
126
|
- lib/panda.rb
|
127
|
+
- lib/panda/adapters/adapter.rb
|
128
|
+
- lib/panda/adapters/faraday.rb
|
129
|
+
- lib/panda/adapters/restclient.rb
|
187
130
|
- lib/panda/api_authentication.rb
|
188
131
|
- lib/panda/base.rb
|
132
|
+
- lib/panda/config.rb
|
189
133
|
- lib/panda/connection.rb
|
190
|
-
- lib/panda/
|
134
|
+
- lib/panda/errors.rb
|
191
135
|
- lib/panda/modules/associations.rb
|
192
136
|
- lib/panda/modules/builders.rb
|
193
137
|
- lib/panda/modules/cloud_connection.rb
|
138
|
+
- lib/panda/modules/destroyers.rb
|
194
139
|
- lib/panda/modules/finders.rb
|
195
140
|
- lib/panda/modules/router.rb
|
196
|
-
- lib/panda/modules/short_status.rb
|
197
141
|
- lib/panda/modules/updatable.rb
|
142
|
+
- lib/panda/modules/video_state.rb
|
143
|
+
- lib/panda/modules/viewable.rb
|
198
144
|
- lib/panda/panda.rb
|
199
145
|
- lib/panda/proxies/encoding_scope.rb
|
200
146
|
- lib/panda/proxies/profile_scope.rb
|
@@ -206,13 +152,13 @@ files:
|
|
206
152
|
- lib/panda/resources/profile.rb
|
207
153
|
- lib/panda/resources/resource.rb
|
208
154
|
- lib/panda/resources/video.rb
|
155
|
+
- lib/panda/version.rb
|
209
156
|
- panda.gemspec
|
210
157
|
- spec/cloud_spec.rb
|
211
158
|
- spec/encoding_spec.rb
|
212
159
|
- spec/heroku_spec.rb
|
213
160
|
- spec/panda_spec.rb
|
214
161
|
- spec/profile_spec.rb
|
215
|
-
- spec/spec.opts
|
216
162
|
- spec/spec_helper.rb
|
217
163
|
- spec/video_spec.rb
|
218
164
|
has_rdoc: true
|
@@ -244,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
190
|
version: "0"
|
245
191
|
requirements: []
|
246
192
|
|
247
|
-
rubyforge_project:
|
193
|
+
rubyforge_project: panda
|
248
194
|
rubygems_version: 1.3.7
|
249
195
|
signing_key:
|
250
196
|
specification_version: 3
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.3.0
|
data/lib/panda/error.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module Panda
|
2
|
-
class Error
|
3
|
-
attr_reader :message
|
4
|
-
attr_reader :error_class
|
5
|
-
attr_reader :original_hash
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
@original_hash = options
|
9
|
-
@message = options['message']
|
10
|
-
@error_class = options['error']
|
11
|
-
end
|
12
|
-
|
13
|
-
def raise!
|
14
|
-
raise(self.to_s)
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_s
|
18
|
-
"#{@error_class}: #{@message}"
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
class ServiceNotAvailable < StandardError
|
24
|
-
def initialize
|
25
|
-
super("ServiceNotAvailable")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|