yahm 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/yahm/mapping.rb +1 -1
- data/lib/yahm/version.rb +1 -1
- data/spec/yahm/mapping_spec.rb +12 -10
- 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: 289d52fb02711637756685037c3bc7b61776595f
|
4
|
+
data.tar.gz: a71595859c07c3d7458f899b0d4b4d2491a621e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec9fd236ab42efcc316c49fff7c2ccd945f3526252fd1c8bf56c385b2c4ddc9a8f49618bec3c78e109932c265fc051fe014c6e7de5f3fb160a958d7ae8b68b4
|
7
|
+
data.tar.gz: 67d6557c1388c7242d9dea672b395887189d8280c02220f0a5e3f42ed8787d8c341fa18bb4a22e35876e79bdee150f5da7d10591bb0ff92d5dd9459ad53fa630
|
data/lib/yahm/mapping.rb
CHANGED
@@ -49,7 +49,7 @@ class Yahm::Mapping
|
|
49
49
|
end
|
50
50
|
|
51
51
|
unless (split_by_character = rule.last[:split_by]).nil?
|
52
|
-
source_value = source_value.split(split_by_character).map(&:strip)
|
52
|
+
source_value = source_value.split(split_by_character).map(&:strip) unless source_value.nil?
|
53
53
|
end
|
54
54
|
|
55
55
|
unless rule.last[:force_array].nil?
|
data/lib/yahm/version.rb
CHANGED
data/spec/yahm/mapping_spec.rb
CHANGED
@@ -16,15 +16,16 @@ describe Yahm::Mapping do
|
|
16
16
|
describe ".translate_hash" do
|
17
17
|
let(:mapping) do
|
18
18
|
_mapping = Yahm::Mapping.new
|
19
|
-
_mapping.map "/record_id",
|
20
|
-
_mapping.map "/record/title",
|
21
|
-
_mapping.map "/record/isbns",
|
22
|
-
_mapping.map "/record/isbns[1]",
|
23
|
-
_mapping.map "/record/count",
|
24
|
-
_mapping.map "/record/languages",
|
25
|
-
_mapping.map "/record/authors",
|
26
|
-
_mapping.map "/record/version",
|
27
|
-
_mapping.map "/record/creators",
|
19
|
+
_mapping.map "/record_id", to: "/id"
|
20
|
+
_mapping.map "/record/title", to: "/tile"
|
21
|
+
_mapping.map "/record/isbns", to: "/my_data/isbns"
|
22
|
+
_mapping.map "/record/isbns[1]", to: "/main_isbn" # when an array, one can specifiy which element to choose
|
23
|
+
_mapping.map "/record/count", to: "/count", :processed_by => :to_i # processed_by specifies a method which post_processes to value
|
24
|
+
_mapping.map "/record/languages", to: "/languages", force_array: true
|
25
|
+
_mapping.map "/record/authors", to: "/authors", split_by: ";"
|
26
|
+
_mapping.map "/record/version", to: "/version", default: 1
|
27
|
+
_mapping.map "/record/creators", to: "/creators", force_array: true # when source value is nil, there should be an empty array in the target hash
|
28
|
+
_mapping.map "/record/publishers", to: "/publishers", split_by: ";" # if there are is no source value, this should result to nil in the target hash
|
28
29
|
_mapping
|
29
30
|
end
|
30
31
|
|
@@ -54,7 +55,8 @@ describe Yahm::Mapping do
|
|
54
55
|
:languages=>["ger"],
|
55
56
|
:authors=>["John Doe", "Jane Doe"],
|
56
57
|
:version=>1,
|
57
|
-
:creators=>[]
|
58
|
+
:creators=>[],
|
59
|
+
:publishers=>nil
|
58
60
|
})
|
59
61
|
end
|
60
62
|
end
|