yaml_to_csv 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 53dc590465610bfd38a9853b8577cc07b3da45a9
4
- data.tar.gz: 8329b3f6dc58d53cc38af8c4a8afa7e94788dc54
3
+ metadata.gz: ba87113ac0fea5b7035cb7cce2089bd667d19c1a
4
+ data.tar.gz: 65018a508c727b51adf1b14cbb151faa75786e51
5
5
  SHA512:
6
- metadata.gz: adc2a5850589204af8ce2bc3e12f4cd7fc439dc4fa7b56a6cc564ebc4ea1224aadc40ea7da669b2873ef93420080cba82e560894c3027674374fbd31bd89aaa9
7
- data.tar.gz: 8160791fd06437790928832bd971be6e22b863a4cf9d52d8d132f5ead928cbb12cae82e3ccb194158b196e700757178f135c0ee30a1c5fdb5fee4e3ff6728141
6
+ metadata.gz: 55f57b3c1737ef73dc36f38f3b20a9e4a2aff772070a7ea49b74af6ac84fc019f74683f66222bda9ef28aa029b2265219d1cd91c06f0447ab86e7470ae4ab0d1
7
+ data.tar.gz: e1d22cd25b7db9a58c7ec2da5390b069f64d8590e5bd329b2e1ee40284d1f880e57bd6e58e82df62c9bf4546badae7b225430b14731c863f3c8e007be0a1a42f
data/lib/yaml_to_csv.rb CHANGED
@@ -28,12 +28,13 @@ class YamlToCsv
28
28
  csv_arrs.reduce({}) do |hsh, (composite_key, value)|
29
29
  keys = split_keys.call(composite_key)
30
30
  nested = hsh
31
- keys.each do |key|
32
- if keys.last == key
33
- nested[key] = value
34
- else
31
+ keys.each_with_index do |key, idx|
32
+ has_nested_keys = (idx + 1) != keys.length
33
+ if has_nested_keys
35
34
  nested[key] ||= {}
36
35
  nested = nested[key]
36
+ else
37
+ nested[key] = value
37
38
  end
38
39
  end
39
40
  hsh
@@ -1,3 +1,3 @@
1
1
  class YamlToCsv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_to_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Claes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-24 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,4 +95,3 @@ signing_key:
95
95
  specification_version: 4
96
96
  summary: Convert YAML to CSV and vice versa
97
97
  test_files: []
98
- has_rdoc: