jackal 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/jackal/callback.rb +31 -3
- data/lib/jackal/utils/payload.rb +11 -1
- data/lib/jackal/utils/spec/helpers.rb +8 -3
- data/lib/jackal/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: aad960864456381c1973a63d0410dea7200be1fc
|
4
|
+
data.tar.gz: 43787842bebae529547b90613402f0f84f77eab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3edc50f45995b3154e0c6726b85c44a41403ef3b4f7a020321a802a29a076c9ef5a7fee9af6596f15d2272fa92273d4057a9ab917ac3228720f03f270733b217
|
7
|
+
data.tar.gz: 46d2b9a99c0fac02cbd7bff500b840a778389b3484d867df4ee1d5fe3db9624a22f78c4a4baeeb422f446a3a7cbb261e982def6c3191252bc148b35fed109751
|
data/CHANGELOG.md
CHANGED
data/lib/jackal/callback.rb
CHANGED
@@ -13,8 +13,10 @@ module Jackal
|
|
13
13
|
include Bogo::Constants
|
14
14
|
include Bogo::Memoization
|
15
15
|
|
16
|
-
# @return [Array<Formatter>] formatters
|
16
|
+
# @return [Array<Formatter>] formatters applied on complete
|
17
17
|
attr_reader :formatters
|
18
|
+
# @return [Array<Formatter>] formatters applied prior
|
19
|
+
attr_reader :pre_formatters
|
18
20
|
|
19
21
|
# Create new instance
|
20
22
|
#
|
@@ -22,9 +24,31 @@ module Jackal
|
|
22
24
|
def initialize(*_)
|
23
25
|
super
|
24
26
|
if(service_config[:formatters])
|
25
|
-
|
27
|
+
setup_formatters
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Initialize any required formatters
|
32
|
+
#
|
33
|
+
# @return [TrueClass, FalseClass]
|
34
|
+
def setup_formatters
|
35
|
+
f_config = service_config[:formatters]
|
36
|
+
case f_config
|
37
|
+
when Hash
|
38
|
+
@formatters = f_config.fetch(:pre, []).map do |klass_name|
|
26
39
|
constantize(klass_name).new(self)
|
27
40
|
end
|
41
|
+
@pre_formatters = f_config.fetch(:post, []).map do |klass_name|
|
42
|
+
constantize(klass_name).new(self)
|
43
|
+
end
|
44
|
+
when Array
|
45
|
+
@formatters = f_config.map do |klass_name|
|
46
|
+
constantize(klass_name).new(self)
|
47
|
+
end
|
48
|
+
@pre_formatters = []
|
49
|
+
else
|
50
|
+
error "Formatters configuration error. Unable to process type `#{f_config.class}`."
|
51
|
+
false
|
28
52
|
end
|
29
53
|
end
|
30
54
|
|
@@ -137,7 +161,11 @@ module Jackal
|
|
137
161
|
# @return [Smash]
|
138
162
|
def apply_formatters!(payload)
|
139
163
|
formatters.each do |formatter|
|
140
|
-
|
164
|
+
begin
|
165
|
+
formatter.format(payload)
|
166
|
+
rescue => e
|
167
|
+
error "Formatter error encountered (<#{formatter}>): #{e.class} - #{e}"
|
168
|
+
end
|
141
169
|
end
|
142
170
|
end
|
143
171
|
|
data/lib/jackal/utils/payload.rb
CHANGED
@@ -26,7 +26,17 @@ module Jackal
|
|
26
26
|
# @return [Smash]
|
27
27
|
def unpack(message)
|
28
28
|
msg = message[:message].to_smash
|
29
|
-
msg.fetch(:payload, msg)
|
29
|
+
result = msg.fetch(:payload, msg)
|
30
|
+
if(respond_to?(:pre_formatters) && (pre_formatters && !pre_formatters.empty?))
|
31
|
+
pre_formatters.each do |formatter|
|
32
|
+
begin
|
33
|
+
formatter.format(result)
|
34
|
+
rescue => e
|
35
|
+
error "Formatter error encountered (<#{formatter}>): #{e.class} - #{e}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
result
|
30
40
|
end
|
31
41
|
|
32
42
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require 'carnivore/spec_helper'
|
3
3
|
|
4
|
-
Celluloid.logger.level =
|
4
|
+
Celluloid.logger.level = ENV['DEBUG'] ? 0 : 4
|
5
5
|
|
6
6
|
# Default source setup higher than base carivore default
|
7
7
|
unless(ENV['CARNIVORE_SOURCE_SETUP'])
|
@@ -51,10 +51,15 @@ end
|
|
51
51
|
# Configure using custom configuration JSON within config
|
52
52
|
# directory of current test
|
53
53
|
#
|
54
|
-
# @param config [String, Symbol] name of configuration file
|
54
|
+
# @param config [String, Symbol] name of configuration file
|
55
55
|
# @return [Thread] thread with running source
|
56
56
|
def run_setup(config)
|
57
|
-
|
57
|
+
config_dir = File.join(Dir.pwd, 'test', 'specs', 'config')
|
58
|
+
path = Dir.glob(File.join(config_dir, "#{config}*")).first
|
59
|
+
|
60
|
+
msg = "No file matching #{config} found in #{config_dir}"
|
61
|
+
raise msg unless path
|
62
|
+
|
58
63
|
Thread.abort_on_exception = true
|
59
64
|
runner = Thread.new do
|
60
65
|
Jackal::Loader.run!(:config => path)
|
data/lib/jackal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carnivore
|