data_collector 0.2.3 → 0.3.0
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/lib/data_collector/rules.rb +8 -5
- data/lib/data_collector/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54fed64f173cd683fa66d514e65c74d42bb992965fdb85ca15df823e97e4ded1
|
4
|
+
data.tar.gz: 18170f3fd1660fef26448961ab5e5af22c42af405750f54873e6cb650718f3b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb5f0e7b5619cbf29ba7a396381ac0bdba315ac94aef9b6d210f4184f47e028f47e4d96608268c83dcbb8c3d291df3bc23493c76ea11a57f33802d1c32e4903
|
7
|
+
data.tar.gz: 805a7b7775abab148ed13be3e70bd7dd16e8de4f9335b7b109e38b99e4298008ea05e093df835bf519e886de9b134ed43a50a6dde462d5c2f2623bfa9a591213
|
data/README.md
CHANGED
data/lib/data_collector/rules.rb
CHANGED
@@ -25,22 +25,24 @@ module DataCollector
|
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
|
+
|
28
29
|
def apply_rule(map_to_key, rule, from_record, to_record)
|
29
|
-
if rule.has_key?('
|
30
|
+
if rule.has_key?('text')
|
31
|
+
to_record << { map_to_key.to_sym => rule['text'] }
|
32
|
+
elsif rule.has_key?('options') && rule['options'].has_key?('convert') && rule['options']['convert'].eql?('each')
|
30
33
|
result = get_value_for(map_to_key, rule['filter'], from_record, rule['options'])
|
31
34
|
|
32
35
|
if result.is_a?(Array)
|
33
|
-
|
34
36
|
result.each do |m|
|
35
37
|
to_record << {map_to_key.to_sym => m}
|
36
38
|
end
|
37
|
-
|
38
39
|
else
|
39
40
|
to_record << {map_to_key.to_sym => result}
|
40
41
|
end
|
41
42
|
else
|
42
43
|
result = get_value_for(map_to_key, rule['filter'], from_record, rule['options'])
|
43
44
|
return if result && result.empty?
|
45
|
+
|
44
46
|
to_record << {map_to_key.to_sym => result}
|
45
47
|
end
|
46
48
|
end
|
@@ -66,13 +68,14 @@ module DataCollector
|
|
66
68
|
end
|
67
69
|
|
68
70
|
data.compact!
|
71
|
+
data.flatten! if options.key?('flatten') && options['flatten']
|
69
72
|
else
|
70
73
|
return options['map'][data] if options['map'].key?(data)
|
71
74
|
end
|
72
75
|
when 'each'
|
73
76
|
data = [data] unless data.is_a?(Array)
|
74
|
-
data = data.map {|d| options['lambda'].call(d)}
|
75
|
-
|
77
|
+
data = data.map { |d| options['lambda'].call(d) }
|
78
|
+
data.flatten! if options.key?('flatten') && options['flatten']
|
76
79
|
when 'call'
|
77
80
|
return options['lambda'].call(data)
|
78
81
|
end
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Celik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
|
-
rubygems_version: 3.0.
|
228
|
+
rubygems_version: 3.0.6
|
229
229
|
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: ETL helper library
|