cine_io 0.0.4 → 0.0.5
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/README.md +33 -1
- data/lib/cine_io/projects_handler.rb +6 -0
- data/lib/cine_io/resource_handler.rb +12 -0
- data/lib/cine_io/streams_handler.rb +10 -2
- data/lib/cine_io/version.rb +1 -1
- data/spec/cine_io/projects_handler_spec.rb +15 -0
- data/spec/cine_io/streams_handler_spec.rb +29 -1
- data/spec/fixtures/vcr_cassettes/create_stream.yml +1 -1
- data/spec/fixtures/vcr_cassettes/create_stream_with_name.yml +41 -0
- data/spec/fixtures/vcr_cassettes/delete_project.yml +1 -1
- data/spec/fixtures/vcr_cassettes/update_project.yml +42 -0
- data/spec/fixtures/vcr_cassettes/update_project_error.yml +38 -0
- data/spec/fixtures/vcr_cassettes/update_stream.yml +41 -0
- data/spec/fixtures/vcr_cassettes/update_stream_error.yml +38 -0
- metadata +12 -2
data/README.md
CHANGED
@@ -38,6 +38,20 @@ project = client.project.get
|
|
38
38
|
# => CineIo::Project
|
39
39
|
```
|
40
40
|
|
41
|
+
```ruby
|
42
|
+
# params:
|
43
|
+
# name: 'a helpful project name'
|
44
|
+
project = client.project.update(params)
|
45
|
+
# => CineIo::Project
|
46
|
+
```
|
47
|
+
|
48
|
+
To delete your project:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
deleted_date = client.project.destroy
|
52
|
+
# => Date String
|
53
|
+
```
|
54
|
+
|
41
55
|
#### Streams
|
42
56
|
|
43
57
|
To get all your streams:
|
@@ -54,10 +68,28 @@ stream = client.streams.get('STREAM_ID')
|
|
54
68
|
# => CineIo::Stream
|
55
69
|
```
|
56
70
|
|
71
|
+
To update a specific stream:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
# params:
|
75
|
+
# name: 'a helpful stream name'
|
76
|
+
stream = client.streams.update('STREAM_ID', params)
|
77
|
+
# => CineIo::Stream
|
78
|
+
```
|
79
|
+
|
80
|
+
To delete a specific stream:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
deleted_date = client.streams.destroy('STREAM_ID')
|
84
|
+
# => Date String
|
85
|
+
```
|
86
|
+
|
57
87
|
To create a new stream:
|
58
88
|
|
59
89
|
```ruby
|
60
|
-
|
90
|
+
# params (optional):
|
91
|
+
# name (optional): 'a helpful stream name'
|
92
|
+
stream = client.streams.create(params)
|
61
93
|
# => CineIo::Stream
|
62
94
|
```
|
63
95
|
|
@@ -30,6 +30,18 @@ class CineIo::ResourceHandler
|
|
30
30
|
JSON.parse(response.body)
|
31
31
|
end
|
32
32
|
|
33
|
+
def update_resource(path, params={})
|
34
|
+
uri = URI.parse("#{CineIo::BASE_URL}#{path}")
|
35
|
+
request = Net::HTTP::Put.new(uri.request_uri)
|
36
|
+
request.set_form_data({:secretKey => @client.config.fetch(:secretKey)}.merge(params))
|
37
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
38
|
+
http.use_ssl = (uri.scheme == "https")
|
39
|
+
response = http.request(request)
|
40
|
+
|
41
|
+
raise CineIo::ApiError.new(response.body) unless response.is_a?(Net::HTTPSuccess)
|
42
|
+
JSON.parse(response.body)
|
43
|
+
end
|
44
|
+
|
33
45
|
def delete_resource(path, params={})
|
34
46
|
uri = URI.parse("#{CineIo::BASE_URL}#{path}")
|
35
47
|
request = Net::HTTP::Delete.new(uri.request_uri)
|
@@ -12,8 +12,16 @@ class CineIo::StreamsHandler < CineIo::ResourceHandler
|
|
12
12
|
get_resource("/stream", id: stream_id, fmleProfile: true).fetch('content')
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# params
|
16
|
+
# name: 'some stream name'
|
17
|
+
def create(params={})
|
18
|
+
CineIo::Stream.new post_resource("/stream", params)
|
19
|
+
end
|
20
|
+
|
21
|
+
# params:
|
22
|
+
# name: some project name
|
23
|
+
def update(stream_id, params)
|
24
|
+
CineIo::Stream.new update_resource("/stream", {id: stream_id}.merge(params))
|
17
25
|
end
|
18
26
|
|
19
27
|
def delete(stream_id)
|
data/lib/cine_io/version.rb
CHANGED
@@ -37,4 +37,19 @@ describe CineIo::ProjectsHandler do
|
|
37
37
|
end
|
38
38
|
end
|
39
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
|
+
|
40
55
|
end
|
@@ -56,7 +56,7 @@ describe CineIo::StreamsHandler do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'can throw an error on api exception' do
|
59
|
-
VCR.use_cassette('get_streams_error'
|
59
|
+
VCR.use_cassette('get_streams_error') do
|
60
60
|
expect {subject.index}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
61
61
|
end
|
62
62
|
end
|
@@ -74,6 +74,18 @@ describe CineIo::StreamsHandler do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
it "can take a name parameter" do
|
78
|
+
VCR.use_cassette('create_stream_with_name') do
|
79
|
+
stream = subject.create(name: 'new stream')
|
80
|
+
expect(stream).to be_a(CineIo::Stream)
|
81
|
+
expect(stream.id).to eq("537b7f48bc03be080085a389")
|
82
|
+
expect(stream.name).to eq("new stream")
|
83
|
+
expect(stream.password).to eq("PASSWORD")
|
84
|
+
expect(stream.play.keys.sort).to eq(['hls', 'rtmp'])
|
85
|
+
expect(stream.publish.keys.sort).to eq(['stream', 'url'])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
77
89
|
it 'can throw an error on api exception' do
|
78
90
|
VCR.use_cassette('create_stream_error') do
|
79
91
|
expect {subject.create}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
@@ -96,4 +108,20 @@ describe CineIo::StreamsHandler do
|
|
96
108
|
end
|
97
109
|
end
|
98
110
|
|
111
|
+
describe '#update' do
|
112
|
+
it "updates the name" do
|
113
|
+
VCR.use_cassette('update_stream') do
|
114
|
+
stream = subject.update('53718cef450ff80200f81856', name: 'homepage stream')
|
115
|
+
expect(stream.id).to eq('53718cef450ff80200f81856')
|
116
|
+
expect(stream.name).to eq('homepage stream')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'can throw an error on api exception' do
|
121
|
+
VCR.use_cassette('update_stream_error') do
|
122
|
+
expect {subject.update('NOT_A_STREAM', name: '')}.to raise_error(CineIo::ApiError, "An unknown error has occured.")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
99
127
|
end
|
@@ -35,7 +35,7 @@ http_interactions:
|
|
35
35
|
- keep-alive
|
36
36
|
body:
|
37
37
|
encoding: US-ASCII
|
38
|
-
string: ! '{"id":"537b7f48bc03be080085a389","
|
38
|
+
string: ! '{"id":"537b7f48bc03be080085a389","streamName":"cine1","play":{"hls":"http://hls.cine.io/cines/cine1/cine1.m3u8","rtmp":"rtmp://fml.cine.io/20C45E/cines/cine1?adbe-live-event=cine1"},"publish":{"url":"rtmp://stream.lax.cine.io/20C45E/cines","stream":"cine1?PASSWORD&adbe-live-event=cine1"},"password":"PASSWORD","expiration":"2034-05-20T00:00:00.000Z","assignedAt":"2014-06-01T07:53:38.613Z"}'
|
39
39
|
http_version:
|
40
40
|
recorded_at: Sun, 01 Jun 2014 07:53:39 GMT
|
41
41
|
recorded_with: VCR 2.3.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://www.cine.io/api/1/-/stream
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: secretKey=MY SECRET&name=new+stream
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
Date:
|
24
|
+
- Wed, 11 Jun 2014 20:19:12 GMT
|
25
|
+
Set-Cookie:
|
26
|
+
- connect.sid=s%3ADUJp5xhon0mGvpFaZaANzwdB.uiRsKW0osoLy%2Bl79UXUjx2CKc4ziyokz9rqGPI%2F%2BUic;
|
27
|
+
Path=/; HttpOnly
|
28
|
+
Vary:
|
29
|
+
- Accept-Encoding
|
30
|
+
X-Powered-By:
|
31
|
+
- Express
|
32
|
+
Content-Length:
|
33
|
+
- '418'
|
34
|
+
Connection:
|
35
|
+
- keep-alive
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"id":"537b7f48bc03be080085a389","name":"new stream","play":{"hls":"http://hls.cine.io/cines/cine1/cine1.m3u8","rtmp":"rtmp://fml.cine.io/20C45E/cines/cine1?adbe-live-event=cine1"},"publish":{"url":"rtmp://stream.lax.cine.io/20C45E/cines","stream":"cine1?PASSWORD&adbe-live-event=cine1"},"password":"PASSWORD","expiration":"2034-05-20T00:00:00.000Z","assignedAt":"2014-06-01T07:53:38.613Z"}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Wed, 11 Jun 2014 20:19:12 GMT
|
41
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://www.cine.io/api/1/-/project
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: secretKey=MY+SECRET&name=new+project+name
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
Date:
|
24
|
+
- Wed, 11 Jun 2014 20:14:16 GMT
|
25
|
+
Set-Cookie:
|
26
|
+
- connect.sid=s%3AlXanIRF3rJUdSVF9WJQYiAIE.yBozlxl0BPpLdC%2FqfJoVXG2%2FW5x8SSMg%2BCNd7Wv6xIQ;
|
27
|
+
Path=/; HttpOnly
|
28
|
+
Vary:
|
29
|
+
- Accept-Encoding
|
30
|
+
X-Powered-By:
|
31
|
+
- Express
|
32
|
+
Content-Length:
|
33
|
+
- '209'
|
34
|
+
Connection:
|
35
|
+
- keep-alive
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"id":"53868bd8a3f20d0800a4eb38","publicKey":"MY PUBLIC","secretKey":"MY SECRET","name":"new
|
39
|
+
project name","streamsCount":2,"updatedAt":"2014-06-11T20:14:16.655Z"}'
|
40
|
+
http_version:
|
41
|
+
recorded_at: Wed, 11 Jun 2014 20:14:16 GMT
|
42
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://www.cine.io/api/1/-/project
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: secretKey=MY+SECRET
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 503
|
19
|
+
message: Service Unavailable
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache, no-store
|
23
|
+
Content-Type:
|
24
|
+
- text/html; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Mon, 09 Jun 2014 20:12:42 GMT
|
27
|
+
Server:
|
28
|
+
- MochiWeb/1.0 (Any of you quaids got a smint?)
|
29
|
+
Content-Length:
|
30
|
+
- '484'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: An unknown error has occured.
|
36
|
+
http_version:
|
37
|
+
recorded_at: Mon, 09 Jun 2014 20:12:42 GMT
|
38
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://www.cine.io/api/1/-/stream
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: secretKey=MY+SECRET&id=53718cef450ff80200f81856&name=homepage+stream
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
Date:
|
24
|
+
- Wed, 11 Jun 2014 20:24:37 GMT
|
25
|
+
Set-Cookie:
|
26
|
+
- connect.sid=s%3AosOebJBb66MYro0XgYG5jwd6.16FOZ8f%2FWHe2J4iDGxt7H%2BXF6qHeYmXHG7fdmu9fx70;
|
27
|
+
Path=/; HttpOnly
|
28
|
+
Vary:
|
29
|
+
- Accept-Encoding
|
30
|
+
X-Powered-By:
|
31
|
+
- Express
|
32
|
+
Content-Length:
|
33
|
+
- '97'
|
34
|
+
Connection:
|
35
|
+
- keep-alive
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"id":"53718cef450ff80200f81856","name":"homepage stream","updatedAt":"2014-06-11T20:24:37.950Z"}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Wed, 11 Jun 2014 20:24:38 GMT
|
41
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://www.cine.io/api/1/-/stream
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: secretKey=MY+SECRET&id=NOT_A_STREAM&name=''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 503
|
19
|
+
message: Service Unavailable
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache, no-store
|
23
|
+
Content-Type:
|
24
|
+
- text/html; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Mon, 09 Jun 2014 20:12:42 GMT
|
27
|
+
Server:
|
28
|
+
- MochiWeb/1.0 (Any of you quaids got a smint?)
|
29
|
+
Content-Length:
|
30
|
+
- '484'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: An unknown error has occured.
|
36
|
+
http_version:
|
37
|
+
recorded_at: Mon, 09 Jun 2014 20:12:42 GMT
|
38
|
+
recorded_with: VCR 2.9.2
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cine_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2014-06-
|
12
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- spec/cine_io_spec.rb
|
121
121
|
- spec/fixtures/vcr_cassettes/create_stream.yml
|
122
122
|
- spec/fixtures/vcr_cassettes/create_stream_error.yml
|
123
|
+
- spec/fixtures/vcr_cassettes/create_stream_with_name.yml
|
123
124
|
- spec/fixtures/vcr_cassettes/delete_project.yml
|
124
125
|
- spec/fixtures/vcr_cassettes/delete_project_error.yml
|
125
126
|
- spec/fixtures/vcr_cassettes/delete_stream.yml
|
@@ -132,6 +133,10 @@ files:
|
|
132
133
|
- spec/fixtures/vcr_cassettes/get_stream_error.yml
|
133
134
|
- spec/fixtures/vcr_cassettes/get_streams.yml
|
134
135
|
- spec/fixtures/vcr_cassettes/get_streams_error.yml
|
136
|
+
- spec/fixtures/vcr_cassettes/update_project.yml
|
137
|
+
- spec/fixtures/vcr_cassettes/update_project_error.yml
|
138
|
+
- spec/fixtures/vcr_cassettes/update_stream.yml
|
139
|
+
- spec/fixtures/vcr_cassettes/update_stream_error.yml
|
135
140
|
- spec/spec_helper.rb
|
136
141
|
homepage: https://github.com/cine-io/cineio-ruby
|
137
142
|
licenses:
|
@@ -166,6 +171,7 @@ test_files:
|
|
166
171
|
- spec/cine_io_spec.rb
|
167
172
|
- spec/fixtures/vcr_cassettes/create_stream.yml
|
168
173
|
- spec/fixtures/vcr_cassettes/create_stream_error.yml
|
174
|
+
- spec/fixtures/vcr_cassettes/create_stream_with_name.yml
|
169
175
|
- spec/fixtures/vcr_cassettes/delete_project.yml
|
170
176
|
- spec/fixtures/vcr_cassettes/delete_project_error.yml
|
171
177
|
- spec/fixtures/vcr_cassettes/delete_stream.yml
|
@@ -178,4 +184,8 @@ test_files:
|
|
178
184
|
- spec/fixtures/vcr_cassettes/get_stream_error.yml
|
179
185
|
- spec/fixtures/vcr_cassettes/get_streams.yml
|
180
186
|
- spec/fixtures/vcr_cassettes/get_streams_error.yml
|
187
|
+
- spec/fixtures/vcr_cassettes/update_project.yml
|
188
|
+
- spec/fixtures/vcr_cassettes/update_project_error.yml
|
189
|
+
- spec/fixtures/vcr_cassettes/update_stream.yml
|
190
|
+
- spec/fixtures/vcr_cassettes/update_stream_error.yml
|
181
191
|
- spec/spec_helper.rb
|