marcspec 0.7.2 → 0.7.3
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.
- data/CHANGES +3 -0
- data/VERSION +1 -1
- data/lib/marcspec/kvmap.rb +9 -10
- data/lib/marcspec/multivaluemap.rb +6 -4
- data/lib/marcspec.rb +2 -8
- data/spec/maps_spec.rb +7 -0
- metadata +4 -4
data/CHANGES
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.3
|
data/lib/marcspec/kvmap.rb
CHANGED
@@ -64,6 +64,10 @@ module MARCSpec
|
|
64
64
|
|
65
65
|
|
66
66
|
# Translate from a solrmarc map file that has *already been determined* to be a KV map
|
67
|
+
#
|
68
|
+
# Uses the underlying java Properties class to avoid having to rewrite all the esacping
|
69
|
+
# logic.
|
70
|
+
#
|
67
71
|
# @param [String] filename The path to the solrmarc kv map file
|
68
72
|
# @return [MARCSpec::KVMap] a KVMap
|
69
73
|
|
@@ -71,20 +75,15 @@ module MARCSpec
|
|
71
75
|
mapname = File.basename(filename).sub(/\..+?$/, '')
|
72
76
|
map = {}
|
73
77
|
File.open(filename) do |smf|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
next if l =~ /^#/
|
79
|
-
unless l =~ /^(.+?)\s*=\s*(.+)$/
|
80
|
-
$LOG.warn "KVMap import skipping weird line in #{filename}\n #{l}"
|
81
|
-
next
|
82
|
-
end
|
83
|
-
map[$1] = $2
|
78
|
+
prop = Java::java.util.Properties.new
|
79
|
+
prop.load(smf.to_inputstream)
|
80
|
+
prop.each do |k,v|
|
81
|
+
map[k] = v
|
84
82
|
end
|
85
83
|
end
|
86
84
|
return self.new(mapname, map)
|
87
85
|
end
|
86
|
+
|
88
87
|
|
89
88
|
|
90
89
|
end
|
@@ -36,15 +36,17 @@ module MARCSpec
|
|
36
36
|
mapname = File.basename(filename).sub(/\..+?$/, '')
|
37
37
|
kvlist = []
|
38
38
|
File.open(filename) do |f|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
prop = Java::java.util.Properties.new
|
40
|
+
prop.load(f.to_inputstream)
|
41
|
+
prop.each do |patstring,kv|
|
42
|
+
unless patstring =~ /^pattern/ and kv =~ /.+=>.+/
|
42
43
|
$LOG.warn "MultiValueMap import skipping weird line in #{filename}\n #{l}"
|
43
44
|
next
|
44
45
|
end
|
46
|
+
match = /^\s*(.+?)\s*=>\s*(.+?)\s*$/.match(kv)
|
45
47
|
kvlist << [Regexp.new(match[1]), match[2]]
|
46
48
|
end
|
47
|
-
end
|
49
|
+
end
|
48
50
|
return self.new(mapname, kvlist)
|
49
51
|
end
|
50
52
|
|
data/lib/marcspec.rb
CHANGED
@@ -17,15 +17,9 @@ require "marcspec/marcfieldspec"
|
|
17
17
|
# It's just a hash.
|
18
18
|
|
19
19
|
module CacheSpot
|
20
|
-
def
|
20
|
+
def cachespot
|
21
21
|
@_cachespot ||= {}
|
22
|
-
@_cachespot
|
23
|
-
return v
|
24
|
-
end
|
25
|
-
|
26
|
-
def cacheget k
|
27
|
-
@_cachespot ||= {}
|
28
|
-
return @_cachespot[k]
|
22
|
+
return @_cachespot
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
data/spec/maps_spec.rb
CHANGED
@@ -56,6 +56,13 @@ describe "Maps" do
|
|
56
56
|
map["nl"].should.equal "New Caledonia"
|
57
57
|
end
|
58
58
|
|
59
|
+
it "should correctly deal with solrmarc files with escaped chars (via \\)" do
|
60
|
+
map = MARCSpec::KVMap.from_solrmarc_file "#{DIR}/data/umich/translation_maps/location_map.properties"
|
61
|
+
map['AAEL'].should.equal 'AAEL'
|
62
|
+
map['AAEL MICE'].should.equal 'AAEL MICE'
|
63
|
+
map['BUHR AAEL'].should.equal 'BUHR'
|
64
|
+
end
|
65
|
+
|
59
66
|
it "should read a pattern solrmarc file" do
|
60
67
|
map = MARCSpec::MultiValueMap.from_solrmarc_file "#{DIR}/data/umich/translation_maps/library_map.properties"
|
61
68
|
map.mapname.should.equal 'library_map'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marcspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 3
|
10
|
+
version: 0.7.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BillDueber
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|