cine_io 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/cine_io/project_handler.rb +17 -0
- data/lib/cine_io/projects_handler.rb +2 -12
- data/lib/cine_io/resource_handler.rb +13 -0
- data/lib/cine_io/version.rb +1 -1
- data/lib/cine_io.rb +5 -1
- data/spec/cine_io/project_handler_spec.rb +55 -0
- data/spec/cine_io/projects_handler_spec.rb +10 -39
- data/spec/cine_io_spec.rb +10 -4
- data/spec/fixtures/vcr_cassettes/get_projects.yml +41 -0
- data/spec/fixtures/vcr_cassettes/get_projects_error.yml +41 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231e4167dc60fc4cea4fd71b4cd126424419e220
|
4
|
+
data.tar.gz: a962fc0f49084355ab737f9d740a57885cb04359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774f250879d95531efe1eebde790139d383fa0bb15de08957738dcb2cc2f55459b388b7d22ef8a4a0a8e6b36aa8d56bb2d67c79e407fc9f80a05367a03b2821f
|
7
|
+
data.tar.gz: db82f71539f27ebbff3481f4902e0246027f408845f6293a4b5ff48676ff438df41958616d6e423d6b2d4ce2e247edd89a52b46b02cfd3c5a9cfd56552a9f39c
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/cine-io/cineio-ruby)
|
4
4
|
|
5
|
-
The [ruby gem](https://rubygems.org/gems/cine_io) for [cine.io](cine.io).
|
5
|
+
The [ruby gem](https://rubygems.org/gems/cine_io) for [cine.io](https://www.cine.io).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
25
25
|
```ruby
|
26
26
|
require('cine_io')
|
27
27
|
client = CineIo::Client.new(secretKey: 'YOUR_SECRET_KEY')
|
28
|
+
client = CineIo::Client.new(secretKey: 'YOUR_SECRET_KEY', masterKey: 'YOUR_MASTER_KEY')
|
28
29
|
```
|
29
30
|
|
30
31
|
### Methods
|
@@ -33,6 +34,14 @@ client = CineIo::Client.new(secretKey: 'YOUR_SECRET_KEY')
|
|
33
34
|
|
34
35
|
To get data about your project:
|
35
36
|
|
37
|
+
```ruby
|
38
|
+
project = client.projects.index
|
39
|
+
# => [CineIo::Project, …]
|
40
|
+
```
|
41
|
+
#### Project
|
42
|
+
|
43
|
+
To get data about your project:
|
44
|
+
|
36
45
|
```ruby
|
37
46
|
project = client.project.get
|
38
47
|
# => CineIo::Project
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CineIo::ProjectHandler < CineIo::ResourceHandler
|
2
|
+
|
3
|
+
def get
|
4
|
+
CineIo::Project.new get_resource("/project")
|
5
|
+
end
|
6
|
+
|
7
|
+
def delete
|
8
|
+
delete_resource("/project").fetch('deletedAt')
|
9
|
+
end
|
10
|
+
|
11
|
+
# params:
|
12
|
+
# name: some project name
|
13
|
+
def update(params)
|
14
|
+
CineIo::Project.new update_resource("/project", params)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -1,17 +1,7 @@
|
|
1
1
|
class CineIo::ProjectsHandler < CineIo::ResourceHandler
|
2
2
|
|
3
|
-
def
|
4
|
-
CineIo::Project.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def delete
|
8
|
-
delete_resource("/project").fetch('deletedAt')
|
9
|
-
end
|
10
|
-
|
11
|
-
# params:
|
12
|
-
# name: some project name
|
13
|
-
def update(params)
|
14
|
-
CineIo::Project.new update_resource("/project", params)
|
3
|
+
def index
|
4
|
+
get_resource_with_master_key("/projects").map(&CineIo::Project.method(:new))
|
15
5
|
end
|
16
6
|
|
17
7
|
end
|
@@ -21,6 +21,19 @@ class CineIo::ResourceHandler
|
|
21
21
|
JSON.parse(response.body)
|
22
22
|
end
|
23
23
|
|
24
|
+
def get_resource_with_master_key(path, params={})
|
25
|
+
uri = URI.parse("#{CineIo::BASE_URL}#{path}")
|
26
|
+
uri.query = URI.encode_www_form({:masterKey => @client.config.fetch(:masterKey)}.merge(params))
|
27
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
28
|
+
http.use_ssl = (uri.scheme == "https")
|
29
|
+
|
30
|
+
request = Net::HTTP::Get.new(uri.request_uri, {"User-Agent" => USER_AGENT})
|
31
|
+
response = http.request(request)
|
32
|
+
|
33
|
+
raise CineIo::ApiError.new(response.body) unless response.is_a?(Net::HTTPSuccess)
|
34
|
+
JSON.parse(response.body)
|
35
|
+
end
|
36
|
+
|
24
37
|
def post_resource(path, params={})
|
25
38
|
uri = URI.parse("#{CineIo::BASE_URL}#{path}")
|
26
39
|
http = Net::HTTP.new(uri.host, uri.port)
|
data/lib/cine_io/version.rb
CHANGED
data/lib/cine_io.rb
CHANGED
@@ -16,10 +16,14 @@ module CineIo
|
|
16
16
|
@config = config
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def projects
|
20
20
|
@project ||= CineIo::ProjectsHandler.new(self)
|
21
21
|
end
|
22
22
|
|
23
|
+
def project
|
24
|
+
@project ||= CineIo::ProjectHandler.new(self)
|
25
|
+
end
|
26
|
+
|
23
27
|
def streams
|
24
28
|
@streams ||= CineIo::StreamsHandler.new(self)
|
25
29
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CineIo::ProjectHandler do
|
4
|
+
|
5
|
+
let(:client) { CineIo::Client.new(:secretKey => "MY SECRET", :publicKey => "MY PUBLIC") }
|
6
|
+
|
7
|
+
subject { described_class.new(client) }
|
8
|
+
|
9
|
+
describe '#get' do
|
10
|
+
it "returns a project" do
|
11
|
+
VCR.use_cassette('get_project') do
|
12
|
+
project = subject.get
|
13
|
+
expect(project).to be_a(CineIo::Project)
|
14
|
+
expect(project.name).to eq("THE PROJECT")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can throw an error on api exception' do
|
19
|
+
VCR.use_cassette('get_project_error') do
|
20
|
+
expect {subject.get}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#delete' do
|
26
|
+
it "returns a date" do
|
27
|
+
VCR.use_cassette('delete_project') do
|
28
|
+
deleted_date = subject.delete
|
29
|
+
expect(deleted_date).not_to be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can throw an error on api exception' do
|
34
|
+
VCR.use_cassette('delete_project_error') do
|
35
|
+
expect {subject.delete}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#update' do
|
41
|
+
it "updates the project" do
|
42
|
+
VCR.use_cassette('update_project') do
|
43
|
+
new_project_details = subject.update(name: 'new project name')
|
44
|
+
expect(new_project_details.name).to eq("new project name")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'can throw an error on api exception' do
|
49
|
+
VCR.use_cassette('update_project_error') do
|
50
|
+
expect {subject.update(name: '')}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -2,52 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CineIo::ProjectsHandler do
|
4
4
|
|
5
|
-
let(:client) { CineIo::Client.new(:secretKey => "MY SECRET", :
|
5
|
+
let(:client) { CineIo::Client.new(:secretKey => "MY SECRET", :masterKey => "MY MASTER KEY") }
|
6
6
|
|
7
7
|
subject { described_class.new(client) }
|
8
8
|
|
9
|
-
describe '#
|
10
|
-
it "returns
|
11
|
-
VCR.use_cassette('
|
12
|
-
|
13
|
-
expect(
|
14
|
-
expect(
|
9
|
+
describe '#index' do
|
10
|
+
it "returns the projects" do
|
11
|
+
VCR.use_cassette('get_projects') do
|
12
|
+
projects = subject.index
|
13
|
+
expect(projects).to be_an(Array)
|
14
|
+
expect(projects[0]).to be_a(CineIo::Project)
|
15
|
+
expect(projects[0].name).to eq("THE PROJECT")
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
it 'can throw an error on api exception' do
|
19
|
-
VCR.use_cassette('
|
20
|
-
expect {subject.
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#delete' do
|
26
|
-
it "returns a date" do
|
27
|
-
VCR.use_cassette('delete_project') do
|
28
|
-
deleted_date = subject.delete
|
29
|
-
expect(deleted_date).not_to be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'can throw an error on api exception' do
|
34
|
-
VCR.use_cassette('delete_project_error') do
|
35
|
-
expect {subject.delete}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#update' do
|
41
|
-
it "updates the project" do
|
42
|
-
VCR.use_cassette('update_project') do
|
43
|
-
new_project_details = subject.update(name: 'new project name')
|
44
|
-
expect(new_project_details.name).to eq("new project name")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'can throw an error on api exception' do
|
49
|
-
VCR.use_cassette('update_project_error') do
|
50
|
-
expect {subject.update(name: '')}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
20
|
+
VCR.use_cassette('get_projects_error') do
|
21
|
+
expect {subject.index}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
51
22
|
end
|
52
23
|
end
|
53
24
|
end
|
data/spec/cine_io_spec.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CineIo do
|
4
|
-
let(:client) { CineIo::Client.new(:publicKey => 'My public key', :secretKey => 'My secret key') }
|
4
|
+
let(:client) { CineIo::Client.new(:publicKey => 'My public key', :secretKey => 'My secret key', :something => 'else') }
|
5
5
|
subject { client }
|
6
6
|
|
7
|
-
it 'takes a
|
8
|
-
expect(subject.config).to eq(:publicKey => 'My public key', :secretKey => 'My secret key')
|
7
|
+
it 'takes a config' do
|
8
|
+
expect(subject.config).to eq(:publicKey => 'My public key', :secretKey => 'My secret key', :something => 'else')
|
9
9
|
end
|
10
|
+
|
10
11
|
describe '#projects' do
|
11
|
-
subject {client.
|
12
|
+
subject {client.projects}
|
12
13
|
it { should be_a(CineIo::ProjectsHandler) }
|
13
14
|
end
|
14
15
|
|
16
|
+
describe '#project' do
|
17
|
+
subject {client.project}
|
18
|
+
it { should be_a(CineIo::ProjectHandler) }
|
19
|
+
end
|
20
|
+
|
15
21
|
describe '#streams' do
|
16
22
|
subject {client.streams}
|
17
23
|
it { should be_a(CineIo::StreamsHandler) }
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://www.cine.io/api/1/-/projects?masterKey=MY%20MASTER%20KEY
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json; charset=utf-8
|
21
|
+
Date:
|
22
|
+
- Sun, 01 Jun 2014 07:27:53 GMT
|
23
|
+
Etag:
|
24
|
+
- ! '"-585713471"'
|
25
|
+
Set-Cookie:
|
26
|
+
- connect.sid=s%3ACxr5WVK6KEkFqdcFxxYTSTJ7.%2F7TTnVJK4mHsI%2FAIiKiebpUq5y5d5Fz8MmK7Azhad%2Bg;
|
27
|
+
Path=/; HttpOnly
|
28
|
+
Vary:
|
29
|
+
- Accept-Encoding
|
30
|
+
X-Powered-By:
|
31
|
+
- Express
|
32
|
+
Content-Length:
|
33
|
+
- '217'
|
34
|
+
Connection:
|
35
|
+
- keep-alive
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '[{"id":"THE ID","publicKey":"MY PUBLIC","secretKey":"MY SECRET","name":"THE PROJECT", "streamsCount":0,"updatedAt":"2014-05-29T01:21:20.186Z"}]'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 01 Jun 2014 07:27:53 GMT
|
41
|
+
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://www.cine.io/api/1/-/projects?masterKey=MY%20MASTER%20KEY
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 400
|
17
|
+
message: Bad Request
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- text/html; charset=utf-8
|
21
|
+
Date:
|
22
|
+
- Sun, 01 Jun 2014 22:34:05 GMT
|
23
|
+
Etag:
|
24
|
+
- ! '"-585839348"'
|
25
|
+
Set-Cookie:
|
26
|
+
- connect.sid=s%3A7R3MsudkzJuWbtPcQThWVWFs.qH%2F%2B2VaecxTCmWWzK6pR1stDOws%2FLltJEY0GpaYzkLI;
|
27
|
+
Path=/; HttpOnly
|
28
|
+
Vary:
|
29
|
+
- Accept-Encoding
|
30
|
+
X-Powered-By:
|
31
|
+
- Express
|
32
|
+
Content-Length:
|
33
|
+
- '29'
|
34
|
+
Connection:
|
35
|
+
- keep-alive
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: An unknown error has occured.
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 01 Jun 2014 22:34:05 GMT
|
41
|
+
recorded_with: VCR 2.3.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cine_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cine.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- cine_io.gemspec
|
98
98
|
- lib/cine_io.rb
|
99
99
|
- lib/cine_io/project.rb
|
100
|
+
- lib/cine_io/project_handler.rb
|
100
101
|
- lib/cine_io/projects_handler.rb
|
101
102
|
- lib/cine_io/resource_handler.rb
|
102
103
|
- lib/cine_io/stream.rb
|
@@ -104,6 +105,7 @@ files:
|
|
104
105
|
- lib/cine_io/stream_recordings_handler.rb
|
105
106
|
- lib/cine_io/streams_handler.rb
|
106
107
|
- lib/cine_io/version.rb
|
108
|
+
- spec/cine_io/project_handler_spec.rb
|
107
109
|
- spec/cine_io/project_spec.rb
|
108
110
|
- spec/cine_io/projects_handler_spec.rb
|
109
111
|
- spec/cine_io/stream_recording_spec.rb
|
@@ -125,6 +127,8 @@ files:
|
|
125
127
|
- spec/fixtures/vcr_cassettes/get_fmle_profile_error.yml
|
126
128
|
- spec/fixtures/vcr_cassettes/get_project.yml
|
127
129
|
- spec/fixtures/vcr_cassettes/get_project_error.yml
|
130
|
+
- spec/fixtures/vcr_cassettes/get_projects.yml
|
131
|
+
- spec/fixtures/vcr_cassettes/get_projects_error.yml
|
128
132
|
- spec/fixtures/vcr_cassettes/get_stream.yml
|
129
133
|
- spec/fixtures/vcr_cassettes/get_stream_error.yml
|
130
134
|
- spec/fixtures/vcr_cassettes/get_stream_recordings.yml
|
@@ -161,6 +165,7 @@ signing_key:
|
|
161
165
|
specification_version: 4
|
162
166
|
summary: The official cine.io ruby gem
|
163
167
|
test_files:
|
168
|
+
- spec/cine_io/project_handler_spec.rb
|
164
169
|
- spec/cine_io/project_spec.rb
|
165
170
|
- spec/cine_io/projects_handler_spec.rb
|
166
171
|
- spec/cine_io/stream_recording_spec.rb
|
@@ -182,6 +187,8 @@ test_files:
|
|
182
187
|
- spec/fixtures/vcr_cassettes/get_fmle_profile_error.yml
|
183
188
|
- spec/fixtures/vcr_cassettes/get_project.yml
|
184
189
|
- spec/fixtures/vcr_cassettes/get_project_error.yml
|
190
|
+
- spec/fixtures/vcr_cassettes/get_projects.yml
|
191
|
+
- spec/fixtures/vcr_cassettes/get_projects_error.yml
|
185
192
|
- spec/fixtures/vcr_cassettes/get_stream.yml
|
186
193
|
- spec/fixtures/vcr_cassettes/get_stream_error.yml
|
187
194
|
- spec/fixtures/vcr_cassettes/get_stream_recordings.yml
|