openvidu-ruby-client 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abfe96ec03f6026b4e03bc6384eb49b224cb9209
4
- data.tar.gz: 8c54571d0f5357185243a23d78c08fe624328de1
3
+ metadata.gz: 59a8122f21134fc2603ab6a8ee13db1688c30e8c
4
+ data.tar.gz: 822010be06300ead388a01be303fdd8a54a7fdb1
5
5
  SHA512:
6
- metadata.gz: 9ecb3e9795439647c987b4d285af22382f561ee70cd436ab67ed04328a7d4806141da320ead15742e4faefaaee6566d073fbd7bbb2485122c8178514738e1474
7
- data.tar.gz: 52b867b99c926d019dd0e20dbb18a78347ad211337c2c1aca60fd6ebca929d2d90b18ffcf3667f88227f271f7636545713656b302b11f6e9eb3bed4eaf4eb03f
6
+ metadata.gz: 5526e8ef1d05d2942df8bea05184452041502440b230652d36955fdc88519d19590df1abe5bd1b1aca557b5c0c22151902a4e0feaa2e7d0df08c94eb539cfe33
7
+ data.tar.gz: 1057d5c72a526ada260bbd5327641e6ee8198924ba04e301c9ec15a17f00f334ba4d17ac79cacef9a9c4a11dfbcfaf81aebaf17c3c9cb8afacf8583b8887e421
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /tmp/
11
11
  /vendor/
12
12
  .DS_Store
13
+ \.idea
@@ -3,11 +3,16 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm: 2.4.5
6
+ dist: bionic
6
7
 
7
8
  services:
8
9
  - docker
9
10
 
11
+ env:
12
+ OPENVIDU_VERIFY_PEER: false
13
+
10
14
  before_install:
11
15
  - gem install bundler -v 1.17.3
12
16
  - docker pull openvidu/openvidu-server-kms
13
- - docker run -p 4443:4443 -d --rm -e openvidu.secret=MY_SECRET openvidu/openvidu-server-kms
17
+ - docker run -p 4443:4443 -d --rm -e openvidu.secret=MY_SECRET -e openvidu.recording.path=/recordings -e openvidu.recording=true -v /var/run/docker.sock:/var/run/docker.sock openvidu/openvidu-server-kms
18
+ - while [[ "$(curl -k -uOPENVIDUAPP:MY_SECRET -s -o /dev/null -w ''%{http_code}'' https://localhost:4443)" != "200" ]]; do echo "Waiting for Openvidu..."; sleep 5; done
@@ -7,6 +7,10 @@ module OpenVidu
7
7
  GENERATED_PARAMS = %w[].freeze
8
8
  ALL_PARAMS = (ASSIGNABLE_PARAMS + GENERATED_PARAMS).freeze
9
9
 
10
+ def self.content_key
11
+ 'content'
12
+ end
13
+
10
14
  def initialize(params = {})
11
15
  self.class::ALL_PARAMS.each do |param|
12
16
  instance_variable_set("@#{param}", params[param.to_sym])
@@ -1,5 +1,6 @@
1
1
  require 'open_vidu/requestor'
2
2
  require 'open_vidu/responder'
3
+ require 'open_vidu/exceptions'
3
4
 
4
5
  module OpenVidu
5
6
  # Command
@@ -15,14 +16,14 @@ module OpenVidu
15
16
 
16
17
  def execute
17
18
  response = OpenVidu::Requestor.new(method, endpoint, params).execute
18
- OpenVidu::Responder.new(object, response).execute if valid?(response)
19
+ raise OpenVidu::ResponseError.new(response) unless valid?(response)
20
+ OpenVidu::Responder.new(object, response.parsed_response).execute
19
21
  end
20
22
 
21
23
  private
22
24
 
23
- # TODO: Implement.
24
25
  def valid?(response)
25
- true
26
+ response.success?
26
27
  end
27
28
  end
28
29
  end
@@ -0,0 +1,9 @@
1
+ module OpenVidu
2
+ class ResponseError < StandardError
3
+ attr_reader :response
4
+ def initialize(response)
5
+ @response = response
6
+ super("OpenVidu Response error code: #{response.code}")
7
+ end
8
+ end
9
+ end
@@ -10,6 +10,10 @@ module OpenVidu
10
10
  ].freeze
11
11
  ALL_PARAMS = (ASSIGNABLE_PARAMS + GENERATED_PARAMS).freeze
12
12
 
13
+ def self.content_key
14
+ 'items'
15
+ end
16
+
13
17
  def self.all
14
18
  OpenVidu::Command.new(
15
19
  :recording, :get, 'api/recordings'
@@ -17,7 +17,7 @@ module OpenVidu
17
17
  end
18
18
 
19
19
  def execute
20
- HTTParty.send(method, url, options)&.parsed_response
20
+ HTTParty.send(method, url, options)
21
21
  end
22
22
 
23
23
  private
@@ -15,11 +15,19 @@ module OpenVidu
15
15
  return klass.new(mapped_params(response)) if complete_record?
16
16
  return klass.find(response['id']) if record_lookup?
17
17
 
18
- response['content'].map { |hash| klass.new(mapped_params(hash)) }
18
+ response[content_key].map { |hash| klass.new(mapped_params(hash)) }
19
19
  end
20
20
 
21
21
  private
22
22
 
23
+ def klass
24
+ Object.const_get(klass_name)
25
+ end
26
+
27
+ def content_key
28
+ klass.content_key
29
+ end
30
+
23
31
  def klass_name
24
32
  "OpenVidu::#{object.to_s.split('_').map(&:capitalize).join('')}"
25
33
  end
@@ -24,6 +24,18 @@ module OpenVidu
24
24
  ).execute
25
25
  end
26
26
 
27
+ def self.exists?(id)
28
+ begin
29
+ OpenVidu::Command.new(
30
+ :session, :get, "api/sessions/#{id}"
31
+ ).execute
32
+ true
33
+ rescue OpenVidu::ResponseError => e
34
+ raise e unless e.response.code == 404
35
+ false
36
+ end
37
+ end
38
+
27
39
  def create
28
40
  OpenVidu::Command.new(
29
41
  :session, :post, 'api/sessions', create_params
@@ -1,3 +1,3 @@
1
1
  module OpenVidu
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'minitest', '~> 5.0'
37
37
  spec.add_development_dependency 'rake', '~> 10.0'
38
38
  spec.add_development_dependency 'test-unit', '~> 3.3', '>= 3.3.4'
39
+ spec.add_development_dependency 'openssl', '>= 2.1.2' # Fix for Travis CI
39
40
 
40
41
  spec.add_development_dependency 'dotenv', '~> 2.7', '>= 2.7.5'
41
42
  spec.add_runtime_dependency 'httparty', '>= 0.13'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvidu-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Saxon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-15 00:00:00.000000000 Z
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -78,6 +78,20 @@ dependencies:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: 3.3.4
81
+ - !ruby/object:Gem::Dependency
82
+ name: openssl
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.1.2
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.1.2
81
95
  - !ruby/object:Gem::Dependency
82
96
  name: dotenv
83
97
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +147,7 @@ files:
133
147
  - lib/open_vidu/base.rb
134
148
  - lib/open_vidu/command.rb
135
149
  - lib/open_vidu/config.rb
150
+ - lib/open_vidu/exceptions.rb
136
151
  - lib/open_vidu/recording.rb
137
152
  - lib/open_vidu/requestor.rb
138
153
  - lib/open_vidu/responder.rb