watership 0.2.0 → 0.2.1

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: 88ed411442bd7d22a020bf35b2977fa8045c28f0
4
- data.tar.gz: a8b8d9ff4cca429b7349b9c49b5afff814f5dfc0
3
+ metadata.gz: ba99e78f4a263b2aa1f7f8940e5888210afd404f
4
+ data.tar.gz: 14b43ac76d64bbb5eab1a32fd24839463ba7f329
5
5
  SHA512:
6
- metadata.gz: c49ca8b9245b9a785cde330485f3a602586cc1d863d9f3f1e6f0ed4833eb0d6ed1b1f88670eff8e0c402f4dea6aaad63ceebdbad1e541d3150ac67887059804f
7
- data.tar.gz: a7f0a9f4362792ea35b269cc445d0bcec29bf933639a676bd6895c1b46b24f81750d3fd82e8f512822868db82246e4edfb2d68d5abbf6443d7c7f456abf88550
6
+ metadata.gz: 62a894ef004e496ae153269fe2653f1868a903bdb75c09adfb8e799b55b68bd81a6db0cd93f90e80bb705554f5ffff05e32d5c62c470def032ad2b6084cbe0ea
7
+ data.tar.gz: 2b0da5493a5d0ee1e1fe64e5e40fe3328831126ae74b59f03362d00ba16af8cd9ddfb49feb98284fec0960cefc7982ac32ae0c4c65995911c7fa493798645b7c
@@ -0,0 +1,26 @@
1
+ module Watership
2
+ module Subscriber
3
+ def perform(payload)
4
+ raise NotImplementedError
5
+ end
6
+
7
+ def subscribe(name, options = {})
8
+ options = { block: true, ack: true }.merge(options)
9
+
10
+ queue(name).subscribe(options) do |delivery_info, properties, payload|
11
+ perform(JSON.parse(payload))
12
+ queue_channel.acknowledge(delivery_info.delivery_tag, false) if options[:ack]
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def queue(name)
19
+ Watership.connect_with_queue(name)
20
+ end
21
+
22
+ def queue_channel
23
+ Watership.channel
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  class Watership
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/watership.rb CHANGED
@@ -2,7 +2,7 @@ require "bunny"
2
2
  require "json"
3
3
  require "watership/version"
4
4
 
5
- class Watership
5
+ module Watership
6
6
  CONNECTION_EXCEPTIONS = [
7
7
  Bunny::ClientTimeout,
8
8
  Bunny::NetworkFailure,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watership
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Scofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-27 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - README.md
80
80
  - Rakefile
81
81
  - lib/watership.rb
82
+ - lib/watership/subscriber.rb
82
83
  - lib/watership/version.rb
83
84
  - watership.gemspec
84
85
  homepage: ''