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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/carnivore/source.rb +33 -10
- data/lib/carnivore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f174c035064f92e9c034561667159f358152c09d
|
4
|
+
data.tar.gz: af6561fd2a8de3753cd4bc257e6d9bc2dba3e2c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 530cba3b2a2be5b5d19ad82c376b5b94239bcaacedc81facb9f144b6d7de6d1a067ba3a2b5948a68268f6a8c3d12621e9d83713e0660a7f3461939ec4820942b
|
7
|
+
data.tar.gz: 5627c21026d731dc1c896e4c3b82e67d9915859fa1d1daf0171fff6fab40cab6a409012929069d33a96b1f07dbf083821383940e355f7b4641ef58a60975a688
|
data/CHANGELOG.md
CHANGED
data/lib/carnivore/source.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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(
|
71
|
-
|
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
|
-
|
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
|
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
|
data/lib/carnivore/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|