phoenix_rails 0.0.1 → 0.0.2
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/lib/phoenix_rails/client.rb +10 -8
- data/lib/phoenix_rails/request.rb +1 -1
- data/lib/phoenix_rails.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d9c70f2565a6a3365f859514661e95200cccf4c
|
4
|
+
data.tar.gz: e92524690a09ad5534b830bf078063d85270a91e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0fdf81dd64ce612403a7158daf5750520a9b754180f245f06d8df45ddfebfb799421a1754ad4944921b5d0894b8adfe7d48a4c54b08fc3c9c0b9fe2a3080d39
|
7
|
+
data.tar.gz: 87fa8547e75de9d80376ffeeb716c1b9b3bc925de4e7f315d4ca1ed4b540bdeda557437f16968b132acb42306ea22649ab98bd2f47723453bf3803ea566fdabe
|
data/lib/phoenix_rails/client.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
|
1
|
+
require 'signature'
|
2
2
|
|
3
3
|
module PhoenixRails
|
4
4
|
class Client
|
5
|
-
attr_accessor :scheme, :host, :port, :
|
5
|
+
attr_accessor :scheme, :host, :port, :key, :secret
|
6
6
|
attr_writer :connect_timeout, :send_timeout, :receive_timeout, :keep_alive_timeout
|
7
7
|
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
options = {
|
11
11
|
:scheme => 'http',
|
12
|
-
:host => 'api.phoenixapp.com',
|
13
12
|
:port => 80,
|
14
13
|
}.merge(options)
|
15
|
-
@scheme, @host, @port, @
|
16
|
-
:scheme, :host, :port, :
|
14
|
+
@scheme, @host, @port, @key, @secret = options.values_at(
|
15
|
+
:scheme, :host, :port, :key, :secret
|
17
16
|
)
|
18
17
|
|
19
18
|
# Default timeouts
|
@@ -26,7 +25,6 @@ module PhoenixRails
|
|
26
25
|
def url=(url)
|
27
26
|
uri = URI.parse(url)
|
28
27
|
@scheme = uri.scheme
|
29
|
-
@app_id = uri.path.split('/').last
|
30
28
|
@key = uri.user
|
31
29
|
@secret = uri.password
|
32
30
|
@host = uri.host
|
@@ -62,7 +60,7 @@ module PhoenixRails
|
|
62
60
|
end
|
63
61
|
|
64
62
|
def channel(channel_name)
|
65
|
-
raise ConfigurationError, 'Missing client configuration: please check that key, secret
|
63
|
+
raise ConfigurationError, 'Missing client configuration: please check that key, secret are configured.' unless configured?
|
66
64
|
Channel.new(url, channel_name, self)
|
67
65
|
end
|
68
66
|
|
@@ -76,6 +74,10 @@ module PhoenixRails
|
|
76
74
|
post('/events', trigger_params(channels, event_name, data, params))
|
77
75
|
end
|
78
76
|
|
77
|
+
def authentication_token
|
78
|
+
Signature::Token.new(@key, @secret)
|
79
|
+
end
|
80
|
+
|
79
81
|
# @private Construct a net/http http client
|
80
82
|
def http_client
|
81
83
|
@client ||= begin
|
@@ -116,7 +118,7 @@ module PhoenixRails
|
|
116
118
|
end
|
117
119
|
|
118
120
|
def configured?
|
119
|
-
host && scheme && key && secret
|
121
|
+
host && scheme && key && secret
|
120
122
|
end
|
121
123
|
|
122
124
|
end
|
data/lib/phoenix_rails.rb
CHANGED
@@ -7,8 +7,8 @@ class PhoenixRails
|
|
7
7
|
class << self
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
def_delegators :default_client, :scheme, :host, :port, :
|
11
|
-
def_delegators :default_client, :scheme=, :host=, :port=, :
|
10
|
+
def_delegators :default_client, :scheme, :host, :port, :key, :secret
|
11
|
+
def_delegators :default_client, :scheme=, :host=, :port=, :key=, :secret=
|
12
12
|
|
13
13
|
def_delegators :default_client, :authentication_token, :url
|
14
14
|
def_delegators :default_client, :encrypted=, :url=
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phoenix_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nguyen Le
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- lib/phoenix_rails/client.rb
|
50
50
|
- lib/phoenix_rails/request.rb
|
51
51
|
- lib/phoenix_rails/resource.rb
|
52
|
-
homepage:
|
52
|
+
homepage: https://github.com/nathanle89/phoenix_rails
|
53
53
|
licenses:
|
54
54
|
- MIT
|
55
55
|
metadata: {}
|