marc4j4r 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- metadata +43 -65
- data/CHANGES +0 -27
- data/Rakefile +0 -71
- data/VERSION +0 -1
- data/benchj.rb +0 -73
- data/lib/marc4j4r.rb +0 -70
- data/lib/marc4j4r/controlfield.rb +0 -32
- data/lib/marc4j4r/datafield.rb +0 -192
- data/lib/marc4j4r/reader.rb +0 -125
- data/lib/marc4j4r/record.rb +0 -259
- data/lib/marc4j4r/writer.rb +0 -31
- data/spec/alephsequentialreader_spec.rb +0 -112
- data/spec/bad.dat +0 -1
- data/spec/badbatch.dat +0 -1
- data/spec/badbatch.xml +0 -13
- data/spec/batch.dat +0 -1
- data/spec/batch.txt +0 -193
- data/spec/batch.xml +0 -13
- data/spec/chinese_utf8.dat +0 -1
- data/spec/controlfield_spec.rb +0 -42
- data/spec/datafield_spec.rb +0 -122
- data/spec/errors.seq +0 -118
- data/spec/one.dat +0 -1
- data/spec/one.txt +0 -17
- data/spec/one.xml +0 -4
- data/spec/reader_spec.rb +0 -110
- data/spec/record_spec.rb +0 -146
- data/spec/spec_helper.rb +0 -14
- data/spec/three.seq +0 -118
data/spec/errors.seq
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
000004262 LDR L ^^^^^nam^a22003011^^4500
|
2
|
-
000004262 001 L 000004262
|
3
|
-
000004262 005 L 19891107000000.0
|
4
|
-
000004262 006 L m^^^^^^^^d^^^^^^^^
|
5
|
-
000004262 007 L cr^bn^---auaua
|
6
|
-
000004262 008 L 880715r19721939nyua^^^^^b^^^^00100^eng^^
|
7
|
-
000004262 010 L $$a72001885/MN
|
8
|
-
000004262 020 L $$a0306705133
|
9
|
-
000004262 035 L $$a(RLIN)MIUG0297757-B
|
10
|
-
000004262 035# L $$a(CaOTULAS)159822964
|
11
|
-
000004262 035 L $$a(OCoLC)ocm00297757
|
12
|
-
000004262 035 L $$asdr-inu1221428
|
13
|
-
000004262 040 # L $$aDLC$$cDLC$$dMiU
|
14
|
-
000004262 043 L $$an------
|
15
|
-
000004262 0500 L $$aML3557$$b.D3645 1972
|
16
|
-
000004262 082 L $$a784.7/51
|
17
|
-
000004262 1001 L $$aDensmore, Frances,$$d1867-1957.
|
18
|
-
000004262 24510 L $$aNootka and Quileute music.
|
19
|
-
000004262 260 L $$aNew York,$$bDa Capo Press,$$c1972.
|
20
|
-
000004262 300 L $$axxvi, 358 p.$$billus.$$c23 cm.
|
21
|
-
000004262 4900 L $$aDa Capo Press music reprint series
|
22
|
-
000004262 500 L $$aReprint of the 1939 ed., which was issued as Bulletin 124 of Smithsonian Institution. Bureau of American Ethnology.
|
23
|
-
000004262 504 L $$aBibliography: p. 349.
|
24
|
-
000004262 538 L $$aMode of access: Internet.
|
25
|
-
000004262 650 0 L $$aNootka Indians$$xMusic.
|
26
|
-
000004262 650 0 L $$aQuileute Indians$$xMusic.
|
27
|
-
000004262 8520 L $$aMiU$$bMUSIC$$hML3557 .D4255 1972
|
28
|
-
000004262 852 L $$ainu$$bSDR$$cINU
|
29
|
-
000004262 970 L $$aBK$$bBook
|
30
|
-
000004262 970 L $$aCE$$bElectronic Resource
|
31
|
-
000004262 971 L $$aMiU
|
32
|
-
000004262 972 L $$c20040625
|
33
|
-
000004262 973 L $$aHT$$bavail_ht
|
34
|
-
000004262 973 L $$aAC$$bavail_circ
|
35
|
-
000004262 974 L $$uinu.30000053901769$$ric$$d20100226
|
36
|
-
000004262 998 L $$s9665
|
37
|
-
000005951 LDR L ^^^^^nam^a22002771^^4500
|
38
|
-
000005951 001 L 000005951
|
39
|
-
000005951 005 L 19970922000000.0
|
40
|
-
000005951 006 L m^^^^^^^^d^^^^^^^^
|
41
|
-
000005951 007 L cr^bn^---auaua
|
42
|
-
000005951 008 L 880715s1968^^^^dcu^^^^^^b^^^|00010^eng^c
|
43
|
-
000005951 010 L ahew68000006
|
44
|
-
000005951 035 L $$a(RLIN)MIUG0425743-B
|
45
|
-
000005951 035 L $$a(CaOTULAS)159824865
|
46
|
-
000005951 035 L $$a(OCoLC)ocm00425743
|
47
|
-
000005951 035 L $$asdr-ucsc.b16458175
|
48
|
-
000005951 040 L $$a*U.S. Dept. of Health Education, and Welfare. Li$$cDLC$$dMiU
|
49
|
-
000005951 0500 L $$aHD7123$$b.A39 no. 22
|
50
|
-
000005951 082 L $$a301.5/5
|
51
|
-
000005951 1001 L $$aKreps, Juanita Morris.
|
52
|
-
000005951 24510 L $$aLifetime allocation of work and leisure,$$cby Juanita M. Kreps.
|
53
|
-
000005951 260 L $$a[Washington,$$bFor sale by Supt. of Docs., U.S. Govt. Print. Off.,$$c1968]
|
54
|
-
000005951 300 L $$aix, 44 p.$$c24 cm.
|
55
|
-
000005951 4901 L $$aUnited States. Social Security Administration. Office of Research and Statistics. Research report$$vno. 22
|
56
|
-
000005951 504 L $$aBibliographical footnotes.
|
57
|
-
000005951 538 L $$aMode of access: Internet.
|
58
|
-
000005951 650 0 L $$aAge and employment
|
59
|
-
000005951 650 0 L $$aRetirement
|
60
|
-
000005951 830 0 L $$aResearch report (United States. Social Security Administration. Office of Research and Statistics) ;$$vno. 22
|
61
|
-
000005951 8520 L $$aMiU$$bTAUB$$hHD6279 .K925
|
62
|
-
000005951 8520 L $$aMiU$$bTAUB$$hHD 7123 .A28 no.22
|
63
|
-
000005951 8520 L $$aMiU$$bBUHR$$cGRAD$$hHD 7123 .A28 no.22
|
64
|
-
000005951 852 L $$auc1$$bSDR$$cUCSC
|
65
|
-
000005951 970 L $$aBK$$bBook
|
66
|
-
000005951 970 L $$aCE$$bElectronic Resource
|
67
|
-
000005951 971 L $$aMiU
|
68
|
-
000005951 972 L $$c20040625
|
69
|
-
000005951 972 L $$c20040625
|
70
|
-
000005951 972 L $$c20040625
|
71
|
-
000005951 973 L $$aHT$$bavail_ht
|
72
|
-
000005951 973 L $$aAC$$bavail_circ
|
73
|
-
000005951 974 L $$umdp.39015038814847$$ric
|
74
|
-
000005951 974 L $$umdp.39015072105847$$ric$$d20091001
|
75
|
-
000005951 974 L $$zno.22$$uuc1.32106000924198$$ric$$d20091202
|
76
|
-
000005951 998 L $$s9665
|
77
|
-
000009811 LDR L ^^^^^nam^a22003251^^4500
|
78
|
-
000009811 001 L 000009811
|
79
|
-
000009811 005 L 19970922000000.0
|
80
|
-
000009811 006 L m^^^^^^^^d^^^^^^^^
|
81
|
-
000009811 007 L cr^bn^---auaua
|
82
|
-
000009811 008 L 880715s1971^^^^dcua^^^^^bs^^^00000^eng^^
|
83
|
-
000009811 010 L $$a72179703
|
84
|
-
000009811 035 L $$a(RLIN)MIUG0695316-B
|
85
|
-
000009811 035 L $$a(CaOTULAS)159829127
|
86
|
-
000009811 035 L $$a(OCoLC)ocm00695316
|
87
|
-
000009811 035 L $$asdr-ucsc.b13985097
|
88
|
-
000009811 040 L $$aDLC$$cDLC$$dMiU$$dCStRLIN
|
89
|
-
000009811 043 L $$an-us---
|
90
|
-
000009811 0500 L $$aHD7123$$b.A39 no. 37$$aHD7102.U4
|
91
|
-
000009811 082 L $$a368.4/00973 s$$a368.4/2/00973
|
92
|
-
000009811 086 L $$aII0 aHE 3.49:37
|
93
|
-
000009811 1101 L $$aUnited States.$$bSocial Security Administration.$$bOffice of Research and Statistics.
|
94
|
-
000009811 24510 L $$aFinancing mental health care under medicare and medicaid.
|
95
|
-
000009811 260 L $$a[Washington;$$bFor sale by the Supt. of Docs., U.S. Govt. Print. Off.,$$c1971]
|
96
|
-
000009811 300 L $$avii, 52 p.$$billus.$$c27 cm.
|
97
|
-
000009811 4901 L $$aIts Research report$$vno. 37
|
98
|
-
000009811 500 L $$aSupt. of Docs. no.: HE 3.49:37
|
99
|
-
000009811 504 L $$aIncludes bibliographical references.
|
100
|
-
000009811 538 L $$aMode of access: Internet.
|
101
|
-
000009811 650 0 L $$aMental health insurance$$zUnited States.
|
102
|
-
000009811 650 0 L $$aMedicare
|
103
|
-
000009811 650 0 L $$aMedicaid
|
104
|
-
000009811 830 0 L $$aResearch report (United States. Social Security Administration. Office of Research and Statistics) ;$$vno. 37
|
105
|
-
000009811 8520 L $$aMiU$$bBUHR$$cGRAD$$hHD 7123 .A28 no.37
|
106
|
-
000009811 8520 L $$aMiU$$bTAUB$$hHD 7123 .A28 no.37
|
107
|
-
000009811 852 L $$auc1$$bSDR$$cUCSC
|
108
|
-
000009811 970 L $$aBK$$bBook
|
109
|
-
000009811 970 L $$aCE$$bElectronic Resource
|
110
|
-
000009811 970 L $$aXS$$bStatistics
|
111
|
-
000009811 971 L $$aMiU
|
112
|
-
000009811 972 L $$c20040625
|
113
|
-
000009811 972 L $$c20040625
|
114
|
-
000009811 973 L $$aHT$$bavail_ht
|
115
|
-
000009811 973 L $$aAC$$bavail_circ
|
116
|
-
000009811 974 L $$zno.37$$umdp.39015004063635$$ric
|
117
|
-
000009811 974 L $$zno.37$$uuc1.32106000924313$$ric$$d20091202
|
118
|
-
000009811 998 L $$s9665
|
data/spec/one.dat
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
00734njm a2200217uu 4500001001500000003000400015005001700019007001500036008004100051010001900092040001300111245006800124260002600192300005600218651004500274700005400319700005500373700003000428852005000458852000800508afc99990058366DLC20071104155141.9sd ummunniauub071103s1939 xxufmnne||||||||| u eng|| aafc99990058366 aDLCcDLC04aThe Texas rangerh[sound recording] /cSung by Beale D. Taylor. aMedina, Texas,c1939. a1 sound disc :banalog, 33 1/3 rpm, mono. ;c12 in. 0aMedinazTexaszUnited States of America.1 aLomax, John Avery, 1867-1948eRecording engineer.1 aLomax, Ruby T. (Ruby Terrill)eRecording engineer.1 aTaylor, Beale D.eSinger. aAmerican Folklife Center, Library of Congress aDLC
|
data/spec/one.txt
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
LEADER 00734njm a2200217uu 4500
|
2
|
-
001 afc99990058366
|
3
|
-
003 DLC
|
4
|
-
005 20071104155141.9
|
5
|
-
007 sd ummunniauub
|
6
|
-
008 071103s1939 xxufmnne||||||||| u eng||
|
7
|
-
010 $a afc99990058366
|
8
|
-
040 $a DLC $c DLC
|
9
|
-
245 04 $a The Texas ranger $h [sound recording] / $c Sung by Beale D. Taylor.
|
10
|
-
260 $a Medina, Texas, $c 1939.
|
11
|
-
300 $a 1 sound disc : $b analog, 33 1/3 rpm, mono. ; $c 12 in.
|
12
|
-
651 0 $a Medina $z Texas $z United States of America.
|
13
|
-
700 1 $a Lomax, John Avery, 1867-1948 $e Recording engineer.
|
14
|
-
700 1 $a Lomax, Ruby T. (Ruby Terrill) $e Recording engineer.
|
15
|
-
700 1 $a Taylor, Beale D. $e Singer.
|
16
|
-
852 $a American Folklife Center, Library of Congress
|
17
|
-
852 $a DLC
|
data/spec/one.xml
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
<?xml version='1.0'?>
|
2
|
-
<collection xmlns='http://www.loc.gov/MARC21/slim' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd'>
|
3
|
-
<record><leader>00734njm a2200217uu 4500</leader><controlfield tag='001'>afc99990058366</controlfield><controlfield tag='003'>DLC</controlfield><controlfield tag='005'>20071104155141.9</controlfield><controlfield tag='007'>sd ummunniauub</controlfield><controlfield tag='008'>071103s1939 xxufmnne||||||||| u eng||</controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'>afc99990058366</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='245' ind1='0' ind2='4'><subfield code='a'>The Texas ranger</subfield><subfield code='h'>[sound recording] /</subfield><subfield code='c'>Sung by Beale D. Taylor.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Medina, Texas,</subfield><subfield code='c'>1939.</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>1 sound disc :</subfield><subfield code='b'>analog, 33 1/3 rpm, mono. ;</subfield><subfield code='c'>12 in.</subfield></datafield><datafield tag='651' ind1=' ' ind2='0'><subfield code='a'>Medina</subfield><subfield code='z'>Texas</subfield><subfield code='z'>United States of America.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Lomax, John Avery, 1867-1948</subfield><subfield code='e'>Recording engineer.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Lomax, Ruby T. (Ruby Terrill)</subfield><subfield code='e'>Recording engineer.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Taylor, Beale D.</subfield><subfield code='e'>Singer.</subfield></datafield><datafield tag='852' ind1=' ' ind2=' '><subfield code='a'>American Folklife Center, Library of Congress</subfield></datafield><datafield tag='852' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield></datafield></record>
|
4
|
-
</collection>
|
data/spec/reader_spec.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "MARC4J4R_reader" do
|
4
|
-
it "can read binary" do
|
5
|
-
reader = MARC4J4R::Reader.new("#{DIR}/one.dat")
|
6
|
-
rec = reader.first
|
7
|
-
rec['245']['a'].should.equal "The Texas ranger"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "can read XML" do
|
11
|
-
reader = MARC4J4R::Reader.new("#{DIR}/one.xml", :marcxml)
|
12
|
-
rec = reader.first
|
13
|
-
rec['245']['a'].should.equal "The Texas ranger"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "enumerates through all binary records" do
|
17
|
-
reader = MARC4J4R::Reader.new("#{DIR}/batch.dat")
|
18
|
-
recs = reader.collect
|
19
|
-
recs.size.should.equal 10
|
20
|
-
end
|
21
|
-
|
22
|
-
it "enumerates through all XML records" do
|
23
|
-
reader = MARC4J4R::Reader.new("#{DIR}/batch.xml", :marcxml)
|
24
|
-
recs = reader.collect
|
25
|
-
recs.size.should.equal 10
|
26
|
-
end
|
27
|
-
|
28
|
-
it "Bails if passed an illegal type" do
|
29
|
-
lambda{reader = MARC4J4R::Reader.new("#{DIR}/batch.xml", :marc)}.should.raise(ArgumentError).message.should.match(/^Reader type/)
|
30
|
-
end
|
31
|
-
it "Bails if passed an illegal encoding" do
|
32
|
-
lambda{reader = MARC4J4R::Reader.new("#{DIR}/batch.xml", :strictmarc, :utf)}.should.raise(ArgumentError).message.should.match(/^Encoding/)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "Reader encodings, strict reader" do
|
37
|
-
it "Works with UTF-8 without explicit encoding" do
|
38
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat")
|
39
|
-
r = reader.first
|
40
|
-
second_title = r.find_by_tag('245')[1]
|
41
|
-
second_title['a'].should.equal "湘鄂贛苏区史稿 /"
|
42
|
-
end
|
43
|
-
it "Works with UTF-8, explicit encoding" do
|
44
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :strictmarc, :utf8)
|
45
|
-
r = reader.first
|
46
|
-
second_title = r.find_by_tag('245')[1]
|
47
|
-
second_title['a'].should.equal "湘鄂贛苏区史稿 /"
|
48
|
-
end
|
49
|
-
it "Fails with UTF-8, wrong explicit encoding" do
|
50
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :strictmarc, :marc8)
|
51
|
-
r = reader.first
|
52
|
-
second_title = r.find_by_tag('245')[1]
|
53
|
-
second_title['a'].should.not.equal "湘鄂贛苏区史稿 /"
|
54
|
-
end
|
55
|
-
it "Fails with UTF-8, wrong explicit encoding" do
|
56
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :strictmarc, :iso)
|
57
|
-
r = reader.first
|
58
|
-
second_title = r.find_by_tag('245')[1]
|
59
|
-
second_title['a'].should.not.equal "湘鄂贛苏区史稿 /"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "Reader encodings, permissive reader" do
|
64
|
-
|
65
|
-
|
66
|
-
it "Works with UTF-8 without explicit encoding" do
|
67
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :permissivemarc)
|
68
|
-
r = reader.first
|
69
|
-
second_title = r.find_by_tag('245')[1]
|
70
|
-
second_title['a'].should.equal "湘鄂贛苏区史稿 /"
|
71
|
-
end
|
72
|
-
it "Works with UTF-8, explicit encoding" do
|
73
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :permissivemarc, :utf8)
|
74
|
-
r = reader.first
|
75
|
-
second_title = r.find_by_tag('245')[1]
|
76
|
-
second_title['a'].should.equal "湘鄂贛苏区史稿 /"
|
77
|
-
end
|
78
|
-
it "Fails with UTF-8, wrong explicit encoding" do
|
79
|
-
reader = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat", :permissivemarc, :iso)
|
80
|
-
r = reader.first
|
81
|
-
second_title = r.find_by_tag('245')[1]
|
82
|
-
second_title['a'].should.equal "湘鄂贛苏区史稿 /" # equal, because it's permissive and tries to do the right thing
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
describe "Reader round-tripping" do
|
92
|
-
before do
|
93
|
-
@one = MARC4J4R::Reader.new("#{DIR}/one.dat").first
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should round-trip binary" do
|
97
|
-
rt = MARC4J4R::Reader.new(StringIO.new(@one.to_marc)).first
|
98
|
-
rt.should.equal @one
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should round-trip xml" do
|
102
|
-
rt = MARC4J4R::Reader.new(StringIO.new(@one.to_xml), :marcxml).first
|
103
|
-
rt.should.equal @one
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should show xml and binary forms equal after parsing" do
|
107
|
-
rt = MARC4J4R::Reader.new("#{DIR}/one.xml", :marcxml).first
|
108
|
-
rt.should.equal @one
|
109
|
-
end
|
110
|
-
end
|
data/spec/record_spec.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# LEADER 00734njm a2200217uu 4500
|
4
|
-
# 001 afc99990058366
|
5
|
-
# 003 DLC
|
6
|
-
# 005 20071104155141.9
|
7
|
-
# 007 sd ummunniauub
|
8
|
-
# 008 071103s1939 xxufmnne||||||||| u eng||
|
9
|
-
# 010 $a afc99990058366
|
10
|
-
# 040 $a DLC $c DLC
|
11
|
-
# 245 04 $a The Texas ranger $h [sound recording] / $c Sung by Beale D. Taylor.
|
12
|
-
# 260 $a Medina, Texas, $c 1939.
|
13
|
-
# 300 $a 1 sound disc : $b analog, 33 1/3 rpm, mono. ; $c 12 in.
|
14
|
-
# 651 0 $a Medina $z Texas $z United States of America.
|
15
|
-
# 700 1 $a Lomax, John Avery, 1867-1948 $e Recording engineer.
|
16
|
-
# 700 1 $a Lomax, Ruby T. (Ruby Terrill) $e Recording engineer.
|
17
|
-
# 700 1 $a Taylor, Beale D. $e Singer.
|
18
|
-
# 852 $a American Folklife Center, Library of Congress
|
19
|
-
# 852 $a DLC
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
describe "MARC4J4R_basic_retrieval_stuff" do
|
26
|
-
before do
|
27
|
-
@one = MARC4J4R::Reader.new("#{DIR}/one.dat").first
|
28
|
-
@batch = MARC4J4R::Reader.new("#{DIR}/batch.dat").collect
|
29
|
-
end
|
30
|
-
|
31
|
-
it "can get the leader" do
|
32
|
-
@one.leader.should.equal "00734njm a2200217uu 4500"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "can set the leader" do
|
36
|
-
@one.leader = "00734njm 2200217uu 4500"
|
37
|
-
@one.leader.should.equal "00734njm 2200217uu 4500"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "disallows bad leaders" do
|
41
|
-
lambda{
|
42
|
-
@one.leader = 'Hello World'
|
43
|
-
}.should.raise RuntimeError
|
44
|
-
end
|
45
|
-
|
46
|
-
it "can read a control field correctly" do
|
47
|
-
@one['001'].value.should.equal "afc99990058366"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "can find all the fields" do
|
51
|
-
fields = @one.collect {|a| a}
|
52
|
-
fields.size.should.equal 16
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should get the first 245 for this record" do
|
56
|
-
@one['245'].to_s.should.equal "245 04 $a The Texas ranger $h [sound recording] / $c Sung by Beale D. Taylor."
|
57
|
-
end
|
58
|
-
|
59
|
-
it "finds nothing when there's nothign there" do
|
60
|
-
@one['035'].should.equal nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "MARC4J4R::Record #find_by_tag" do
|
65
|
-
before do
|
66
|
-
@one = MARC4J4R::Reader.new("#{DIR}/one.dat").first
|
67
|
-
@df = MARC4J4R::DataField.new('260')
|
68
|
-
@df << MARC4J4R::SubField.new('a', 'Medina, Texas,')
|
69
|
-
@df << MARC4J4R::SubField.new('c', '1939.')
|
70
|
-
|
71
|
-
@cf = MARC4J4R::ControlField.new('005', '20071104155141.9')
|
72
|
-
|
73
|
-
@batch = MARC4J4R::Reader.new("#{DIR}/batch.dat").collect
|
74
|
-
@utf8 = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat").first
|
75
|
-
end
|
76
|
-
|
77
|
-
it "gets an empty array for non-existant tag(s)" do
|
78
|
-
@one.find_by_tag('999').should.equal []
|
79
|
-
end
|
80
|
-
|
81
|
-
it "gets an empty arry for set of non-existant tags" do
|
82
|
-
@one.find_by_tag(['998', '999']).should.equal []
|
83
|
-
end
|
84
|
-
|
85
|
-
it "gets a single field for the 260 as string" do
|
86
|
-
onetag = @one.find_by_tag('260')
|
87
|
-
onetag.should.equal [@df]
|
88
|
-
end
|
89
|
-
|
90
|
-
it "gets a single field for the 260 as an array" do
|
91
|
-
onetag = @one.find_by_tag('260')
|
92
|
-
@one.find_by_tag(['260']).should.equal [@df]
|
93
|
-
end
|
94
|
-
|
95
|
-
it "gets both the 260 and 005" do
|
96
|
-
@one.find_by_tag(['005', '260']).should.equal [@cf, @df]
|
97
|
-
end
|
98
|
-
|
99
|
-
it "returns fields in the order their tags were requested" do
|
100
|
-
@one.find_by_tag(['260', '005']).should.equal [@df, @cf]
|
101
|
-
end
|
102
|
-
|
103
|
-
it "allows caller to force return of tags in original order" do
|
104
|
-
@one.find_by_tag(['260', '005'], true).should.equal [@cf, @df]
|
105
|
-
end
|
106
|
-
|
107
|
-
it "finds all instances of requested tags" do
|
108
|
-
@one.find_by_tag('700').size.should.equal 3
|
109
|
-
@one.find_by_tag('852').size.should.equal 2
|
110
|
-
@one.find_by_tag(['852', '700']).size.should.equal 5
|
111
|
-
end
|
112
|
-
|
113
|
-
it "returns duplicate-tag fields in the order from the record" do
|
114
|
-
first = @one['700']
|
115
|
-
@one.find_by_tag('700')[0].should.equal first
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "Format checks" do
|
121
|
-
before do
|
122
|
-
@one = MARC4J4R::Reader.new("#{DIR}/one.dat").first
|
123
|
-
@batch = MARC4J4R::Reader.new("#{DIR}/batch.dat").collect {|a| a}
|
124
|
-
@utf8 = MARC4J4R::Reader.new("#{DIR}/chinese_utf8.dat").first
|
125
|
-
end
|
126
|
-
|
127
|
-
it "round trips binary" do
|
128
|
-
MARC4J4R::Record.from_string(@one.to_marc).should.equal @one
|
129
|
-
@batch.each do |r|
|
130
|
-
MARC4J4R::Record.from_string(r.to_marc).should.equal r
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
it "round trips utf8 record as binary" do
|
135
|
-
MARC4J4R::Record.from_string(@utf8.to_marc, :utf8).should.equal @utf8
|
136
|
-
end
|
137
|
-
|
138
|
-
it "round trips XML" do
|
139
|
-
MARC4J4R::Record.from_xml_string(@one.to_xml).should.equal @one
|
140
|
-
end
|
141
|
-
|
142
|
-
it "round trips marc-in-json" do
|
143
|
-
copy = @one.to_marc_in_json
|
144
|
-
MARC4J4R::Record.new_from_marc_in_json(copy).should.equal @one
|
145
|
-
end
|
146
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bacon'
|
3
|
-
begin
|
4
|
-
require 'greeneggs'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
-
require 'marc4j4r'
|
11
|
-
DIR = File.dirname(__FILE__)
|
12
|
-
|
13
|
-
|
14
|
-
Bacon.summary_on_exit
|
data/spec/three.seq
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
000004262 LDR L ^^^^^nam^a22003011^^4500
|
2
|
-
000004262 001 L 000004262
|
3
|
-
000004262 005 L 19891107000000.0
|
4
|
-
000004262 006 L m^^^^^^^^d^^^^^^^^
|
5
|
-
000004262 007 L cr^bn^---auaua
|
6
|
-
000004262 008 L 880715r19721939nyua^^^^^b^^^^00100^eng^^
|
7
|
-
000004262 010 L $$a72001885/MN
|
8
|
-
000004262 020 L $$a0306705133
|
9
|
-
000004262 035 L $$a(RLIN)MIUG0297757-B
|
10
|
-
000004262 035 L $$a(CaOTULAS)159822964
|
11
|
-
000004262 035 L $$a(OCoLC)ocm00297757
|
12
|
-
000004262 035 L $$asdr-inu1221428
|
13
|
-
000004262 040 L $$aDLC$$cDLC$$dMiU
|
14
|
-
000004262 043 L $$an------
|
15
|
-
000004262 0500 L $$aML3557$$b.D3645 1972
|
16
|
-
000004262 082 L $$a784.7/51
|
17
|
-
000004262 1001 L $$aDensmore, Frances,$$d1867-1957.
|
18
|
-
000004262 24510 L $$aNootka and Quileute music.
|
19
|
-
000004262 260 L $$aNew York,$$bDa Capo Press,$$c1972.
|
20
|
-
000004262 300 L $$axxvi, 358 p.$$billus.$$c23 cm.
|
21
|
-
000004262 4900 L $$aDa Capo Press music reprint series
|
22
|
-
000004262 500 L $$aReprint of the 1939 ed., which was issued as Bulletin 124 of Smithsonian Institution. Bureau of American Ethnology.
|
23
|
-
000004262 504 L $$aBibliography: p. 349.
|
24
|
-
000004262 538 L $$aMode of access: Internet.
|
25
|
-
000004262 650 0 L $$aNootka Indians$$xMusic.
|
26
|
-
000004262 650 0 L $$aQuileute Indians$$xMusic.
|
27
|
-
000004262 8520 L $$aMiU$$bMUSIC$$hML3557 .D4255 1972
|
28
|
-
000004262 852 L $$ainu$$bSDR$$cINU
|
29
|
-
000004262 970 L $$aBK$$bBook
|
30
|
-
000004262 970 L $$aCE$$bElectronic Resource
|
31
|
-
000004262 971 L $$aMiU
|
32
|
-
000004262 972 L $$c20040625
|
33
|
-
000004262 973 L $$aHT$$bavail_ht
|
34
|
-
000004262 973 L $$aAC$$bavail_circ
|
35
|
-
000004262 974 L $$uinu.30000053901769$$ric$$d20100226
|
36
|
-
000004262 998 L $$s9665
|
37
|
-
000005951 LDR L ^^^^^nam^a22002771^^4500
|
38
|
-
000005951 001 L 000005951
|
39
|
-
000005951 005 L 19970922000000.0
|
40
|
-
000005951 006 L m^^^^^^^^d^^^^^^^^
|
41
|
-
000005951 007 L cr^bn^---auaua
|
42
|
-
000005951 008 L 880715s1968^^^^dcu^^^^^^b^^^|00010^eng^c
|
43
|
-
000005951 010 L $$ahew68000006
|
44
|
-
000005951 035 L $$a(RLIN)MIUG0425743-B
|
45
|
-
000005951 035 L $$a(CaOTULAS)159824865
|
46
|
-
000005951 035 L $$a(OCoLC)ocm00425743
|
47
|
-
000005951 035 L $$asdr-ucsc.b16458175
|
48
|
-
000005951 040 L $$a*U.S. Dept. of Health Education, and Welfare. Li$$cDLC$$dMiU
|
49
|
-
000005951 0500 L $$aHD7123$$b.A39 no. 22
|
50
|
-
000005951 082 L $$a301.5/5
|
51
|
-
000005951 1001 L $$aKreps, Juanita Morris.
|
52
|
-
000005951 24510 L $$aLifetime allocation of work and leisure,$$cby Juanita M. Kreps.
|
53
|
-
000005951 260 L $$a[Washington,$$bFor sale by Supt. of Docs., U.S. Govt. Print. Off.,$$c1968]
|
54
|
-
000005951 300 L $$aix, 44 p.$$c24 cm.
|
55
|
-
000005951 4901 L $$aUnited States. Social Security Administration. Office of Research and Statistics. Research report$$vno. 22
|
56
|
-
000005951 504 L $$aBibliographical footnotes.
|
57
|
-
000005951 538 L $$aMode of access: Internet.
|
58
|
-
000005951 650 0 L $$aAge and employment
|
59
|
-
000005951 650 0 L $$aRetirement
|
60
|
-
000005951 830 0 L $$aResearch report (United States. Social Security Administration. Office of Research and Statistics) ;$$vno. 22
|
61
|
-
000005951 8520 L $$aMiU$$bTAUB$$hHD6279 .K925
|
62
|
-
000005951 8520 L $$aMiU$$bTAUB$$hHD 7123 .A28 no.22
|
63
|
-
000005951 8520 L $$aMiU$$bBUHR$$cGRAD$$hHD 7123 .A28 no.22
|
64
|
-
000005951 852 L $$auc1$$bSDR$$cUCSC
|
65
|
-
000005951 970 L $$aBK$$bBook
|
66
|
-
000005951 970 L $$aCE$$bElectronic Resource
|
67
|
-
000005951 971 L $$aMiU
|
68
|
-
000005951 972 L $$c20040625
|
69
|
-
000005951 972 L $$c20040625
|
70
|
-
000005951 972 L $$c20040625
|
71
|
-
000005951 973 L $$aHT$$bavail_ht
|
72
|
-
000005951 973 L $$aAC$$bavail_circ
|
73
|
-
000005951 974 L $$umdp.39015038814847$$ric
|
74
|
-
000005951 974 L $$umdp.39015072105847$$ric$$d20091001
|
75
|
-
000005951 974 L $$zno.22$$uuc1.32106000924198$$ric$$d20091202
|
76
|
-
000005951 998 L $$s9665
|
77
|
-
000009811 LDR L ^^^^^nam^a22003251^^4500
|
78
|
-
000009811 001 L 000009811
|
79
|
-
000009811 005 L 19970922000000.0
|
80
|
-
000009811 006 L m^^^^^^^^d^^^^^^^^
|
81
|
-
000009811 007 L cr^bn^---auaua
|
82
|
-
000009811 008 L 880715s1971^^^^dcua^^^^^bs^^^00000^eng^^
|
83
|
-
000009811 010 L $$a72179703
|
84
|
-
000009811 035 L $$a(RLIN)MIUG0695316-B
|
85
|
-
000009811 035 L $$a(CaOTULAS)159829127
|
86
|
-
000009811 035 L $$a(OCoLC)ocm00695316
|
87
|
-
000009811 035 L $$asdr-ucsc.b13985097
|
88
|
-
000009811 040 L $$aDLC$$cDLC$$dMiU$$dCStRLIN
|
89
|
-
000009811 043 L $$an-us---
|
90
|
-
000009811 0500 L $$aHD7123$$b.A39 no. 37$$aHD7102.U4
|
91
|
-
000009811 082 L $$a368.4/00973 s$$a368.4/2/00973
|
92
|
-
000009811 086 L $$aII0 aHE 3.49:37
|
93
|
-
000009811 1101 L $$aUnited States.$$bSocial Security Administration.$$bOffice of Research and Statistics.
|
94
|
-
000009811 24510 L $$aFinancing mental health care under medicare and medicaid.
|
95
|
-
000009811 260 L $$a[Washington;$$bFor sale by the Supt. of Docs., U.S. Govt. Print. Off.,$$c1971]
|
96
|
-
000009811 300 L $$avii, 52 p.$$billus.$$c27 cm.
|
97
|
-
000009811 4901 L $$aIts Research report$$vno. 37
|
98
|
-
000009811 500 L $$aSupt. of Docs. no.: HE 3.49:37
|
99
|
-
000009811 504 L $$aIncludes bibliographical references.
|
100
|
-
000009811 538 L $$aMode of access: Internet.
|
101
|
-
000009811 650 0 L $$aMental health insurance$$zUnited States.
|
102
|
-
000009811 650 0 L $$aMedicare
|
103
|
-
000009811 650 0 L $$aMedicaid
|
104
|
-
000009811 830 0 L $$aResearch report (United States. Social Security Administration. Office of Research and Statistics) ;$$vno. 37
|
105
|
-
000009811 8520 L $$aMiU$$bBUHR$$cGRAD$$hHD 7123 .A28 no.37
|
106
|
-
000009811 8520 L $$aMiU$$bTAUB$$hHD 7123 .A28 no.37
|
107
|
-
000009811 852 L $$auc1$$bSDR$$cUCSC
|
108
|
-
000009811 970 L $$aBK$$bBook
|
109
|
-
000009811 970 L $$aCE$$bElectronic Resource
|
110
|
-
000009811 970 L $$aXS$$bStatistics
|
111
|
-
000009811 971 L $$aMiU
|
112
|
-
000009811 972 L $$c20040625
|
113
|
-
000009811 972 L $$c20040625
|
114
|
-
000009811 973 L $$aHT$$bavail_ht
|
115
|
-
000009811 973 L $$aAC$$bavail_circ
|
116
|
-
000009811 974 L $$zno.37$$umdp.39015004063635$$ric
|
117
|
-
000009811 974 L $$zno.37$$uuc1.32106000924313$$ric$$d20091202
|
118
|
-
000009811 998 L $$s9665
|