apphunkd 0.12.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/apphunkd.gemspec +4 -1
- data/lib/apphunkd/queue.rb +5 -5
- data/lib/apphunkd/remote.rb +11 -9
- data/lib/apphunkd/remote/result.rb +2 -3
- metadata +11 -1
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ begin
|
|
21
21
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
22
22
|
gem.add_development_dependency "yard", ">= 0"
|
23
23
|
gem.add_dependency "eventmachine", ">= 0"
|
24
|
+
gem.add_dependency "httparty", ">= 0.5.2"
|
24
25
|
gem.add_dependency "sinatra", ">= 0.9.4"
|
25
26
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
26
27
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
data/apphunkd.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{apphunkd}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.13.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andreas Wolff"]
|
@@ -248,17 +248,20 @@ Gem::Specification.new do |s|
|
|
248
248
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
249
249
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
250
250
|
s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
|
251
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
|
251
252
|
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
|
252
253
|
else
|
253
254
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
254
255
|
s.add_dependency(%q<yard>, [">= 0"])
|
255
256
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
257
|
+
s.add_dependency(%q<httparty>, [">= 0.5.2"])
|
256
258
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
257
259
|
end
|
258
260
|
else
|
259
261
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
260
262
|
s.add_dependency(%q<yard>, [">= 0"])
|
261
263
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
264
|
+
s.add_dependency(%q<httparty>, [">= 0.5.2"])
|
262
265
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
263
266
|
end
|
264
267
|
end
|
data/lib/apphunkd/queue.rb
CHANGED
@@ -38,9 +38,9 @@ module Apphunkd
|
|
38
38
|
result = push_item_to_remote_service(item)
|
39
39
|
if result.status == :ok
|
40
40
|
case result.response.code
|
41
|
-
when
|
41
|
+
when 201
|
42
42
|
debug "Message successfully stored."
|
43
|
-
when
|
43
|
+
when 400, 403
|
44
44
|
log_error "Remote Service refused to store item: #{result.response.code} / #{result.response.body}. Dropped."
|
45
45
|
else
|
46
46
|
put_item_to_stack(item)
|
@@ -48,7 +48,7 @@ module Apphunkd
|
|
48
48
|
end
|
49
49
|
else
|
50
50
|
put_item_to_stack(item)
|
51
|
-
log_error "Could not push to Remote Service: Connection Error. Put item back in queue."
|
51
|
+
log_error "Could not push to Remote Service: Connection Error. Put item back in queue: #{result.status} / #{result.response}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -78,8 +78,8 @@ module Apphunkd
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def push_item_to_remote_service(item)
|
81
|
-
url = generate_api_messages_url(item
|
82
|
-
result = Apphunkd::Remote.
|
81
|
+
url = generate_api_messages_url(item[:token])
|
82
|
+
result = Apphunkd::Remote.post_message(url, item.dup, 300)
|
83
83
|
end
|
84
84
|
|
85
85
|
def generate_api_messages_url(token)
|
data/lib/apphunkd/remote.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
require '
|
1
|
+
require 'httparty'
|
2
2
|
require 'timeout'
|
3
|
-
require 'uri'
|
4
3
|
|
5
4
|
module Apphunkd
|
6
5
|
module Remote
|
6
|
+
include HTTParty
|
7
7
|
|
8
8
|
autoload :Result, 'apphunkd/remote/result'
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
def
|
12
|
+
def post_message(url, payload = {}, post_timeout = 60)
|
13
13
|
begin
|
14
|
+
payload.delete(:token)
|
14
15
|
Timeout.timeout(post_timeout) do
|
15
|
-
|
16
|
-
result = Remote::Result.new(:response => Net::HTTP.post_form(uri, payload))
|
16
|
+
result = Remote::Result.new(self.post(url, :body => payload))
|
17
17
|
result.status = :ok
|
18
18
|
return result
|
19
19
|
end
|
20
|
-
rescue SocketError
|
21
|
-
Remote::Result.new(:status => :connection_error)
|
22
|
-
rescue
|
23
|
-
Remote::Result.new(:status => :
|
20
|
+
rescue SocketError => e
|
21
|
+
return Remote::Result.new(:status => :connection_error, :response => "SocketError: #{e.inspect}")
|
22
|
+
rescue Errno::ECONNREFUSED => e
|
23
|
+
return Remote::Result.new(:status => :connection_error, :response => "ConnRefused: #{e.inspect}")
|
24
|
+
rescue Timeout::Error => e
|
25
|
+
return Remote::Result.new(:status => :timeout, :response => "Timeout: #{e.inspect}")
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apphunkd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Wolff
|
@@ -42,6 +42,16 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: "0"
|
44
44
|
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: httparty
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.5.2
|
54
|
+
version:
|
45
55
|
- !ruby/object:Gem::Dependency
|
46
56
|
name: sinatra
|
47
57
|
type: :runtime
|