marc4j4r 0.1.6 → 0.2.2

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.
Files changed (54) hide show
  1. data/README.rdoc +17 -0
  2. data/Rakefile +26 -13
  3. data/VERSION +1 -1
  4. data/jars/marc4j.jar +0 -0
  5. data/lib/marc4j4r/controlfield.rb +32 -0
  6. data/lib/marc4j4r/datafield.rb +196 -0
  7. data/lib/marc4j4r/reader.rb +71 -0
  8. data/lib/marc4j4r/record.rb +214 -0
  9. data/lib/marc4j4r/writer.rb +29 -0
  10. data/lib/marc4j4r.rb +26 -485
  11. data/lib/original_monolithic_file.rb +518 -0
  12. data/spec/batch.dat +1 -0
  13. data/spec/batch.txt +193 -0
  14. data/spec/batch.xml +13 -0
  15. data/spec/controlfield_spec.rb +40 -0
  16. data/spec/datafield_spec.rb +56 -0
  17. data/spec/one.dat +1 -0
  18. data/spec/one.txt +17 -0
  19. data/spec/one.xml +4 -0
  20. data/spec/reader_spec.rb +49 -0
  21. data/spec/record_spec.rb +101 -0
  22. data/{test/helper.rb → spec/spec_helper.rb} +9 -5
  23. metadata +74 -80
  24. data/.document +0 -5
  25. data/.gitignore +0 -21
  26. data/README.markdown +0 -41
  27. data/doc/ControlFieldImpl.html +0 -314
  28. data/doc/DataFieldImpl.html +0 -875
  29. data/doc/Java/OrgMarc4j/MarcReader.html +0 -184
  30. data/doc/MARC4J4R/Reader.html +0 -245
  31. data/doc/MARC4J4R.html +0 -281
  32. data/doc/RecordImpl.html +0 -686
  33. data/doc/SubfieldImpl.html +0 -252
  34. data/doc/_index.html +0 -153
  35. data/doc/class_list.html +0 -36
  36. data/doc/css/common.css +0 -1
  37. data/doc/css/full_list.css +0 -50
  38. data/doc/css/style.css +0 -268
  39. data/doc/file.README.html +0 -90
  40. data/doc/file_list.html +0 -38
  41. data/doc/frames.html +0 -13
  42. data/doc/index.html +0 -90
  43. data/doc/js/app.js +0 -99
  44. data/doc/js/full_list.js +0 -106
  45. data/doc/js/jquery.js +0 -19
  46. data/doc/method_list.html +0 -219
  47. data/doc/top-level-namespace.html +0 -87
  48. data/jars/MarcImporter.jar +0 -0
  49. data/test/batch.seq +0 -118
  50. data/test/bench.rb +0 -63
  51. data/test/one.dat +0 -1
  52. data/test/one.seq +0 -30
  53. data/test/one.xml +0 -55
  54. data/test/test_marc4j4r.rb +0 -76
data/test/batch.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/test/bench.rb DELETED
@@ -1,63 +0,0 @@
1
- require 'rubygems'
2
- require '../lib/marc4j4r'
3
- require 'benchmark'
4
-
5
- filename = 'test.mrc'
6
- tags = %w(
7
- 245
8
- 035
9
- 100
10
- 010
11
- 001
12
- 050
13
- 300
14
- 600
15
- 856
16
- 260
17
- )
18
-
19
- Benchmark.bmbm do |x|
20
-
21
- x.report("0 tags; nohash") do
22
- reader = MARC4J4R.reader(filename)
23
- reader.each(false) do |r|
24
- tags.each do |t|
25
- # fields = r.find_by_tag(t, true)
26
- end
27
- end
28
- end
29
- x.report("0 tags; hash") do
30
- reader = MARC4J4R.reader(filename)
31
- reader.each do |r|
32
- tags.each do |t|
33
- # fields = r.find_by_tag(t, true)
34
- end
35
- end
36
- end
37
-
38
-
39
- (1..10).each do |i|
40
- x.report("#{tags.size * i} tags; nohash") do
41
- reader = MARC4J4R.reader(filename)
42
- reader.each(false) do |r|
43
- i.times do
44
- tags.each do |t|
45
- fields = r.find_by_tag(t, true)
46
- end
47
- end
48
- end
49
- end
50
- x.report("#{tags.size * i} tags; hash") do
51
- reader = MARC4J4R.reader(filename)
52
- reader.each do |r|
53
- i.times do
54
- tags.each do |t|
55
- fields = r.find_by_tag(t)
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
63
-
data/test/one.dat DELETED
@@ -1 +0,0 @@
1
- 00755cam 22002414a 4500001001300000003000600013005001700019008004100036010001700077020004300094040001800137042000800155050002600163082001700189100003100206245005400237260004200291300007200333500003300405650003700438630002500475630001300500fol05731351 IMchF20000613133448.0000107s2000 nyua 001 0 eng  a 00020737  a0471383147 (paper/cd-rom : alk. paper) aDLCcDLCdDLC apcc00aQA76.73.P22bM33 200000a005.13/32211 aMartinsson, Tobias,d1976-10aActivePerl with ASP and ADO /cTobias Martinsson. aNew York :bJohn Wiley & Sons,c2000. axxi, 289 p. :bill. ;c23 cm. +e1 computer laser disc (4 3/4 in.) a"Wiley Computer Publishing." 0aPerl (Computer program language)00aActive server pages.00aActiveX.
data/test/one.seq DELETED
@@ -1,30 +0,0 @@
1
- 006988435 LDR L 00000nam^a2200277Ia^4500
2
- 006988435 001 L 006988435
3
- 006988435 006 L m^^^^^^^^d^^^^^^^^
4
- 006988435 007 L cr^cn|||||||||
5
- 006988435 008 L 070103s2007^^^^nyu^^^^^sb^^^^001^0^eng^d
6
- 006988435 010 L $$z2007060391
7
- 006988435 020 L $$z9781403977564
8
- 006988435 035 L $$a(CaPaEBR)ebrtrial10194097
9
- 006988435 040 L $$aCaPaEBR$$cCaPaEBR$$dMiU
10
- 006988435 05014 L $$aPL207$$b.C39 2007eb
11
- 006988435 1001 L $$aÇayır, Kenan.
12
- 006988435 24510 L $$aIslamic literature in contemporary Turkey$$h[electronic resource]$$bfrom epic to novel /$$cKenan Çayır.
13
- 006988435 250 L $$a1st ed.
14
- 006988435 260 L $$aNew York :$$bPalgrave Macmillan,$$c2007.
15
- 006988435 504 L $$aIncludes bibliographical references (p. 189-198) and index.
16
- 006988435 650 0 L $$aIslamic literature, Turkish$$xHistory and criticism.
17
- 006988435 650 0 L $$aTurkish literature$$xHistory and criticism.
18
- 006988435 7102 L $$aebrary, Inc.
19
- 006988435 85640 L $$3Ann Arbor campus:$$zAccess to the ebrary online version restricted; authentication may be required:$$uhttp://site.ebrary.com/lib/umich/Doc?id=10194097
20
- 006988435 85640 L $$3Flint campus:$$zAccess to the ebrary online version restricted; authentication may be required:$$uhttp://libproxy.umflint.edu:2048/login?url=http://site.ebrary.com/lib/umich/Doc?id=10194097
21
- 006988435 8526 L $$aMiU$$bELEC$$hSee URL for access
22
- 006988435 8526 L $$aMiFliC$$bFLINT$$cELEC$$hSee URL for access
23
- 006988435 970 L $$aBK$$bBook
24
- 006988435 970 L $$aCE$$bElectronic Resource
25
- 006988435 971 L $$aMiU
26
- 006988435 971 L $$aMiFliC
27
- 006988435 972 L $$c20091022
28
- 006988435 972 L $$c20091022
29
- 006988435 973 L $$aAO$$bavail_online
30
- 006988435 998 L $$cebrary-dld ERLoad20091022
data/test/one.xml DELETED
@@ -1,55 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
3
- <record>
4
- <leader> njm a22 uu 4500</leader>
5
- <controlfield tag="001">afc99990058366</controlfield>
6
- <controlfield tag="003">DLC</controlfield>
7
- <controlfield tag="005">20071104155141.9</controlfield>
8
- <controlfield tag="007">sd ummunniauub</controlfield>
9
- <controlfield tag="008">071103s1939 xxufmnne||||||||| u eng||</controlfield>
10
- <datafield tag="010" ind1=" " ind2=" ">
11
- <subfield code="a">afc99990058366</subfield>
12
- </datafield>
13
- <datafield tag="040" ind1=" " ind2=" ">
14
- <subfield code="a">DLC</subfield>
15
- <subfield code="c">DLC</subfield>
16
- </datafield>
17
- <datafield tag="245" ind1="0" ind2="4">
18
- <subfield code="a">The Texas ranger</subfield>
19
- <subfield code="h">[sound recording] /</subfield>
20
- <subfield code="c">Sung by Beale D. Taylor.</subfield>
21
- </datafield>
22
- <datafield tag="260" ind1=" " ind2=" ">
23
- <subfield code="a">Medina, Texas,</subfield>
24
- <subfield code="c">1939.</subfield>
25
- </datafield>
26
- <datafield tag="300" ind1=" " ind2=" ">
27
- <subfield code="a">1 sound disc :</subfield>
28
- <subfield code="b">analog, 33 1/3 rpm, mono. ;</subfield>
29
- <subfield code="c">12 in.</subfield>
30
- </datafield>
31
- <datafield tag="651" ind1=" " ind2="0">
32
- <subfield code="a">Medina</subfield>
33
- <subfield code="z">Texas</subfield>
34
- <subfield code="z">United States of America.</subfield>
35
- </datafield>
36
- <datafield tag="700" ind1="1" ind2=" ">
37
- <subfield code="a">Lomax, John Avery, 1867-1948</subfield>
38
- <subfield code="e">Recording engineer.</subfield>
39
- </datafield>
40
- <datafield tag="700" ind1="1" ind2=" ">
41
- <subfield code="a">Lomax, Ruby T. (Ruby Terrill)</subfield>
42
- <subfield code="e">Recording engineer.</subfield>
43
- </datafield>
44
- <datafield tag="700" ind1="1" ind2=" ">
45
- <subfield code="a">Taylor, Beale D.</subfield>
46
- <subfield code="e">Singer.</subfield>
47
- </datafield>
48
- <datafield tag="852" ind1=" " ind2=" ">
49
- <subfield code="a">American Folklife Center, Library of Congress</subfield>
50
- </datafield>
51
- <datafield tag="852" ind1=" " ind2=" ">
52
- <subfield code="a">DLC</subfield>
53
- </datafield>
54
- </record>
55
- </collection>
@@ -1,76 +0,0 @@
1
- require 'helper'
2
-
3
- # one.xml
4
- # LEADER 00000njm a2200000uu 4500
5
- # 001 afc99990058366
6
- # 003 DLC
7
- # 005 20071104155141.9
8
- # 007 sd ummunniauub
9
- # 008 071103s1939 xxufmnne||||||||| u eng||
10
- # 010 $a afc99990058366
11
- # 040 $a DLC $c DLC
12
- # 245 04 $a The Texas ranger $h [sound recording] / $c Sung by Beale D. Taylor.
13
- # 260 $a Medina, Texas, $c 1939.
14
- # 300 $a 1 sound disc : $b analog, 33 1/3 rpm, mono. ; $c 12 in.
15
- # 651 0 $a Medina $z Texas $z United States of America.
16
- # 700 1 $a Lomax, John Avery, 1867-1948 $e Recording engineer.
17
- # 700 1 $a Lomax, Ruby T. (Ruby Terrill) $e Recording engineer.
18
- # 700 1 $a Taylor, Beale D. $e Singer.
19
- # 852 $a American Folklife Center, Library of Congress
20
- # 852 $a DLC
21
-
22
- class TestMarc4j4r < Test::Unit::TestCase
23
-
24
- def setup
25
- reader = MARC4J4R.reader(File.dirname(__FILE__) + '/one.xml', :marcxml)
26
- @r = reader.next
27
- end
28
-
29
- should "get the leader as a string" do
30
- assert_equal '00000njm a2200000uu 4500', @r.leader
31
- end
32
-
33
- should "get all fields with the given tag" do
34
- assert_equal 3, @r.find_by_tag('700').size
35
- end
36
-
37
- should "get all fields with any of the given tags" do
38
- assert_equal 6, @r.find_by_tag(['010','700', '852']).size
39
- end
40
-
41
- should "get an empty array trying to find a non-existent tag" do
42
- assert_equal [], @r.find_by_tag('002')
43
- end
44
-
45
- should "not return anything for a non-existent tag" do
46
- assert_equal 1, @r.find_by_tag(['010', '002']).size
47
- end
48
-
49
- should "get the value of a control tag" do
50
- assert_equal 'DLC', @r['003'].value
51
- end
52
-
53
- should "get a subfield value via field[]" do
54
- assert_equal 'Sung by Beale D. Taylor.', @r['245']['c']
55
- end
56
-
57
- should "joing all values of a field with a space" do
58
- assert_equal "DLC DLC", @r['040'].value
59
- end
60
-
61
- should "Get the first field with a given tag via []" do
62
- assert_equal '700 1 $a Lomax, John Avery, 1867-1948 $e Recording engineer.', @r['700'].to_s
63
- end
64
-
65
- should "get the subfield values in order of the original record" do
66
- assert_equal ['Medina, Texas,', '1939.'], @r['260'].sub_values(['a', 'c'])
67
- assert_equal ['Medina, Texas,', '1939.'], @r['260'].sub_values(['c', 'a'])
68
- end
69
-
70
- should "get the subfield values in order of the codes I pass" do
71
- assert_equal [ '1939.', 'Medina, Texas,'], @r['260'].sub_values(['c', 'a'], true)
72
- end
73
-
74
-
75
-
76
- end