watership 0.2.5 → 0.2.6

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: 61c748aa0c2c2eee939f134e456f8641fddb9003
4
- data.tar.gz: f91c3605eeb336615059c3f81cdf45e74934ec0d
3
+ metadata.gz: 56677c57d836c14527c4f17df9988561f3972c27
4
+ data.tar.gz: 27ea7ce1bd196216472f2140a2fa4367ae01ef18
5
5
  SHA512:
6
- metadata.gz: 4f8884061fe65ddda2862ba327dffb0d0e67f253433cfdbd21de95243a0e60efc9fe5c5e27c8effb88ab5e0f3b7e88a2056d2bacc712b252ef7b60a60981c2cb
7
- data.tar.gz: 157dda93f86859988cfcfcc1a58a5579393ecc6e232261fae063858556d2ecb11d4625ea21034b6a9fc7a75fee5c7e36f79d01648d12768ba85056201f768efe
6
+ metadata.gz: ba65da99ea01c47e4b1da2cc9fde44f094c68178a028ec54301ea029eddf4e6a0de94da296e452c7fdce87d0635f9313ae9e03fc34702c3b30e5e19d533d0158
7
+ data.tar.gz: 97eed4dccb8d43e852fd196dd9bbcc0d9faabd859a6d8f2bf9c4c0c9e9ab7fa6a6839115f32e26239fe965324723896b522df3aaee36afa67e27757960ba820e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Watership is a wrapper around Bunny. It attempts to catch connection issues to the RabbitMQ server and provide a fake backend, switching back to the real backend when it becomes available.
4
4
 
5
- **You shouldn't use it. It's dumb.**
5
+ It is currently being used in production on a set of applications, but be warned that it's still early in its life.
6
6
 
7
7
  ## Installation
8
8
 
@@ -1,3 +1,3 @@
1
1
  module Watership
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
data/lib/watership.rb CHANGED
@@ -11,6 +11,10 @@ module Watership
11
11
  ]
12
12
 
13
13
  class << self
14
+ def environment=(env)
15
+ @env = env
16
+ end
17
+
14
18
  def config=(path)
15
19
  @config = IO.read(path).chomp
16
20
  end
@@ -25,7 +29,7 @@ module Watership
25
29
  queue.publish(JSON.generate(message))
26
30
  rescue StandardError => exception
27
31
  fallback.call if fallback
28
- Airbrake.notify(exception) if defined?(Airbrake)
32
+ notify(exception)
29
33
  logger.error(exception.class.name)
30
34
  end
31
35
 
@@ -42,7 +46,7 @@ module Watership
42
46
  def channel
43
47
  $channel ||= connection.create_channel
44
48
  rescue *CONNECTION_EXCEPTIONS => exception
45
- Airbrake.notify_or_ignore(exception) if defined?(Airbrake)
49
+ notify(exception)
46
50
  $channel = nil
47
51
  end
48
52
 
@@ -50,6 +54,14 @@ module Watership
50
54
  Bunny.new(@config).tap { |bunny| bunny.start }
51
55
  end
52
56
 
57
+ def notify(exception)
58
+ Airbrake.notify_or_ignore(exception) if defined?(Airbrake) && @env == 'production'
59
+ end
60
+
61
+ def logger=(logger)
62
+ @logger = logger
63
+ end
64
+
53
65
  def logger
54
66
  @logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
55
67
  end
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.5
4
+ version: 0.2.6
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-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler