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.
@@ -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 |c|
7
- c.access_key = "my_access_key"
8
- c.secret_key = "my_secret_key"
9
- c.api_host = "api.example.com"
10
- c.cloud_id = 'my_cloud_id'
11
- c.api_port = 85
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.message.should == "no-abc"
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 |c|
113
- c.access_key = "my_access_key"
114
- c.secret_key = "my_secret_key"
115
- c.cloud_id = 'my_cloud_id'
116
- c.region = "eu"
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 = "my_access_key"
131
- c.secret_key = "my_secret_key"
132
- c.cloud_id = 'my_cloud_id'
133
- c.region = "eu"
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: 27
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 1.3.0
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-01-10 00:00:00 +00:00
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: :development
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: :development
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: :development
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: 3
87
+ hash: 31
86
88
  segments:
89
+ - 2
90
+ - 4
87
91
  - 0
88
- version: "0"
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
- version_requirements: *id007
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: 23
103
+ hash: 3
132
104
  segments:
133
105
  - 0
134
- - 3
135
- - 2
136
- version: 0.3.2
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: info@pandastream.com
110
+ email:
111
+ - info@pandastream.com
173
112
  executables: []
174
113
 
175
114
  extensions: []
176
115
 
177
- extra_rdoc_files:
178
- - LICENSE
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/error.rb
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
@@ -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
@@ -1,13 +0,0 @@
1
- module ShortStatus
2
- def success?
3
- @attributes['status'] == 'success'
4
- end
5
-
6
- def processing?
7
- @attributes['status'] == 'processing'
8
- end
9
-
10
- def fail?
11
- @attributes['status'] == 'fail'
12
- end
13
- end