carnivore 0.3.4 → 0.3.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: b3ebd582b172d7f8a172e53b246fb649662b62f4
4
- data.tar.gz: daa0ee227892628fdcc56bd3e045d7740aa5535a
3
+ metadata.gz: f174c035064f92e9c034561667159f358152c09d
4
+ data.tar.gz: af6561fd2a8de3753cd4bc257e6d9bc2dba3e2c6
5
5
  SHA512:
6
- metadata.gz: 9536220e9976707a1b05c7af17b340e0ff04077ce4956b28ea4e3444783da856f371c8c796a4d7637c9f1f7985558027e8754e1de46ac36cd128ced3b300247b
7
- data.tar.gz: 93b87e705f41946c55eeee4387066f731f8f99e190e8ca9d302629de8b87005fb1c16e09c9fe1bcca6659e259f23a87f9344444b5bf63897c56271b50c085126
6
+ metadata.gz: 530cba3b2a2be5b5d19ad82c376b5b94239bcaacedc81facb9f144b6d7de6d1a067ba3a2b5948a68268f6a8c3d12621e9d83713e0660a7f3461939ec4820942b
7
+ data.tar.gz: 5627c21026d731dc1c896e4c3b82e67d9915859fa1d1daf0171fff6fab40cab6a409012929069d33a96b1f07dbf083821383940e355f7b4641ef58a60975a688
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.3.6
2
+ * Add `Carnivore::Source.clear!` helper
3
+ * Integrate memoization helpers
4
+ * Fix up config specs to proper load in config
5
+
1
6
  # v0.3.4
2
7
  * Remove loading of unused CLI library
3
8
  * Only terminate callback supervisor if alive
@@ -10,6 +10,8 @@ module Carnivore
10
10
 
11
11
  class << self
12
12
 
13
+ include Bogo::Memoization
14
+
13
15
  # Builds a source container
14
16
  #
15
17
  # @param args [Hash] source configuration
@@ -31,14 +33,27 @@ module Carnivore
31
33
  inst
32
34
  end
33
35
 
36
+ # @return [Smash] Source class information
37
+ def source_classes
38
+ memoize(:source_classes, :global) do
39
+ Smash.new
40
+ end
41
+ end
42
+
43
+ # @return [Smash] Registered source information
44
+ def sources_registry
45
+ memoize(:sources, :global) do
46
+ Smash.new
47
+ end
48
+ end
49
+
34
50
  # Register a new source type
35
51
  #
36
52
  # @param type [Symbol] name of source type
37
53
  # @param require_path [String] path to require when requested
38
54
  # @return [TrueClass]
39
55
  def provide(type, require_path)
40
- @source_klass ||= Smash.new
41
- @source_klass[type] = require_path
56
+ source_classes[type] = require_path
42
57
  true
43
58
  end
44
59
 
@@ -47,8 +62,7 @@ module Carnivore
47
62
  # @param type [String, Symbol] name of source type
48
63
  # @return [String, NilClass]
49
64
  def require_path(type)
50
- @source_klass ||= Smash.new
51
- @source_klass[type]
65
+ source_classes[type]
52
66
  end
53
67
 
54
68
  # Register the container
@@ -57,8 +71,7 @@ module Carnivore
57
71
  # @param inst [SourceContainer]
58
72
  # @return [TrueClass]
59
73
  def register(name, inst)
60
- @sources ||= Smash.new
61
- @sources[name] = inst
74
+ sources_registry[name] = inst
62
75
  true
63
76
  end
64
77
 
@@ -67,8 +80,8 @@ module Carnivore
67
80
  # @param name [String, Symbol] name of source
68
81
  # @return [SourceContainer]
69
82
  def source(name)
70
- if(@sources && @sources[name.to_sym])
71
- @sources[name.to_sym]
83
+ if(sources_registry[name])
84
+ sources_registry[name]
72
85
  else
73
86
  Celluloid.logger.error "Source lookup failed (name: #{name})"
74
87
  abort KeyError.new("Requested named source is not registered: #{name}")
@@ -77,7 +90,12 @@ module Carnivore
77
90
 
78
91
  # @return [Array<SourceContainer>] registered source containers
79
92
  def sources
80
- @sources ? @sources.values : []
93
+ sources_registry.values
94
+ end
95
+
96
+ # @return [NilClass] Remove any registered sources
97
+ def clear!
98
+ sources_registry.clear
81
99
  end
82
100
 
83
101
  # Reset communication methods within class
@@ -207,7 +225,12 @@ module Carnivore
207
225
  # Ensure we cleanup our internal supervisor before bailing out
208
226
  def teardown_cleanup
209
227
  warn 'Termination request received. Tearing down!'
210
- callback_supervisor.terminate if callback_supervisor.alive?
228
+ if(callback_supervisor && callback_supervisor.alive?)
229
+ warn "Tearing down callback supervisor! (#{callback_supervisor})"
230
+ callback_supervisor.terminate
231
+ else
232
+ warn 'Callback supervisor is not alive. No teardown issued'
233
+ end
211
234
  end
212
235
 
213
236
  # @return [TrueClass, FalseClass] automatic message confirmation enabled
@@ -1,4 +1,4 @@
1
1
  module Carnivore
2
2
  # Current version of library
3
- VERSION = Gem::Version.new('0.3.4')
3
+ VERSION = Gem::Version.new('0.3.6')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carnivore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid