pili 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +420 -129
- data/example/example.rb +181 -0
- data/lib/pili/api.rb +87 -42
- data/lib/pili/config.rb +14 -11
- data/lib/pili/{auth.rb → credentials.rb} +11 -1
- data/lib/pili/hub.rb +29 -0
- data/lib/pili/rpc.rb +80 -0
- data/lib/pili/stream.rb +57 -51
- data/lib/pili/version.rb +1 -1
- data/lib/pili.rb +3 -2
- metadata +6 -4
- data/lib/pili/client.rb +0 -48
data/lib/pili/version.rb
CHANGED
data/lib/pili.rb
CHANGED
@@ -4,12 +4,13 @@ require 'httparty'
|
|
4
4
|
require "pili/version"
|
5
5
|
|
6
6
|
module Pili
|
7
|
-
autoload :
|
7
|
+
autoload :Credentials, 'pili/credentials'
|
8
8
|
autoload :Config, 'pili/config'
|
9
|
+
autoload :RPC, 'pili/rpc'
|
9
10
|
autoload :API, 'pili/api'
|
10
11
|
autoload :Utils, 'pili/utils'
|
11
12
|
autoload :ResponseError, 'pili/exceptions'
|
12
13
|
|
13
|
-
autoload :
|
14
|
+
autoload :Hub, 'pili/hub'
|
14
15
|
autoload :Stream, 'pili/stream'
|
15
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pili
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miclle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,12 +65,14 @@ files:
|
|
65
65
|
- LICENSE
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
|
+
- example/example.rb
|
68
69
|
- lib/pili.rb
|
69
70
|
- lib/pili/api.rb
|
70
|
-
- lib/pili/auth.rb
|
71
|
-
- lib/pili/client.rb
|
72
71
|
- lib/pili/config.rb
|
72
|
+
- lib/pili/credentials.rb
|
73
73
|
- lib/pili/exceptions.rb
|
74
|
+
- lib/pili/hub.rb
|
75
|
+
- lib/pili/rpc.rb
|
74
76
|
- lib/pili/stream.rb
|
75
77
|
- lib/pili/utils.rb
|
76
78
|
- lib/pili/version.rb
|
data/lib/pili/client.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module Pili
|
3
|
-
class Client
|
4
|
-
|
5
|
-
attr_reader :access_key, :secret_key, :hub_name
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(access_key, secret_key, hub_name)
|
9
|
-
@access_key = access_key
|
10
|
-
@secret_key = secret_key
|
11
|
-
@hub_name = hub_name
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
def create_stream(options = {})
|
16
|
-
url = Config.api_base_url + "/streams"
|
17
|
-
|
18
|
-
body = {
|
19
|
-
:hub => @hub_name,
|
20
|
-
:title => options[:title],
|
21
|
-
:publishKey => options[:publish_key],
|
22
|
-
:publishSecurity => options[:publish_security] == "static" ? "static" : "dynamic",
|
23
|
-
:clientIp => options[:client_ip]
|
24
|
-
}
|
25
|
-
|
26
|
-
body.delete_if { |k, v| v.nil? }
|
27
|
-
|
28
|
-
Stream.new self, API.post(@access_key, @secret_key, url, body)
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def get_stream(stream_id)
|
33
|
-
url = Config.api_base_url + "/streams/" + stream_id
|
34
|
-
Stream.new self, API.get(@access_key, @secret_key, url)
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def list_streams(options = {})
|
39
|
-
url = Config.api_base_url + "/streams?hub=#{@hub_name}"
|
40
|
-
|
41
|
-
url += "&marker=#{options[:marker]}" unless Utils.blank?(options[:marker])
|
42
|
-
url += "&limit=#{options[:limit]}" if options[:limit].is_a?(Fixnum)
|
43
|
-
|
44
|
-
API.get(@access_key, @secret_key, url)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|