boxcar_client 0.0.3 → 0.0.4
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/boxcar_client/agent.rb +11 -10
- data/lib/boxcar_client/configuration.rb +4 -0
- data/lib/boxcar_client/notifier.rb +5 -1
- data/lib/boxcar_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a901ab178db24465ed58eb8b56f6d6604ae8d996
|
4
|
+
data.tar.gz: 8e2cc03d39c497a0a4082021797eb91242b3b107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18ed0951236b68d62175a8bb615115b59298bb44412c3ecc5584b16cf7870eb6645effa7fac0e3e97b82f9a575086bb8eb48caffcafed5680fa58bcb0171c1a
|
7
|
+
data.tar.gz: c13c2c94bf9cdb9b4486c1338793572e06c90bfc80ea2210d1d18b8c734de5efa7c9f8925a8dfe162207f9d364b4ec668ac20df41300e39d087c286616880d38
|
data/lib/boxcar_client/agent.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
module BoxcarClient
|
2
2
|
class Agent
|
3
|
-
def initialize(
|
4
|
-
@
|
5
|
-
@data
|
3
|
+
def initialize(url, data)
|
4
|
+
@url = url
|
5
|
+
@data = data
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
uri = URI(@
|
8
|
+
def post
|
9
|
+
uri = URI(@url)
|
10
10
|
request = Net::HTTP::Post.new(uri.to_s)
|
11
11
|
request.set_form_data(@data)
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
begin
|
14
|
+
response = Net::HTTP.start(uri.hostname, uri.port).request(request)
|
15
|
+
response_handler response
|
16
|
+
rescue
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
|
-
|
19
|
-
|
20
21
|
def response_handler(response)
|
21
22
|
case response
|
22
23
|
when Net::HTTPSuccess
|
23
|
-
|
24
|
+
"OK"
|
24
25
|
else
|
25
26
|
response.value
|
26
27
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module BoxcarClient
|
2
2
|
class Notifier
|
3
3
|
def self.push(user_data)
|
4
|
-
Agent.new(BoxcarClient.configuration.push_url, push_data(user_data)).
|
4
|
+
Agent.new(BoxcarClient.configuration.push_url, push_data(user_data)).post
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.subscribe(email)
|
8
|
+
Agent.new(BoxcarClient.configuration.subscribe_url, {'email' => email}).post
|
5
9
|
end
|
6
10
|
|
7
11
|
def self.push_data(user_data)
|