data_collector 0.15.0 → 0.16.0
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 +4 -4
- data/lib/data_collector/core.rb +7 -0
- data/lib/data_collector/rules.rb +1 -1
- data/lib/data_collector/rules_ng.rb +2 -2
- data/lib/data_collector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05eee6a12f06a0d94c8ad6b0e39746a169622bf51c0b4cd142bc8445ab8917eb
|
4
|
+
data.tar.gz: e0c9aa6d5b397b393ca4348b7b1b38f451c8e6dae79dd202ab695c8244e7974f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dc5ea1eacbbd11c71e3e7139f59130a0e54318638928025553bbe6deed2b528df77360f55c7821baca208b3b84c55ac85df7db84a327157ff1e80f5b4ad0344
|
7
|
+
data.tar.gz: d9d6cf588e3c379e0a09c45dfe68ab339ad372c48c2602e1b71cf66c7f9523fb4457ec8d2deabc7c6bdb5d2ac8919ece131b5ef66df1616c7baddfff80298762
|
data/lib/data_collector/core.rb
CHANGED
@@ -16,6 +16,7 @@ module DataCollector
|
|
16
16
|
def input
|
17
17
|
@input ||= DataCollector::Input.new
|
18
18
|
end
|
19
|
+
module_function :input
|
19
20
|
|
20
21
|
# Output is an object you can store data that needs to be written to an output stream
|
21
22
|
# output[:name] = 'John'
|
@@ -48,6 +49,7 @@ module DataCollector
|
|
48
49
|
def output
|
49
50
|
@output ||= Output.new
|
50
51
|
end
|
52
|
+
module_function :output
|
51
53
|
|
52
54
|
#You can apply rules to input
|
53
55
|
# A rule is made up of a Hash the key is the map key field its value is a Hash with a JSONPath filter and
|
@@ -79,11 +81,13 @@ module DataCollector
|
|
79
81
|
def rules
|
80
82
|
@rules ||= Rules.new
|
81
83
|
end
|
84
|
+
module_function :rules
|
82
85
|
|
83
86
|
# New rules runner
|
84
87
|
def rules_ng
|
85
88
|
@rules_ng ||= RulesNg.new
|
86
89
|
end
|
90
|
+
module_function :rules_ng
|
87
91
|
|
88
92
|
# evaluator http://jsonpath.com/
|
89
93
|
# uitleg http://goessner.net/articles/JsonPath/index.html
|
@@ -104,15 +108,18 @@ module DataCollector
|
|
104
108
|
@logger.error("#{filter_path} failed: #{e.message}")
|
105
109
|
[]
|
106
110
|
end
|
111
|
+
module_function :filter
|
107
112
|
|
108
113
|
def config
|
109
114
|
@config ||= ConfigFile
|
110
115
|
end
|
116
|
+
module_function :config
|
111
117
|
|
112
118
|
def log(message)
|
113
119
|
@logger ||= Logger.new(STDOUT)
|
114
120
|
@logger.info(message)
|
115
121
|
end
|
122
|
+
module_function :log
|
116
123
|
|
117
124
|
end
|
118
125
|
|
data/lib/data_collector/rules.rb
CHANGED
@@ -105,12 +105,12 @@ module DataCollector
|
|
105
105
|
output_data
|
106
106
|
end
|
107
107
|
|
108
|
-
def json_path_filter(
|
108
|
+
def json_path_filter(filter, input_data)
|
109
109
|
data = nil
|
110
110
|
return data if input_data.nil? || input_data.empty?
|
111
111
|
return input_data if input_data.is_a?(String)
|
112
112
|
|
113
|
-
|
113
|
+
Core.filter(input_data, filter)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|