abroad 4.1.0 → 4.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: dadd8e40a0bd722140b69e9afc49eae5aa28f28e
4
- data.tar.gz: f204d17dffbc54735c6255765e675e809bc0cd29
3
+ metadata.gz: 0b68ea68c52475a6416744f8605aacf49a680b44
4
+ data.tar.gz: 9f3b19ef80343e6b157ccf016f8ee040ce422a0a
5
5
  SHA512:
6
- metadata.gz: bca09d5714337ed9456c3dfa774d3ba63287114a4e8d2a6403dfcf0f71267902f9dcdf76840537b9be98231c6bac86a19342f27dd495977a0636021d2ab09c1d
7
- data.tar.gz: 63b5cc4df1bef7e34f0501932b22c5e7c54f90e13be4738d9b6664848310e8daf3e653c90c1c099968a2922c08110ad4f237ad07e1c360129814d84284ef1b6a
6
+ metadata.gz: 9b4bb6fcdbb232870d7f88d654a010f0569b6490f8c00922adcc243c0e8a0ad1a78d924c75430267bd1e6ba292669def38e4c828bb385d008e2db3f09b4e3516
7
+ data.tar.gz: 43ca2d4a935b470fe1de2e05d7aa74fb82898f73eeeec6d111dee6f882243690d8d76dd77c615eb9f15ec806d9bd5a1a4bb94c3c9b0fbd928c002f45b1d82e0a
@@ -21,7 +21,7 @@ module Abroad
21
21
  walk(val, cur_path + [segment], options, &block)
22
22
  end
23
23
  when Array
24
- if options[:preserve_arrays]
24
+ if options[:preserve_arrays] && string_array?(obj)
25
25
  yield scrub_path(cur_path).join('.'), obj
26
26
  else
27
27
  obj.each_with_index do |val, idx|
@@ -33,6 +33,17 @@ module Abroad
33
33
  end
34
34
  end
35
35
 
36
+ def string_array?(arr)
37
+ arr.all? do |elem|
38
+ case elem
39
+ when Hash, Array
40
+ false
41
+ else
42
+ true
43
+ end
44
+ end
45
+ end
46
+
36
47
  def scrub_path(path)
37
48
  path # no-op
38
49
  end
@@ -1,3 +1,3 @@
1
1
  module Abroad
2
- VERSION = '4.1.0'
2
+ VERSION = '4.1.1'
3
3
  end
@@ -16,4 +16,18 @@ describe Abroad::Extractors::Yaml::DottedKeyExtractor do
16
16
  'foo.bar' => %w(a b c)
17
17
  )
18
18
  end
19
+
20
+ it "expands arrays if they don't contain only strings" do
21
+ content = YAML.dump(foo: { bar: [{ baz: 'boo' }] })
22
+ extractor = Abroad::Extractors::Yaml::DottedKeyExtractor.from_string(content)
23
+ enum = extractor.extract_each(preserve_arrays: true)
24
+
25
+ phrases = enum.with_object({}) do |(key, value), ret|
26
+ ret[key] = value
27
+ end
28
+
29
+ expect(phrases).to eq(
30
+ 'foo.bar.0.baz' => 'boo'
31
+ )
32
+ end
19
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abroad
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-05 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities