pusher-platform 0.9.0 → 0.10.0

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
  SHA256:
3
- metadata.gz: 5df1e0c1efb25d9e0a1c3cfdf36d74d93374168b6ccc8aaf6cc06e432b8c47df
4
- data.tar.gz: ab99cbc6b42252857e5719bbdc6d8667d609e4612875b4069feb7073f6eef997
3
+ metadata.gz: 9cc62681eb9e885dac40f75a5a461cacf237575c3f04933818d1172e1016866a
4
+ data.tar.gz: 8f3772d45bfece5711842230e3061b2d726b94688685ad283eb28215d0fa22df
5
5
  SHA512:
6
- metadata.gz: 0e7027e40457c731612e810097e25e984612c0960dd3675d7f13c493d95d29bf708d4b04aa169190d2f37f1da18ff46a2f1163ca6142b69c4b5821f091f2dd96
7
- data.tar.gz: d8f037b670eae0166895b81e6c901e465a77f62e49f7b6dc726e1889fe31742665b8f51a42215c9c827e61ff6492206ecccc954b1e4972204a43b2411427b644
6
+ metadata.gz: 1d297f244c8709f56adb979818e63c8b07ea70f8baddbb2e8e19fad7ae1f068ae3d45068e801a255662fd69020c67f1ccd44c5a7aa94cba2250684c12021f935
7
+ data.tar.gz: d15e3e5be0a907a210e66eb1617b45fcd7fbcf8da82bcc11894f9e61d6d909817b786a8624e625954441eb7ae5490c162b14eabab9402333abec9e1d2d90eca0
@@ -1,11 +1,12 @@
1
1
  require 'excon'
2
2
  require 'json'
3
3
  require_relative './error_response'
4
+ require_relative './error'
4
5
 
5
6
  module PusherPlatform
6
7
  class BaseClient
7
8
  def initialize(options)
8
- raise "Unspecified host" if options[:host].nil?
9
+ raise PusherPlatform::Error.new("Unspecified host") if options[:host].nil?
9
10
  port_string = options[:port] || ''
10
11
  host_string = "https://#{options[:host]}#{port_string}"
11
12
  @connection = Excon.new(host_string)
@@ -16,8 +17,8 @@ module PusherPlatform
16
17
  end
17
18
 
18
19
  def request(options)
19
- raise "Unspecified request method" if options[:method].nil?
20
- raise "Unspecified request path" if options[:path].nil?
20
+ raise PusherPlatform::Error.new("Unspecified request method") if options[:method].nil?
21
+ raise PusherPlatform::Error.new("Unspecified request path") if options[:path].nil?
21
22
 
22
23
  headers = if options[:headers]
23
24
  options[:headers].dup
@@ -45,7 +46,7 @@ module PusherPlatform
45
46
  if response.status >= 200 && response.status <= 299
46
47
  return response
47
48
  elsif response.status >= 300 && response.status <= 399
48
- raise "unsupported redirect response: #{response.status}"
49
+ raise PusherPlatform::Error.new("Unsupported redirect response: #{response.status}")
49
50
  elsif response.status >= 400 && response.status <= 599
50
51
  error = begin
51
52
  JSON.parse(response.body)
@@ -61,7 +62,7 @@ module PusherPlatform
61
62
  }
62
63
  raise ErrorResponse.new(error_res_opts)
63
64
  else
64
- raise "unsupported response code: #{response.status}"
65
+ raise PusherPlatform::Error.new("Unsupported response code: #{response.status}")
65
66
  end
66
67
  end
67
68
 
@@ -0,0 +1,4 @@
1
+ module PusherPlatform
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative './common'
2
+ require_relative './error'
2
3
 
3
4
  module PusherPlatform
4
5
  class ErrorResponse < Error
@@ -2,6 +2,7 @@ require_relative './authenticator'
2
2
  require_relative './base_client'
3
3
  require_relative './common'
4
4
  require_relative './error_response'
5
+ require_relative './error'
5
6
 
6
7
  module PusherPlatform
7
8
 
@@ -9,15 +10,16 @@ module PusherPlatform
9
10
 
10
11
  class Instance
11
12
  def initialize(options)
12
- raise "No instance locator provided" if options[:locator].nil?
13
- raise "No service name provided" if options[:service_name].nil?
14
- raise "No service version provided" if options[:service_version].nil?
13
+ raise PusherPlatform::Error.new("No instance locator provided") if options[:locator].nil?
14
+ raise PusherPlatform::Error.new("No key provided") if options[:key].nil?
15
+ raise PusherPlatform::Error.new("No service name provided") if options[:service_name].nil?
16
+ raise PusherPlatform::Error.new("No service version provided") if options[:service_version].nil?
15
17
  locator = options[:locator]
16
18
  @service_name = options[:service_name]
17
19
  @service_version = options[:service_version]
18
20
 
19
21
  key_parts = options[:key].match(/^([^:]+):(.+)$/)
20
- raise "Invalid key" if key_parts.nil?
22
+ raise PusherPlatform::Error.new("Invalid key") if key_parts.nil?
21
23
 
22
24
  @key_id = key_parts[1]
23
25
  @key_secret = key_parts[2]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher-platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pusher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2018-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -49,6 +49,7 @@ files:
49
49
  - lib/pusher-platform/authenticator.rb
50
50
  - lib/pusher-platform/base_client.rb
51
51
  - lib/pusher-platform/common.rb
52
+ - lib/pusher-platform/error.rb
52
53
  - lib/pusher-platform/error_response.rb
53
54
  - lib/pusher-platform/instance.rb
54
55
  homepage: