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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc7b7aa820d36ad017732ae695c841013cce3a826e9042e19a2995442847a39b
4
- data.tar.gz: 6e2e5012d09ea7cf08c967093242f2e5af7389e62cd3d631b213ba948b019b8a
3
+ metadata.gz: 54fed64f173cd683fa66d514e65c74d42bb992965fdb85ca15df823e97e4ded1
4
+ data.tar.gz: 18170f3fd1660fef26448961ab5e5af22c42af405750f54873e6cb650718f3b2
5
5
  SHA512:
6
- metadata.gz: fb68056b1e72c17f51de9df99487f85b01dc64fb17951419eebb7a5e35d07906f4b47093092ecf6afda5b1a415a51e12d5ad7c47fda9bae39c783b0187eb52fc
7
- data.tar.gz: 3d3a3b35c1b011fb55bec52ea98a2291a2d3fa2d270ce68948879d4c4b1978af4f15a0bb524e5b5fa20a924252d349ea1907f25d1df99674885a23a9d4fd2a52
6
+ metadata.gz: ddb5f0e7b5619cbf29ba7a396381ac0bdba315ac94aef9b6d210f4184f47e028f47e4d96608268c83dcbb8c3d291df3bc23493c76ea11a57f33802d1c32e4903
7
+ data.tar.gz: 805a7b7775abab148ed13be3e70bd7dd16e8de4f9335b7b109e38b99e4298008ea05e093df835bf519e886de9b134ed43a50a6dde462d5c2f2623bfa9a591213
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # DataCollector
2
- Convinience module to Extract, Transform and Load your data.
2
+ Convenience module to Extract, Transform and Load your data.
3
3
 
4
4
  #### input
5
5
  Read input from an URI
@@ -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?('options') && rule['options'].has_key?('convert') && rule['options']['convert'].eql?('each')
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
- #pp data
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module DataCollector
3
- VERSION = "0.2.3"
3
+ VERSION = "0.3.0"
4
4
  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.2.3
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-01-08 00:00:00.000000000 Z
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.2
228
+ rubygems_version: 3.0.6
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: ETL helper library