marc4j4r 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,16 @@
1
+ 1.0
2
+ Arbitrary decision that this is 1.0
3
+ Using javamarc.jar (fork of marc4j) from http://github.com/billdueber/javamarc
4
+ Including alephsequential reader (but not writer) and specs
5
+ Added code to Reader#each to deal with #errors object if provided by the
6
+ specific reader (right now, :permissivemarc and :alephsequential) and specs
7
+ to test
8
+ Added lots of specs
9
+ Fixed definition of class-level methods in Record. For some reason (I'm sure having to do with the
10
+ fact that they're aliased java classes), using 'def self.to_xml' doesn't work; need to use
11
+ 'def Record.to_xml' instead
12
+ 0.9.1
13
+ Updated to latest marc4j; changes involve character conversion
14
+
15
+ 0.9.0
16
+ First real public release
data/README.rdoc CHANGED
@@ -15,7 +15,9 @@ links for all the classes:
15
15
 
16
16
  == Getting a MARC reader
17
17
 
18
- marc4j4r provides three readers out of the box: :strictmarc (binary), :permissivemarc (:binary), and :marcxml (MARC-XML).
18
+ marc4j4r provides three readers out of the box: :strictmarc (binary), :permissivemarc (:binary), :marcxml (MARC-XML),
19
+ or :alephsequential (Ex Libris's AlephSequential format).
20
+
19
21
  You can pass either a filename or an open IO object (either ruby or java.io.inputstream)
20
22
 
21
23
  require 'marc4j4r'
@@ -26,6 +28,7 @@ You can pass either a filename or an open IO object (either ruby or java.io.inpu
26
28
  permissivereader = MARC4J4R::Reader.new('test.mrc', :permissivemarc)
27
29
 
28
30
  xmlreader = MARC4J4R::Reader.new('test.xml', :marcxml)
31
+ asreader = MARC4J4R::Reader.new('test.seq', :alephsequential)
29
32
 
30
33
  # Or use a file object
31
34
 
data/Rakefile CHANGED
@@ -23,8 +23,8 @@ end
23
23
 
24
24
 
25
25
  # Make sure we've got the right .jar
26
- LOCALJAR = 'jars/marc4j.jar'
27
- JAVAJAR = '../../marc4j.jar'
26
+ LOCALJAR = 'jars/javamarc.jar'
27
+ JAVAJAR = '../../javamarc.jar'
28
28
 
29
29
 
30
30
  file LOCALJAR => JAVAJAR do |t|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 1.0.0
Binary file
@@ -22,7 +22,7 @@ module MARC4J4R
22
22
  # @param [String] The pretty string
23
23
  def to_s
24
24
  return self.tag + " " + self.value
25
- end
25
+ end
26
26
 
27
27
  def == other
28
28
  self.tag == other.tag && self.value == other.value
@@ -13,11 +13,7 @@ module MARC4J4R
13
13
 
14
14
  alias_method :oldinit, :initialize
15
15
  def initialize(tag = nil, ind1 = ' ', ind2 = ' ')
16
- if tag
17
- self.oldinit(tag, ind1[0].ord, ind2[0].ord)
18
- else
19
- self.oldinit
20
- end
16
+ self.oldinit(tag, ind1[0].ord, ind2[0].ord)
21
17
  end
22
18
 
23
19
  def controlField?
@@ -91,7 +87,7 @@ module MARC4J4R
91
87
  end
92
88
 
93
89
  # Is it a singleton?
94
- if not [Set, Array].include? code.class
90
+ unless code.is_a? Array
95
91
  code = [code]
96
92
  end
97
93
 
@@ -1,10 +1,33 @@
1
+ import 'org.marc4j.ErrorHandler'
2
+ require 'logger'
3
+ $LOG ||= Logger.new(STDERR)
4
+
1
5
  module Java::OrgMarc4j::MarcReader
2
6
  include Enumerable
3
7
 
4
8
  # Return the next record, after calling #hashify on it
5
9
  def each(hashify=true)
6
10
  while self.hasNext
7
- r = self.next
11
+ begin
12
+ r = self.next
13
+ # rescue Java::org.marc4j.MarcException => e
14
+ rescue org.marc4j.MarcException => e
15
+ unless self.methods.include? 'errors'
16
+ puts "#{e}"
17
+ raise e
18
+ end
19
+ self.errors.getErrors.each do |err|
20
+ case err.severity
21
+ when ErrorHandler::ERROR_TYPO, ErrorHandler::MINOR_ERROR, ErrorHandler::MAJOR_ERROR
22
+ $LOG.warn err.toString
23
+ when ErrorHandler::INFO
24
+ $LOG.info err.toString
25
+ when ErrorHandler::FATAL
26
+ $LOG.error err.toString
27
+ next # skip to the next record
28
+ end
29
+ end
30
+ end
8
31
  r.hashify if hashify
9
32
  yield r
10
33
  end
@@ -13,14 +36,13 @@ end
13
36
 
14
37
 
15
38
  module MARC4J4R
16
-
17
- # First, add Enumerable to the interface
18
- Java::org.marc4j.MarcReader.module_eval("include Enumerable")
19
-
39
+
20
40
  class Reader
21
41
 
22
42
  ENCODINGS = ['UTF-8', 'ISO-8859-1', 'MARC-8']
23
43
  ENCODING_ALIASES = {:utf8 => 'UTF-8', :marc8 => 'MARC-8', :iso => 'ISO-8859-1'}
44
+
45
+ # @attr_reader [File] handle The handle of the File (or IO) object being read from
24
46
  attr_reader :handle
25
47
 
26
48
  # Get a marc reader of the appropriate type
@@ -57,14 +79,18 @@ module MARC4J4R
57
79
  @handle = IOConvert.byteinstream(input)
58
80
  case type
59
81
  when :strictmarc then
82
+ Java::org.marc4j.MarcStreamReader.module_eval("include Enumerable")
60
83
  return Java::org.marc4j.MarcStreamReader.new(@handle, encoding)
61
84
  when :permissivemarc then
62
85
  encoding ||= 'BESTGUESS'
86
+ Java::org.marc4j.MarcPermissiveStreamReader.module_eval("include Enumerable")
63
87
  return Java::org.marc4j.MarcPermissiveStreamReader.new(@handle, true, true, encoding)
64
88
  when :marcxml then
89
+ Java::org.marc4j.MarcXmlReader.module_eval("include Enumerable")
65
90
  return Java::org.marc4j.MarcXmlReader.new(@handle)
66
91
  when :alephsequential then
67
- return MARC4J4R::AlephSequentialReader.new(@handle)
92
+ Java::org.marc4j.MarcAlephSequentialReader.module_eval("include Enumerable")
93
+ return Java::org.marc4j.MarcAlephSequentialReader.new(@handle)
68
94
  else
69
95
  raise ArgumentError, "Reader type #{type} illegal: must be :strictmarc, :permissivemarc, :marcxml, or :alephsequential"
70
96
  end
@@ -53,11 +53,12 @@ module MARC4J4R
53
53
  end
54
54
 
55
55
  # Set the leader
56
+ # @throw RuntimeError if leader is illegal
56
57
  def leader= str
57
58
  begin
58
59
  self.set_leader Java::org.marc4j.marc.impl.LeaderImpl.new(str)
59
- rescue java.lang.StringIndexOutOfBoundsException => e
60
- throw RuntimeError.new("'#{str}' not a legal leader: #{e.message}")
60
+ rescue Java::java.lang.StringIndexOutOfBoundsException => e
61
+ raise RuntimeError.new("'#{str}' not a legal leader: #{e.message}")
61
62
  end
62
63
  end
63
64
 
@@ -197,7 +198,11 @@ module MARC4J4R
197
198
  # Give a marc record in a string, turn it into an object
198
199
  # @param String str The record as a MARC binary string
199
200
  # @return MARC4J4R::Record The first record encoded in the string
200
- def self.from_string str
201
+ #
202
+ # Note that the normal way of defining this class (self.from_string)
203
+ # didn't work; I assume it has something to do with the fact that
204
+ # it's actually jrst aliased to the Java class
205
+ def Record.from_string str
201
206
  return MARC4J4R::Reader.new(StringIO.new(str)).first
202
207
  end
203
208
 
@@ -205,7 +210,7 @@ module MARC4J4R
205
210
  # Give a marc-xml record in a string, turn it into an object
206
211
  # @param String str The record as a MARC-XML string
207
212
  # @return MARC4J4R::Record The first record encoded in the string
208
- def self.from_xml_string str
213
+ def Record.from_xml_string str
209
214
  return MARC4J4R::Reader.new(StringIO.new(str), :marcxml).first
210
215
  end
211
216
 
data/lib/marc4j4r.rb CHANGED
@@ -2,11 +2,21 @@ unless defined? JRUBY_VERSION
2
2
  raise "Only works under JRUBY"
3
3
  end
4
4
 
5
+ require 'logger'
6
+ $LOG ||= Logger.new(STDERR)
7
+
5
8
  begin
6
9
  include_class Java::org.marc4j.marc.impl.RecordImpl
7
10
  rescue NameError => e
8
11
  jardir = File.join(File.dirname(__FILE__), '..', 'jars')
9
- require "#{jardir}/marc4j.jar"
12
+ require "#{jardir}/javamarc.jar"
13
+ end
14
+
15
+ begin
16
+ include_class Java::org.marc4j.MarcAlephSequentialReader
17
+ rescue
18
+ jardir = File.join(File.dirname(__FILE__), '..', 'jars')
19
+ require "#{jardir}/marc4j_serializations.jar"
10
20
  end
11
21
 
12
22
  # Define a method that will take a string (filename), IO object, or StringIO object,
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ import 'org.marc4j.ErrorHandler'
4
+
5
+ describe "MarcAlephSequentialReader constructor" do
6
+ before do
7
+ @seqfile = 'spec/three.seq'
8
+ end
9
+
10
+ it "should open a file" do
11
+ reader = MARC4J4R::Reader.new(@seqfile, :alephsequential)
12
+ reader.class.should.equal Java::org.marc4j.MarcAlephSequentialReader
13
+ end
14
+
15
+ it "delimits records correctly" do
16
+ reader = MARC4J4R::Reader.new(@seqfile, :alephsequential)
17
+ reader.collect.size.should.equal 3
18
+ end
19
+ end
20
+
21
+ describe "MarcAlephSequentialReader record construction" do
22
+ before do
23
+ seqfile = 'spec/three.seq'
24
+ reader = MARC4J4R::Reader.new(seqfile, :alephsequential)
25
+ @recs = reader.collect
26
+
27
+ end
28
+
29
+ it "gets the correct IDs" do
30
+ @recs[0]['001'].value.should.equal '000004262'
31
+ @recs[1]['001'].value.should.equal '000005951'
32
+ @recs[2]['001'].value.should.equal '000009811'
33
+ end
34
+
35
+ # Note that marc4j deals with teh length as an integer,
36
+ # so leading non-numerics get turned into zeros.
37
+ it "deals with leaders" do
38
+ @recs[0].leader.should.equal '00000nam^a22003011^^4500'
39
+ @recs[1].leader.should.equal '00000nam^a22002771^^4500'
40
+ @recs[2].leader.should.equal '00000nam^a22003251^^4500'
41
+ end
42
+
43
+ it "deals with control fields" do
44
+ @recs[0]['008'].value.should.equal '880715r19721939nyua^^^^^b^^^^00100^eng^^'
45
+ end
46
+
47
+ it "gets correct indicators" do
48
+ @recs[0]['050'].ind1.should.equal '0'
49
+ @recs[0]['050'].ind2.should.equal ' '
50
+ end
51
+
52
+ it "deals with variable field values" do
53
+ @recs[0]['040']['a'].should.equal 'DLC'
54
+ @recs[0]['040']['c'].should.equal 'DLC'
55
+ @recs[0]['040']['d'].should.equal 'MiU'
56
+ end
57
+
58
+ it "correctly adds multiple similar tags" do
59
+ @recs[0].find_by_tag('035').size.should.equal 4
60
+ end
61
+
62
+ end
63
+
64
+ describe "MarcAlephSequentialReader error handling" do
65
+
66
+ it "should bail on a bad file" do
67
+ lambda{
68
+ reader = MARC4J4R::Reader.new('spec/dne', :alephsequential)
69
+ }.should.raise Java::java.io.IOException
70
+ end
71
+
72
+
73
+ it "should fail to read a non-aleph-seq file" do
74
+ lambda {
75
+ reader = MARC4J4R::Reader.new('spec/batch.xml', :alephsequential)
76
+ }.should.raise Java::org.marc4j.MarcException
77
+ end
78
+
79
+ it "should produce a minor error for bad indicators" do
80
+ reader = MARC4J4R::Reader.new('spec/errors.seq', :alephsequential)
81
+ r = reader.next
82
+ err = reader.errors.getErrors
83
+ e = err[0]
84
+ e.severity.should.equal ErrorHandler::MINOR_ERROR
85
+ e.to_string.should.match /first indicator/
86
+ e = err[1]
87
+ e.severity.should.equal ErrorHandler::MINOR_ERROR
88
+ e.to_string.should.match /second indicator/
89
+ end
90
+
91
+ it "should produce a major error for poorly-formed variable field" do
92
+ reader = MARC4J4R::Reader.new('spec/errors.seq', :alephsequential)
93
+ r = reader.next
94
+ r = reader.next # second record
95
+ err = reader.errors.getErrors
96
+ e = err[0]
97
+ e.severity.should.equal ErrorHandler::MAJOR_ERROR
98
+ e.to_string.should.match /malformed/i
99
+ end
100
+
101
+ end
102
+
103
+
data/spec/bad.dat ADDED
@@ -0,0 +1 @@
1
+ 00734njm a2200217uu 450000100150000009007001500036008004100051010001900092040001300111245006800124260002600192300005600218651004500274700005400319700005500373700003000428852005000458852000800508afc99990058366DLC20071104155141.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/badbatch.dat ADDED
@@ -0,0 +1 @@
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.00647pam 2200241 a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001500161100002600176245006700202260003800269263000900307300001100316650003700327650002500364700001600389fol05754809 IMchF20000601115601.0000203s2000 mau 001 0 eng  a 00022023  a1565926994 aDLCcDLCdDLC apcc00aQA76.73.P22bD47 200000a005.742211 aDescartes, Alligator.10aProgramming the Perl DBI /cAlligator Descartes and Tim Bunce. aCmabridge, MA :bO'Reilly,c2000. a1111 ap. cm. 0aPerl (Computer program language) 0aDatabase management.1 aBunce, Tim.00605cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077040001800094042000800112050002700120082001700147100002100164245005500185260004500240300002600285504005100311650003700362fol05843555 IMchF20000525142739.0000318s1999 cau b 001 0 eng  a 00501349  aDLCcDLCdDLC apcc00aQA76.73.P22bB763 199900a005.13/32211 aBrown, Martin C.10aPerl :bprogrammer's reference /cMartin C. Brown. aBerkeley :bOsborne/McGraw-Hill,cc1999. axix, 380 p. ;c22 cm. aIncludes bibliographical references and index. 0aPerl (Computer program language)00579cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002700135082001700162100002100179245005500200260004500255300003600300650003700336fol05843579 IMchF20000525142716.0000318s1999 caua 001 0 eng  a 00502116  a0072120002 aDLCcDLCdDLC apcc00aQA76.73.P22bB762 199900a005.13/32211 aBrown, Martin C.10aPerl :bthe complete reference /cMartin C. Brown. aBerkeley :bOsborne/McGraw-Hill,cc1999. axxxv, 1179 p. :bill. ;c24 cm. 0aPerl (Computer program language)00801nam 22002778a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001800156100002000174245008800194250003200282260004100314263000900355300001100364650003700375650003600412650002600448700002500474700002400499fol05848297 IMchF20000524125727.0000518s2000 mau 001 0 eng  a 00041664  a1565924193 aDLCcDLC apcc00aQA76.73.P22bG84 200000a005.2/7622211 aGuelich, Scott.10aCGI programming with Perl /cScott Guelich, Shishir Gundavaram & Gunther Birznieks. a2nd ed., expanded & updated aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language) 0aCGI (Computer network protocol) 0aInternet programming.1 aGundavaram, Shishir.1 aBirznieks, Gunther.00665nam 22002298a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002700130082001700157111005200174245008600226250001200312260004100324263000900365300001100374650005000385fol05865950 IMchF20000615103017.0000612s2000 mau 100 0 eng  a 00055759  a0596000138 aDLCcDLC apcc00aQA76.73.P22bP475 200000a005.13/32212 aPerl Conference 4.0d(2000 :cMonterey, Calif.)10aProceedings of the Perl Conference 4.0 :bJuly 17-20, 2000, Monterey, California. a1st ed. aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language) 22002178a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100002800173245006200201260004100263263000900304300001100313650003700324fol05865956 IMchF20000615102948.0000612s2000 mau 000 0 eng  a 00055770  a1565926099 aDLCcDLC apcc00aQA76.73.P22bB43 200000a005.13/32211 aBlank-Edelman, David N.10aPerl for system administration /cDavid N. Blank-Edelman. aCambridge, Mass. :bO'Reilly,c2000. a0006 ap. cm. 0aPerl (Computer program language)00661nam 22002538a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100001700173245006700190250001200257260004100269263000900310300001100319650003700330700002300367700001700390fol05865967 IMchF20000615102611.0000614s2000 mau 000 0 eng  a 00055799  a0596000278 aDLCcDLC apcc00aQA76.73.P22bW35 200000a005.13/32211 aWall, Larry.10aProgramming Perl /cLarry Wall, Tom Christiansen & Jon Orwant. a3rd ed. aCambridge, Mass. :bO'Reilly,c2000. a0007 ap. cm. 0aPerl (Computer program language)1 aChristiansen, Tom.1 aOrwant, Jon.00603cam 22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001700161100003200178245006000210260005700270300003300327650003700360fol05872355 IMchF20000706095105.0000315s1999 njua 001 0 eng  a 00500678  a013020868X aDLCcDLCdDLC apcc00aQA76.73.P22bL69 199900a005.13/32211 aLowe, Vincentq(Vincent D.)10aPerl programmer's interactive workbook /cVincent Lowe. aUpper Saddle River, NJ :bPrentice Hall PTP,cc1999. axx, 633 p. :bill. ;c23 cm. 0aPerl (Computer program language)00696nam 22002538a 4500001001300000003000600013005001700019008004100036010001700077020002800094040001300122042000800135050002600143082001700169100002600186245004400212260005100256263000900307300001100316500002000327650003700347650001700384650004100401fol05882032 IMchF20000707091904.0000630s2000 cau 001 0 eng  a 00058174  a0764547291 (alk. paper) aDLCcDLC apcc00aQA76.73.P22bF64 200000a005.13/32212 aFoster-Johnson, Eric.10aCross-platform Perl /cEric F. Johnson. aFoster City, CA :bIDG Books Worldwide,c2000. a0009 ap. cm. aIncludes index. 0aPerl (Computer program language) 0aWeb servers. 0aCross-platform software development.
data/spec/badbatch.xml ADDED
@@ -0,0 +1,13 @@
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>00755cam 22002414a 4500</leader><controlfield tag='001'>fol05731351 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000613133448.0</controlfield><controlfield tag='008'>000107s2000 nyua 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00020737 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>0471383147 (paper/cd-rom : alk. paper)</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield><subfield code='d'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>M33 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Martinsson, Tobias,</subfield><subfield code='d'>1976-</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>ActivePerl with ASP and ADO /</subfield><subfield code='c'>Tobias Martinsson.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>New York :</subfield><subfield code='b'>John Wiley &amp; Sons,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>xxi, 289 p. :</subfield><subfield code='b'>ill. ;</subfield><subfield code='c'>23 cm. +</subfield><subfield code='e'>1 computer laser disc (4 3/4 in.)</subfield></datafield><datafield tag='500' ind1=' ' ind2=' '><subfield code='a'>&quot;Wiley Computer Publishing.&quot;</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield><datafield tag='630' ind1='0' ind2='0'><subfield code='a'>Active server pages.</subfield></datafield><datafield tag='630' ind1='0' ind2='0'><subfield code='a'>ActiveX.</subfield></datafield></record>
4
+ <record><leader>00647pam 2200241 a 4500</leader><controlfield tag='001'>fol05754809 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000601115601.0</controlfield><controlfield tag='008'>000203s2000 mau 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00022023 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>1565926994</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield><subfield code='d'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>D47 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.74</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Descartes, Alligator.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Programming the Perl DBI /</subfield><subfield code='c'>Alligator Descartes and Tim Bunce.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Cmabridge, MA :</subfield><subfield code='b'>O&apos;Reilly,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>1111</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Database management.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Bunce, Tim.</subfield></datafield></record>
5
+ <record><leader>00605cam 22002054a 4500</leader><controlfield tag='001'>fol05843555 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000525142739.0</controlfield><controlfield tag='008'>000318s1999 cau b 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00501349 </subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield><subfield code='d'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>B763 1999</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Brown, Martin C.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Perl :</subfield><subfield code='b'>programmer&apos;s reference /</subfield><subfield code='c'>Martin C. Brown.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Berkeley :</subfield><subfield code='b'>Osborne/McGraw-Hill,</subfield><subfield code='c'>c1999.</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>xix, 380 p. ;</subfield><subfield code='c'>22 cm.</subfield></datafield><datafield tag='504' ind1=' ' ind2=' '><subfield code='a'>Includes bibliographical references and index.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield></record>
6
+ <record><leader>00579cam 22002054a 4500</leader><controlfield tag='001'>fol05843579 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000525142716.0</controlfield><controlfield tag='008'>000318s1999 caua 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00502116 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>0072120002</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield><subfield code='d'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>B762 1999</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Brown, Martin C.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Perl :</subfield><subfield code='b'>the complete reference /</subfield><subfield code='c'>Martin C. Brown.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Berkeley :</subfield><subfield code='b'>Osborne/McGraw-Hill,</subfield><subfield code='c'>c1999.</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>xxxv, 1179 p. :</subfield><subfield code='b'>ill. ;</subfield><subfield code='c'>24 cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield></record>
7
+ <record><leader>00801nam 00</leader><controlfield tag='001'>fol05848297 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000524125727.0</controlfield><controlfield tag='008'>000518s2000 mau 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00041664 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>1565924193</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>G84 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.2/762</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Guelich, Scott.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>CGI programming with Perl /</subfield><subfield code='c'>Scott Guelich, Shishir Gundavaram &amp; Gunther Birznieks.</subfield></datafield><datafield tag='250' ind1=' ' ind2=' '><subfield code='a'>2nd ed., expanded &amp; updated</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Cambridge, Mass. :</subfield><subfield code='b'>O&apos;Reilly,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>0006</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>CGI (Computer network protocol)</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Internet programming.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Gundavaram, Shishir.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Birznieks, Gunther.</subfield></datafield></record>
8
+ <record><leader>00665nam 22002298a 4500</leader><controlfield tag='001'>fol05865950 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000615103017.0</controlfield><controlfield tag='008'>000612s2000 mau 100 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00055759 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>0596000138</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>P475 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='111' ind1='2' ind2=' '><subfield code='a'>Perl Conference 4.0</subfield><subfield code='d'>(2000 :</subfield><subfield code='c'>Monterey, Calif.)</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Proceedings of the Perl Conference 4.0 :</subfield><subfield code='b'>July 17-20, 2000, Monterey, California.</subfield></datafield><datafield tag='250' ind1=' ' ind2=' '><subfield code='a'>1st ed.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Cambridge, Mass. :</subfield><subfield code='b'>O&apos;Reilly,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>0006</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield><subfield code='v'>Congresses.</subfield></datafield></record>
9
+ <record><leader>00579nam 22002178a 4500</leader><controlfield tag='001'>fol05865956 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000615102948.0</controlfield><controlfield tag='008'>000612s2000 mau 000 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00055770 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>1565926099</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>B43 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Blank-Edelman, David N.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Perl for system administration /</subfield><subfield code='c'>David N. Blank-Edelman.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Cambridge, Mass. :</subfield><subfield code='b'>O&apos;Reilly,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>0006</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield></record>
10
+ <record><leader>00661nam 22002538a 4500</leader><controlfield tag='001'>fol05865967 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000615102611.0</controlfield><controlfield tag='008'>000614s2000 mau 000 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00055799 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>0596000278</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>W35 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Wall, Larry.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Programming Perl /</subfield><subfield code='c'>Larry Wall, Tom Christiansen &amp; Jon Orwant.</subfield></datafield><datafield tag='250' ind1=' ' ind2=' '><subfield code='a'>3rd ed.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Cambridge, Mass. :</subfield><subfield code='b'>O&apos;Reilly,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>0007</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Christiansen, Tom.</subfield></datafield><datafield tag='700' ind1='1' ind2=' '><subfield code='a'>Orwant, Jon.</subfield></datafield></record>
11
+ <record><leader>00603cam 22002054a 4500</leader><controlfield tag='001'>fol05872355 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000706095105.0</controlfield><controlfield tag='008'>000315s1999 njua 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00500678 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>013020868X</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield><subfield code='d'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>L69 1999</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='1' ind2=' '><subfield code='a'>Lowe, Vincent</subfield><subfield code='q'>(Vincent D.)</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Perl programmer&apos;s interactive workbook /</subfield><subfield code='c'>Vincent Lowe.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Upper Saddle River, NJ :</subfield><subfield code='b'>Prentice Hall PTP,</subfield><subfield code='c'>c1999.</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>xx, 633 p. :</subfield><subfield code='b'>ill. ;</subfield><subfield code='c'>23 cm.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield></record>
12
+ <record><leader>00696nam 22002538a 4500</leader><controlfield tag='001'>fol05882032 </controlfield><controlfield tag='003'>IMchF</controlfield><controlfield tag='005'>20000707091904.0</controlfield><controlfield tag='008'>000630s2000 cau 001 0 eng </controlfield><datafield tag='010' ind1=' ' ind2=' '><subfield code='a'> 00058174 </subfield></datafield><datafield tag='020' ind1=' ' ind2=' '><subfield code='a'>0764547291 (alk. paper)</subfield></datafield><datafield tag='040' ind1=' ' ind2=' '><subfield code='a'>DLC</subfield><subfield code='c'>DLC</subfield></datafield><datafield tag='042' ind1=' ' ind2=' '><subfield code='a'>pcc</subfield></datafield><datafield tag='050' ind1='0' ind2='0'><subfield code='a'>QA76.73.P22</subfield><subfield code='b'>F64 2000</subfield></datafield><datafield tag='082' ind1='0' ind2='0'><subfield code='a'>005.13/3</subfield><subfield code='2'>21</subfield></datafield><datafield tag='100' ind1='2' ind2=' '><subfield code='a'>Foster-Johnson, Eric.</subfield></datafield><datafield tag='245' ind1='1' ind2='0'><subfield code='a'>Cross-platform Perl /</subfield><subfield code='c'>Eric F. Johnson.</subfield></datafield><datafield tag='260' ind1=' ' ind2=' '><subfield code='a'>Foster City, CA :</subfield><subfield code='b'>IDG Books Worldwide,</subfield><subfield code='c'>2000.</subfield></datafield><datafield tag='263' ind1=' ' ind2=' '><subfield code='a'>0009</subfield></datafield><datafield tag='300' ind1=' ' ind2=' '><subfield code='a'>p. cm.</subfield></datafield><datafield tag='500' ind1=' ' ind2=' '><subfield code='a'>Includes index.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Perl (Computer program language)</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Web servers.</subfield></datafield><datafield tag='650' ind1=' ' ind2='0'><subfield code='a'>Cross-platform software development.</subfield></datafield></record>
13
+ </collection>
@@ -4,6 +4,7 @@ describe "MARC4J4R::ControlField basics" do
4
4
  it "can create a controlfield via the alias" do
5
5
  cf = MARC4J4R::ControlField.new('001')
6
6
  cf.tag.should.equal '001'
7
+ cf.controlField?.should.equal true
7
8
  end
8
9
 
9
10
  it "allows get/set of tag and value" do
@@ -12,6 +13,7 @@ describe "MARC4J4R::ControlField basics" do
12
13
  cf.value = 'Value'
13
14
  cf.tag.should.equal '001'
14
15
  cf.value.should.equal 'Value'
16
+ cf.to_s.should.equal '001 Value'
15
17
  end
16
18
 
17
19
  it "can create a cf with both arguments" do
@@ -45,6 +45,18 @@ describe "MARC4J4R::DataField & SubField basics" do
45
45
  df.ind1.should.equal '0'
46
46
  end
47
47
 
48
+ it "is not a control field" do
49
+ df = MARC4J4R::DataField.new('010', '1', '2')
50
+ df.controlField?.should.equal false
51
+ end
52
+
53
+ it "can create an empty df with blank constructor" do
54
+ df = MARC4J4R::DataField.new
55
+ df.tag.should.equal nil
56
+ df.ind1.should.equal ' '
57
+ df.ind2.should.equal ' '
58
+ end
59
+
48
60
 
49
61
  it "should defalt to spaces in ind1/ind2" do
50
62
  df = MARC4J4R::DataField.new('010')
@@ -53,4 +65,58 @@ describe "MARC4J4R::DataField & SubField basics" do
53
65
  end
54
66
  end
55
67
 
68
+ describe "Datafield with subfields" do
69
+ begin
70
+ @df = MARC4J4R::DataField.new('010', '1', '2')
71
+ @a = MARC4J4R::SubField.new('a', 'one')
72
+ @b = MARC4J4R::SubField.new('b', 'two')
73
+ @df << @a
74
+ @df << @b
75
+ end
76
+
77
+ it "works with subs" do
78
+ @df.subs.size.should.equal 2
79
+ @df.subs('a').should.equal [@a]
80
+ @df.subs('b').should.equal [@b]
81
+ @df.subs('c').should.equal []
82
+ @df.subs(['a', 'b']).sort{|a,b|a.code <=> b.code}.should.equal [@a,@b].sort{|a,b| a.code <=> b.code}
83
+ end
84
+
85
+ it "gets values" do
86
+ @df.value.should.equal "one two"
87
+ @df.value('|').should.equal "one|two"
88
+ @df.sub_values('a').should.equal ['one']
89
+ @df.sub_values(['a', 'b']).should.equal ['one', 'two']
90
+ @df << MARC4J4R::SubField.new('a', 'three')
91
+ @df['a'].should.equal 'one'
92
+ @df['b'].should.equal 'two'
93
+ @df['c'].should.equal nil
94
+ @df.sub_values('a').should.equal ['one','three']
95
+ end
96
+ end
56
97
 
98
+ describe "SubFields" do
99
+ before do
100
+ @df = MARC4J4R::DataField.new('010', '1', '2')
101
+ @a = MARC4J4R::SubField.new('a', 'one')
102
+ @df << @a
103
+ end
104
+
105
+ it "should allow creation of subfield wiht any info" do
106
+ lambda{
107
+ sf = MARC4J4R::SubField.new('a', 'value')
108
+ sf = MARC4J4R::SubField.new('a')
109
+ sf = MARC4J4R::SubField.new()
110
+ }.should.not.raise Exception
111
+ end
112
+
113
+ it "should get/set" do
114
+ @a.code.should.equal 'a'
115
+ @a.value.should.equal 'one'
116
+ @a.data.should.equal 'one'
117
+ @a.value = 'two'
118
+ @a.value.should.equal 'two'
119
+ @a.code = 'b'
120
+ @a.code.should.equal 'b'
121
+ end
122
+ end
data/spec/errors.seq ADDED
@@ -0,0 +1,118 @@
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/record_spec.rb CHANGED
@@ -32,6 +32,17 @@ describe "MARC4J4R_basic_retrieval_stuff" do
32
32
  @one.leader.should.equal "00734njm a2200217uu 4500"
33
33
  end
34
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
+
35
46
  it "can read a control field correctly" do
36
47
  @one['001'].value.should.equal "afc99990058366"
37
48
  end
@@ -44,7 +55,10 @@ describe "MARC4J4R_basic_retrieval_stuff" do
44
55
  it "should get the first 245 for this record" do
45
56
  @one['245'].to_s.should.equal "245 04 $a The Texas ranger $h [sound recording] / $c Sung by Beale D. Taylor."
46
57
  end
47
-
58
+
59
+ it "finds nothing when there's nothign there" do
60
+ @one['035'].should.equal nil
61
+ end
48
62
  end
49
63
 
50
64
  describe "MARC4J4R::Record #find_by_tag" do
@@ -98,4 +112,9 @@ describe "MARC4J4R::Record #find_by_tag" do
98
112
  first = @one['700']
99
113
  @one.find_by_tag('700')[0].should.equal first
100
114
  end
115
+
116
+ it "round trips binary and xml" do
117
+ MARC4J4R::Record.from_string(@one.to_marc).should.equal @one
118
+ MARC4J4R::Record.from_xml_string(@one.to_xml).should.equal @one
119
+ end
101
120
  end
data/spec/three.seq ADDED
@@ -0,0 +1,118 @@
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
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marc4j4r
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 9
9
9
  - 0
10
- version: 0.9.0
10
+ version: 1.0.0
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-10 00:00:00 -04:00
18
+ date: 2010-09-04 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -55,29 +55,36 @@ extensions: []
55
55
  extra_rdoc_files:
56
56
  - README.rdoc
57
57
  files:
58
+ - CHANGES
58
59
  - LICENSE
59
60
  - README.rdoc
60
61
  - Rakefile
61
62
  - VERSION
62
- - jars/marc4j.jar
63
+ - jars/javamarc.jar
63
64
  - lib/marc4j4r.rb
64
65
  - lib/marc4j4r/controlfield.rb
65
66
  - lib/marc4j4r/datafield.rb
66
67
  - lib/marc4j4r/reader.rb
67
68
  - lib/marc4j4r/record.rb
68
69
  - lib/marc4j4r/writer.rb
70
+ - spec/alephsequentialreader_spec.rb
71
+ - spec/bad.dat
72
+ - spec/badbatch.dat
73
+ - spec/badbatch.xml
69
74
  - spec/batch.dat
70
75
  - spec/batch.txt
71
76
  - spec/batch.xml
72
77
  - spec/chinese_utf8.dat
73
78
  - spec/controlfield_spec.rb
74
79
  - spec/datafield_spec.rb
80
+ - spec/errors.seq
75
81
  - spec/one.dat
76
82
  - spec/one.txt
77
83
  - spec/one.xml
78
84
  - spec/reader_spec.rb
79
85
  - spec/record_spec.rb
80
86
  - spec/spec_helper.rb
87
+ - spec/three.seq
81
88
  has_rdoc: true
82
89
  homepage: http://github.com/billdueber/javamarc/tree/master/ruby/marc4j4r/
83
90
  licenses: []