data_collector 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/data_collector.gemspec +1 -2
- data/lib/data_collector/core.rb +3 -0
- data/lib/data_collector/output.rb +5 -2
- data/lib/data_collector/rules.rb +10 -3
- data/lib/data_collector/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67dc86adcebab3a6deba3ca2adf6c41c5925c03fc0dca627b030a39ff889d796
|
4
|
+
data.tar.gz: a4283972b9035c9e48370bcd07f3a375fb5312de584ed757f3572cc4c0b47164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65fee9ff5f15c521afc0f8181a67cebe5d7d3668a72e5cf792572745b9f7279565972cfea1568fed08d1173b33686c7fd9038c244afbc37891d25a25b6d3962d
|
7
|
+
data.tar.gz: 5cb4b0144a4993a00af0fc9d9637f9bc1c1fb0b72fd082e30c9f7ffbd319fbd2ad28ce95ae9b0fe54020bcb0e3ec0251380830ff4525d7a80c33966355a1ac0a
|
data/README.md
CHANGED
data/data_collector.gemspec
CHANGED
@@ -42,9 +42,8 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_runtime_dependency "nori", "~> 2.6"
|
43
43
|
spec.add_runtime_dependency "http", "~> 4.1"
|
44
44
|
spec.add_runtime_dependency "mime-types", "~> 3.2"
|
45
|
-
spec.add_runtime_dependency "minitar", "= 0.
|
45
|
+
spec.add_runtime_dependency "minitar", "= 0.9"
|
46
46
|
spec.add_runtime_dependency "activesupport", "~> 5.2"
|
47
|
-
spec.add_runtime_dependency "redis", "~> 4.1"
|
48
47
|
|
49
48
|
spec.add_development_dependency "bundler", "~> 2.0"
|
50
49
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/data_collector/core.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'jsonpath'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
require_relative 'input'
|
5
6
|
require_relative 'output'
|
@@ -93,6 +94,7 @@ module DataCollector
|
|
93
94
|
|
94
95
|
filtered
|
95
96
|
rescue StandardError => e
|
97
|
+
@logger ||= Logger.new(STDOUT)
|
96
98
|
@logger.error("#{filter_path} failed: #{e.message}")
|
97
99
|
[]
|
98
100
|
end
|
@@ -102,6 +104,7 @@ module DataCollector
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def log(message)
|
107
|
+
@logger ||= Logger.new(STDOUT)
|
105
108
|
@logger.info(message)
|
106
109
|
end
|
107
110
|
|
@@ -64,13 +64,16 @@ module DataCollector
|
|
64
64
|
|
65
65
|
def clear
|
66
66
|
@data = {}
|
67
|
-
GC.start(full_mark: true, immediate_sweep: true)
|
67
|
+
#GC.start(full_mark: true, immediate_sweep: true)
|
68
|
+
GC.start
|
68
69
|
end
|
69
70
|
|
70
71
|
|
71
|
-
def to_s(erb_file)
|
72
|
+
def to_s(erb_file = nil)
|
72
73
|
data = @data
|
73
74
|
|
75
|
+
return data.to_s if erb_file.nil?
|
76
|
+
|
74
77
|
def print(data, symbol, to_symbol = nil)
|
75
78
|
tag = to_symbol ? to_symbol.to_s : symbol.to_s
|
76
79
|
|
data/lib/data_collector/rules.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'logger'
|
2
|
-
#require_relative 'core'
|
3
2
|
|
4
3
|
module DataCollector
|
5
4
|
class Rules
|
@@ -19,7 +18,9 @@ module DataCollector
|
|
19
18
|
end
|
20
19
|
|
21
20
|
to_record.each do |element|
|
22
|
-
element = element.delete_if
|
21
|
+
element = element.delete_if do |k, v|
|
22
|
+
v != false && (v.nil? || v.empty?)
|
23
|
+
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -38,13 +39,19 @@ module DataCollector
|
|
38
39
|
to_record << {map_to_key.to_sym => result}
|
39
40
|
end
|
40
41
|
else
|
41
|
-
|
42
|
+
result = get_value_for(map_to_key, rule['filter'], from_record, rule['options'])
|
43
|
+
return if result && result.empty?
|
44
|
+
to_record << {map_to_key.to_sym => result}
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
45
48
|
def get_value_for(tag_key, filter_path, record, options = {})
|
46
49
|
data = nil
|
47
50
|
if record
|
51
|
+
if filter_path.is_a?(Array) && !record.is_a?(Array)
|
52
|
+
record = [record]
|
53
|
+
end
|
54
|
+
|
48
55
|
data = Core::filter(record, filter_path)
|
49
56
|
|
50
57
|
if data && options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Celik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
103
|
+
version: '0.9'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0.
|
110
|
+
version: '0.9'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '5.2'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: redis
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '4.1'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '4.1'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: bundler
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|