yahm 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yahm/mapping.rb +1 -1
- data/lib/yahm/version.rb +1 -1
- data/spec/yahm/mapping_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ae6af9e954b14e990a059ff3672a72f0f1c9b8f
|
4
|
+
data.tar.gz: bb64407d073dff1464f31b677499854ebdf23455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 589c022e88492cd65dccf9a239be3ebefe63c24d1f6feaed9dc850fddd29f790bf9093a16df9428919222830a078342054c14566115d7de1d931505b6c902004
|
7
|
+
data.tar.gz: 2295f96ffca8eae8a8c751a31079c70eb204304fa1a693ca547e6fa3e5ef3da6a350ef39780a76f9c4be6638d0b43dbd2076d843aad6a6934d006770c50f6f6f
|
data/lib/yahm/mapping.rb
CHANGED
@@ -41,7 +41,7 @@ class Yahm::Mapping
|
|
41
41
|
sanitized_target_path = rule.last[:to].sub(/^\//, "").split("/").map(&:to_sym)
|
42
42
|
target_parent_path = sanitized_target_path.slice(0, sanitized_target_path.length - 1)
|
43
43
|
|
44
|
-
source_value = sanitized_source_path.inject(input_hash) { |hash, key| hash[key]
|
44
|
+
source_value = sanitized_source_path.inject(input_hash) { |hash, key| hash.nil? ? nil : hash[key]}
|
45
45
|
|
46
46
|
unless (symbol_or_callable = rule.last[:processed_by]).nil?
|
47
47
|
source_value = if source_value.is_a?(Array)
|
data/lib/yahm/version.rb
CHANGED
data/spec/yahm/mapping_spec.rb
CHANGED
@@ -78,6 +78,13 @@ describe Yahm::Mapping do
|
|
78
78
|
:target => "a string"
|
79
79
|
})
|
80
80
|
end
|
81
|
+
|
82
|
+
it "returns nil if the source path does not exist" do
|
83
|
+
expect(Yahm::Mapping.new.map("/source/value/min", to: "/target").translate_hash(foo: "bar"))
|
84
|
+
.to eq({
|
85
|
+
:target => nil
|
86
|
+
})
|
87
|
+
end
|
81
88
|
end
|
82
89
|
|
83
90
|
end
|