marcspec 1.1.0 → 1.1.1
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 +2 -0
- data/VERSION +1 -1
- data/lib/marcspec/multivaluemap.rb +5 -1
- data/spec/maps_spec.rb +23 -4
- data/spec/solrfieldspec_spec.rb +27 -2
- metadata +3 -3
data/CHANGES
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/spec/maps_spec.rb
CHANGED
@@ -26,10 +26,30 @@ describe "Maps" do
|
|
26
26
|
@kvmap['two'].should.equal ['2', 'zwei']
|
27
27
|
end
|
28
28
|
|
29
|
-
it "gets nothing on nonmatches" do
|
29
|
+
it "gets nothing on nonmatches for kvmap" do
|
30
30
|
@kvmap['ddd'].should.equal nil
|
31
|
-
@mvmap['ddd'].should.equal [nil]
|
32
31
|
end
|
32
|
+
|
33
|
+
it "gets nothing on nonmatches for mvmap" do
|
34
|
+
@mvmap['ddd'].should.equal nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "gets default if set for nonmatches with KVMap" do
|
38
|
+
@kvmap['ddd', 'default'].should.equal 'default'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "gets default if set for nonmatches with MVMap" do
|
42
|
+
@mvmap['ddd', 'default'].should.equal 'default'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "gets key if default is :passthrough for nonmatches with KVMap" do
|
46
|
+
@kvmap['ddd', :passthrough].should.equal 'ddd'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "gets key if default is :passthrough for nonmatches with KVMap" do
|
50
|
+
@mvmap['ddd', :passthrough].should.equal 'ddd'
|
51
|
+
end
|
52
|
+
|
33
53
|
|
34
54
|
it "gets correct values from multivaluemap" do
|
35
55
|
@mvmap['bi'].should.equal ['Bill']
|
@@ -40,7 +60,7 @@ describe "Maps" do
|
|
40
60
|
|
41
61
|
it "correctly uses default value" do
|
42
62
|
@mvmap['bi', 'default'].should.equal ['Bill']
|
43
|
-
@mvmap['ddd', 'default'].should.equal
|
63
|
+
@mvmap['ddd', 'default'].should.equal 'default'
|
44
64
|
@kvmap['ddd', 'default'].should.equal 'default'
|
45
65
|
@kvmap['one', 'default'].should.equal '1'
|
46
66
|
end
|
@@ -64,7 +84,6 @@ describe "Maps" do
|
|
64
84
|
|
65
85
|
it "can't round-trip a multivaluemap with a Proc" do
|
66
86
|
s = @mvmap.asPPString
|
67
|
-
puts s
|
68
87
|
newmvmap = MARCSpec::MultiValueMap.fromPPString s
|
69
88
|
newmvmap.should.not.equal @mvmap
|
70
89
|
end
|
data/spec/solrfieldspec_spec.rb
CHANGED
@@ -65,6 +65,31 @@ describe "SolrFieldSpec" do
|
|
65
65
|
sfs << @nonmatchingSpec
|
66
66
|
sfs.marc_values(@one).should.equal [@default]
|
67
67
|
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "Solr Field Specs and maps" do
|
71
|
+
|
72
|
+
before do
|
73
|
+
@one = MARC4J4R::Reader.new("#{DIR}/data/one.dat").first
|
74
|
+
# @batch = MARC4J4R::Reader.new("#{DIR}/batch.dat").collect
|
75
|
+
@opts = {:solrField=>'solrfield'}
|
76
|
+
@titleAC = MARCSpec::VariableFieldSpec.new('245', ['a', 'c'])
|
77
|
+
@titleACValue = "The Texas ranger Sung by Beale D. Taylor."
|
78
|
+
@twosixtyC = MARCSpec::VariableFieldSpec.new('260', 'c')
|
79
|
+
@twosixtyCValue = "1939."
|
80
|
+
|
81
|
+
@nonmatchingSpec = MARCSpec::VariableFieldSpec.new('999', ['a', 'c'])
|
82
|
+
|
83
|
+
@default = 'DEFAULT'
|
84
|
+
|
85
|
+
|
86
|
+
@mapValue = "twosixtyCMapValue"
|
87
|
+
@mapValueForDefault = 'mapValueForDefaultValue'
|
88
|
+
@noMapKeyDefault = 'noMapKeyDefault'
|
89
|
+
|
90
|
+
@map = MARCSpec::KVMap.new('nameOfTheMap', {@twosixtyCValue => @mapValue, @default=>@mapValueForDefault})
|
91
|
+
|
92
|
+
end
|
68
93
|
|
69
94
|
it "works with a KV Map and no defaults" do
|
70
95
|
@opts[:map] = @map
|
@@ -91,7 +116,7 @@ describe "SolrFieldSpec" do
|
|
91
116
|
sfs << @nonmatchingSpec
|
92
117
|
sfs.marc_values(@one).should.equal [@default]
|
93
118
|
end
|
94
|
-
|
119
|
+
|
95
120
|
it "returns multiple values from a kv map when appropriate" do
|
96
121
|
@map[@twosixtyCValue] = ['one', 'two']
|
97
122
|
@opts[:map] = @map
|
@@ -109,7 +134,7 @@ describe "SolrFieldSpec" do
|
|
109
134
|
sfs << @titleAC
|
110
135
|
sfs.marc_values(@one).sort.should.equal ['one', 'two', 'three', 'four'].sort
|
111
136
|
end
|
112
|
-
|
137
|
+
|
113
138
|
|
114
139
|
it "round trips if you add the map by hand" do
|
115
140
|
@opts[:map] = @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: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BillDueber
|