traject 1.0.0.beta.5 → 1.0.0.beta.7
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/traject/macros/marc21.rb +29 -21
- data/lib/traject/macros/marc21_semantics.rb +1 -1
- data/lib/traject/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc1ca6c023f01b9e21148a3ca37d86858df8065
|
4
|
+
data.tar.gz: 4360b687f3ba8d957d4a14d39bc6cefbd443bcdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba976f724960b4048c2db65827780a46a2c64c442b2f48aa077375775f9f3a8901f446f226fd26f8e69cddbb696b3c114403c592b20cdc362bc43161a25f608
|
7
|
+
data.tar.gz: 7216d83c97aa75698d2c03dec2bcc263decf4cc3d39a62187e9b0b09856fa1cac45e4fcb524d633f8a77acbf474343a69fec9b0324b66f056eb888915396e95b
|
@@ -47,10 +47,6 @@ module Traject::Macros
|
|
47
47
|
raise RuntimeError.new("Illegal/Unknown argument '#{(options.keys - EXTRACT_MARC_VALID_OPTIONS).join(', ')}' in extract_marc at #{Traject::Util.extract_caller_location(caller.first)}")
|
48
48
|
end
|
49
49
|
|
50
|
-
only_first = options.delete(:first)
|
51
|
-
trim_punctuation = options.delete(:trim_punctuation)
|
52
|
-
default_value = options.delete(:default)
|
53
|
-
allow_duplicates = options.delete(:allow_duplicates)
|
54
50
|
|
55
51
|
# We create the TranslationMap and the MarcExtractor here
|
56
52
|
# on load, so the lambda can just refer to already created
|
@@ -61,6 +57,8 @@ module Traject::Macros
|
|
61
57
|
|
62
58
|
if translation_map_arg = options.delete(:translation_map)
|
63
59
|
translation_map = Traject::TranslationMap.new(translation_map_arg)
|
60
|
+
else
|
61
|
+
translation_map = nil
|
64
62
|
end
|
65
63
|
|
66
64
|
|
@@ -68,29 +66,39 @@ module Traject::Macros
|
|
68
66
|
|
69
67
|
lambda do |record, accumulator, context|
|
70
68
|
accumulator.concat extractor.extract(record)
|
69
|
+
Marc21.apply_extraction_options(accumulator, options, translation_map)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Side-effect the accumulator with the options
|
74
|
+
def self.apply_extraction_options(accumulator, options, translation_map=nil)
|
75
|
+
only_first = options[:first]
|
76
|
+
trim_punctuation = options[:trim_punctuation]
|
77
|
+
default_value = options[:default]
|
78
|
+
allow_duplicates = options[:allow_duplicates]
|
79
|
+
|
80
|
+
if only_first
|
81
|
+
accumulator.replace Array(accumulator[0])
|
82
|
+
end
|
71
83
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if translation_map
|
77
|
-
translation_map.translate_array! accumulator
|
78
|
-
end
|
79
|
-
|
80
|
-
if trim_punctuation
|
81
|
-
accumulator.collect! {|s| Marc21.trim_punctuation(s)}
|
82
|
-
end
|
84
|
+
if translation_map
|
85
|
+
translation_map.translate_array! accumulator
|
86
|
+
end
|
83
87
|
|
84
|
-
|
85
|
-
|
86
|
-
|
88
|
+
if trim_punctuation
|
89
|
+
accumulator.collect! {|s| Marc21.trim_punctuation(s)}
|
90
|
+
end
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
|
92
|
+
unless allow_duplicates
|
93
|
+
accumulator.uniq!
|
94
|
+
end
|
91
95
|
|
96
|
+
if default_value && accumulator.empty?
|
97
|
+
accumulator << default_value
|
92
98
|
end
|
93
99
|
end
|
100
|
+
|
101
|
+
|
94
102
|
# A list of symbols that are valid keys in the options hash
|
95
103
|
EXTRACT_MARC_VALID_OPTIONS = [:first, :trim_punctuation, :default,
|
96
104
|
:allow_duplicates, :separator, :translation_map,
|
@@ -514,7 +514,7 @@ module Traject::Macros
|
|
514
514
|
# customization you probably just want to write your own method in
|
515
515
|
# terms of the Marc21Semantics.assemble_lcsh method.
|
516
516
|
def marc_lcsh_formatted(options = {})
|
517
|
-
spec = options[:spec] || "600:610:611:630:648:650:651:654:
|
517
|
+
spec = options[:spec] || "600:610:611:630:648:650:651:654:662"
|
518
518
|
subd_separator = options[:subdivison_separator] || " — "
|
519
519
|
other_separator = options[:other_separator] || " "
|
520
520
|
|
data/lib/traject/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: marc
|