tiny_bus 1.0.2 → 1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_bus.rb +8 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb6142b34ec3c5c72a2a4073b080d8aba77dd40b9c04df3df89d9802a26c5c39
4
- data.tar.gz: b94962edf28bd4ad4affecb69cfd6d68d298b6623b98518cbbc9059fc117c83d
3
+ metadata.gz: 80e736518279f690809f359a1a1c4c96fd32154d3c847b83fe249e409bf5fd56
4
+ data.tar.gz: a1557163fb8fb490e79cbf159411989de8fc0e49bb8b5436d43cd7392c554031
5
5
  SHA512:
6
- metadata.gz: 1a29c06a16aab93b03d5a68384c55a4f461dd2a5e3b06c888d0d420325cd169dd1a16284af10a467eeb6953a525a809287deed3b25781a831ade89847d8dd0aa
7
- data.tar.gz: 05de4ca2e32edad9a3d63a065752c1990135d5de66710f957dfbc49838a6f45e2ffb9b4c901f831a073bbf14dd4a5291ef62c9d96a9219a9021c4a32f197176b
6
+ metadata.gz: eb83e912761d438bc17d93a4121e0c897c3d88b212ec50a842d088cedcaa028b84b6e797727be10a817fe63ad93e941f0f82278ffc79bea5587d13e516398e0d
7
+ data.tar.gz: bcf4adbfa6c0f959410b3b25ede768690c5e2c8bf47cd28e0d0b38e3d05941af44496656a9d75ce468da66d7e456a2761141413383bfba71b3c6759a38e61c88
data/lib/tiny_bus.rb CHANGED
@@ -20,9 +20,9 @@ require 'tiny_log'
20
20
  # t.msg({'topic' => 'whatever', 'details' => 'Historic happenings!}) # goes to dead letter output, or raises exception, depending on the configuration
21
21
  #
22
22
  # Initialization options:
23
- # TinyBus.new(log: <some object that responds to #puts>) # will send a copy of all successful messages to the log
24
- # TinyBus.new(dead: <some object that responds to #puts>) # will send a copy of all unsuccessful messages to the dead object
25
- # TinyBus.new(raise_on_dead: true) # strict mode for undeliverable messages, defaults to false
23
+ # TinyBus.new(log: <a filename for log output>) # will log all normal msgs in this file
24
+ # TinyBus.new(dead: <a filename for dead message log output>) # will log all undeliverable msgs in this file
25
+ # TinyBus.new(raise_on_dead: true) # strict mode for undeliverable messages, defaults to false
26
26
  class TinyBus
27
27
  # log:
28
28
  # if specified it should be a valid filename
@@ -37,8 +37,8 @@ class TinyBus
37
37
  def initialize(log: nil, dead: nil, raise_on_dead: false)
38
38
  @subs = {}
39
39
  @stats = { '.dead' => 0 }
40
- @log = log ? TinyLog.new(log) : $stdout
41
- @dead = dead ? File.open(dead, 'a') : $stderr
40
+ @log = log ? TinyLog.new(log) : TinyLog.new($stdout)
41
+ @dead = dead ? TinyLog.new(dead) : TinyLog.new($stderr)
42
42
  @raise_on_dead = raise_on_dead
43
43
  end
44
44
 
@@ -69,7 +69,7 @@ class TinyBus
69
69
  #
70
70
  # NOTE: it modifies the incoming msg object in place in order to avoid
71
71
  # unnecessary object allocations
72
- def msg(msg)
72
+ def msg(msg, lvl='info')
73
73
  topic = msg['topic']
74
74
 
75
75
  raise TinyBus::SendToDotTopicError.new("Cannot send to dot topic `#{topic}', because those are reserved for internal use") if topic.start_with?('.')
@@ -84,13 +84,13 @@ class TinyBus
84
84
  if subbers
85
85
  @stats[topic] += 1
86
86
  subbers.each{|s| s.msg(annotated) }
87
- @log.puts annotated
87
+ @log.sent annotated
88
88
  else
89
89
  if @raise_on_dead
90
90
  raise TinyBus::DeadMsgError.new("Could not deliver message to topic `#{topic}'")
91
91
  else
92
92
  @stats['.dead'] += 1
93
- @dead.puts annotated
93
+ @dead.dead annotated
94
94
  end
95
95
  end
96
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt