lapine 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19554974173dd44d98df62ed0ff7a8a34dcaf201
4
- data.tar.gz: abc54df05e0e133655eee78b2fc6c50a48db47cd
3
+ metadata.gz: 17ff6eda9eaea1807ee77240e11fa2dc336f7350
4
+ data.tar.gz: b94a4cbada011e8f4fe12e6873b2def2ab923e27
5
5
  SHA512:
6
- metadata.gz: 39dd5b1c4bd4145fb0710145afaa00050fdc9b24001f99645a9c82dd9c205ae01e32ad1736100df87b1ab7809c25edf7f55192b22a9858dde1e0f9ccb58dd3b3
7
- data.tar.gz: 35470b955af0f1ade5a271b8983d51a91988e62a21466b03726d55da67fbbd11eaad0f0bc87a7fd41524915972df3be0352d2a463457572962ded1313982c1d8
6
+ metadata.gz: f68160452a12c78121c0175e2cbf8448924a6d4dd075de8e5051628240cb097b2e3bf8ecd6bf3b5779a83b3a8b24fb020fdd7b977caa71d236628bb44ea68d13
7
+ data.tar.gz: 391d24cbd65e613f44f46df60eca15c1958c20466b01eb3425faea7448225127f45f6e78758ddc7f3b2b9ef56ce4259bfa1fe283c68c768b5bbde7bd214b9dbf
data/Changelog.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ ## 1.0.1
5
+
6
+ * Increased verbosity of errors
7
+ * Avoid instance_variable_get in publisher
8
+ * rename @exchange to @lapine_exchange
9
+
4
10
  ## 1.0.0
5
11
 
6
12
  * Breaking Change - error handler includes metadata in method signature
data/lib/lapine.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  require 'lapine/version'
2
+ require 'lapine/errors'
2
3
  require 'lapine/configuration'
3
4
  require 'lapine/exchange'
4
5
  require 'lapine/publisher'
5
6
  require 'lapine/annotated_logger'
6
7
 
7
8
  module Lapine
8
- class UndefinedConnection < StandardError; end
9
- class UndefinedExchange < StandardError; end
10
-
11
9
  def self.config
12
10
  @config ||= Configuration.new
13
11
  end
@@ -18,14 +16,14 @@ module Lapine
18
16
 
19
17
  def self.add_exchange(name, properties)
20
18
  connection = properties[:connection]
21
- raise UndefinedConnection unless connection
22
- raise UndefinedConnection unless config.connection_properties[connection]
19
+ raise UndefinedConnection.new("No connection for #{name}, properties: #{properties}") unless connection
20
+ raise UndefinedConnection.new("No connection properties for #{name}, properties: #{properties}") unless config.connection_properties[connection]
23
21
  config.exchange_properties[name] = properties
24
22
  end
25
23
 
26
24
  def self.find_exchange(name)
27
25
  exchange = config.exchange_properties[name]
28
- raise UndefinedExchange unless exchange
26
+ raise UndefinedExchange.new("No exchange for #{name}") unless exchange
29
27
  return config.exchanges[name].exchange if config.exchanges[name]
30
28
  config.exchanges[name] = Lapine::Exchange.new(name, exchange)
31
29
  config.exchanges[name].exchange
data/lib/lapine/dtrace.rb CHANGED
@@ -22,7 +22,7 @@ module Lapine
22
22
  end
23
23
 
24
24
  def self.fire!(probe_name, *args)
25
- raise "Unknown probe: #{probe_name}" unless self.provider.probes[probe_name]
25
+ raise ArgumentError.new("Unknown probe: #{probe_name}") unless self.provider.probes[probe_name]
26
26
  probe = self.provider.probes[probe_name]
27
27
  probe.fire(*args) if probe.enabled?
28
28
  end
@@ -0,0 +1,6 @@
1
+ module Lapine
2
+ class LapineError < StandardError; end
3
+ class UndefinedConnection < LapineError; end
4
+ class UndefinedExchange < LapineError; end
5
+ class NilExchange < LapineError; end
6
+ end
@@ -12,7 +12,8 @@ module Lapine
12
12
  end
13
13
 
14
14
  def exchange
15
- reconnect unless conn && conn.connected?
15
+ reconnect unless @exchange && conn && conn.connected?
16
+ raise Lapine::NilExchange unless @exchange
16
17
  @exchange
17
18
  end
18
19
 
@@ -8,7 +8,7 @@ module Lapine
8
8
  end
9
9
 
10
10
  def publish(routing_key = nil)
11
- Lapine.find_exchange(self.class.instance_variable_get(:@exchange)).publish(to_json, routing_key: routing_key)
11
+ Lapine.find_exchange(self.class.current_lapine_exchange).publish(to_json, routing_key: routing_key)
12
12
  end
13
13
 
14
14
  def to_json
@@ -17,7 +17,11 @@ module Lapine
17
17
 
18
18
  module ClassMethods
19
19
  def exchange(name)
20
- @exchange = name
20
+ @lapine_exchange = name
21
+ end
22
+
23
+ def current_lapine_exchange
24
+ @lapine_exchange
21
25
  end
22
26
  end
23
27
  end
@@ -1,3 +1,3 @@
1
1
  module Lapine
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lapine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-26 00:00:00.000000000 Z
12
+ date: 2015-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp
@@ -184,6 +184,7 @@ files:
184
184
  - lib/lapine/consumer/runner.rb
185
185
  - lib/lapine/consumer/topology.rb
186
186
  - lib/lapine/dtrace.rb
187
+ - lib/lapine/errors.rb
187
188
  - lib/lapine/exchange.rb
188
189
  - lib/lapine/publisher.rb
189
190
  - lib/lapine/test/exchange.rb