marc4j4r 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +2 -4
- data/VERSION +1 -1
- data/jars/javamarc.jar +0 -0
- data/jars/marc4j_serializations.jar +0 -0
- data/lib/marc4j4r/record.rb +5 -12
- data/lib/marc4j4r/writer.rb +2 -1
- data/spec/alephsequentialreader_spec.rb +6 -6
- data/spec/record_spec.rb +5 -0
- metadata +5 -4
data/CHANGES
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
1.1
|
2
|
+
Added native java method to turn a record into XML (20% speedup or so)
|
1
3
|
1.0
|
2
4
|
Arbitrary decision that this is 1.0
|
3
5
|
Using javamarc.jar (fork of marc4j) from http://github.com/billdueber/javamarc
|
@@ -5,10 +7,6 @@
|
|
5
7
|
Added code to Reader#each to deal with #errors object if provided by the
|
6
8
|
specific reader (right now, :permissivemarc and :alephsequential) and specs
|
7
9
|
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
10
|
0.9.1
|
13
11
|
Updated to latest marc4j; changes involve character conversion
|
14
12
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/jars/javamarc.jar
CHANGED
Binary file
|
Binary file
|
data/lib/marc4j4r/record.rb
CHANGED
@@ -142,20 +142,13 @@ module MARC4J4R
|
|
142
142
|
|
143
143
|
# Return the record as valid MARC-XML
|
144
144
|
# @return String A MARC-XML representation of the record, including the XML header
|
145
|
+
|
145
146
|
def to_xml
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
writer = org.marc4j.MarcXmlWriter.new(res)
|
150
|
-
writer.write(self)
|
151
|
-
writer.writeEndDocument
|
152
|
-
return xml.toString
|
153
|
-
rescue
|
154
|
-
"Woops! to_xml failed for record #{self['001'].data}: #{$!}"
|
155
|
-
end
|
156
|
-
end
|
147
|
+
return Java::org.marc4j.MarcXmlWriter.record_to_XML(self)
|
148
|
+
end
|
149
|
+
|
157
150
|
|
158
|
-
|
151
|
+
def to_marc
|
159
152
|
begin
|
160
153
|
s = Java::java.io.ByteArrayOutputStream.new
|
161
154
|
writer = org.marc4j.MarcPermissiveStreamWriter.new(s)
|
data/lib/marc4j4r/writer.rb
CHANGED
@@ -20,7 +20,8 @@ module MARC4J4R
|
|
20
20
|
if type == :strictmarc
|
21
21
|
return Java::org.marc4j.MarcStreamWriter.new(@handle)
|
22
22
|
elsif type == :marcxml
|
23
|
-
|
23
|
+
writer = Java::org.marc4j.MarcXmlWriter.new(@handle)
|
24
|
+
writer.setUnicodeNormalization(true)
|
24
25
|
else
|
25
26
|
raise ArgumentError.new("#{type} must be :strictmarc or :marcxml")
|
26
27
|
end
|
@@ -4,7 +4,7 @@ import 'org.marc4j.ErrorHandler'
|
|
4
4
|
|
5
5
|
describe "MarcAlephSequentialReader constructor" do
|
6
6
|
before do
|
7
|
-
@seqfile =
|
7
|
+
@seqfile = "#{DIR}/three.seq"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should open a file" do
|
@@ -20,7 +20,7 @@ end
|
|
20
20
|
|
21
21
|
describe "MarcAlephSequentialReader record construction" do
|
22
22
|
before do
|
23
|
-
seqfile =
|
23
|
+
seqfile = "#{DIR}/three.seq"
|
24
24
|
reader = MARC4J4R::Reader.new(seqfile, :alephsequential)
|
25
25
|
@recs = reader.collect
|
26
26
|
|
@@ -65,19 +65,19 @@ describe "MarcAlephSequentialReader error handling" do
|
|
65
65
|
|
66
66
|
it "should bail on a bad file" do
|
67
67
|
lambda{
|
68
|
-
reader = MARC4J4R::Reader.new(
|
68
|
+
reader = MARC4J4R::Reader.new("#{DIR}/doesntexist.seq", :alephsequential)
|
69
69
|
}.should.raise Java::java.io.IOException
|
70
70
|
end
|
71
71
|
|
72
72
|
|
73
73
|
it "should fail to read a non-aleph-seq file" do
|
74
74
|
lambda {
|
75
|
-
reader = MARC4J4R::Reader.new(
|
75
|
+
reader = MARC4J4R::Reader.new("#{DIR}/batch.xml", :alephsequential)
|
76
76
|
}.should.raise Java::org.marc4j.MarcException
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should produce a minor error for bad indicators" do
|
80
|
-
reader = MARC4J4R::Reader.new(
|
80
|
+
reader = MARC4J4R::Reader.new("#{DIR}/errors.seq", :alephsequential)
|
81
81
|
r = reader.next
|
82
82
|
err = reader.errors.getErrors
|
83
83
|
e = err[0]
|
@@ -89,7 +89,7 @@ describe "MarcAlephSequentialReader error handling" do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should produce a major error for poorly-formed variable field" do
|
92
|
-
reader = MARC4J4R::Reader.new(
|
92
|
+
reader = MARC4J4R::Reader.new("#{DIR}/errors.seq", :alephsequential)
|
93
93
|
r = reader.next
|
94
94
|
r = reader.next # second record
|
95
95
|
err = reader.errors.getErrors
|
data/spec/record_spec.rb
CHANGED
@@ -117,4 +117,9 @@ describe "MARC4J4R::Record #find_by_tag" do
|
|
117
117
|
MARC4J4R::Record.from_string(@one.to_marc).should.equal @one
|
118
118
|
MARC4J4R::Record.from_xml_string(@one.to_xml).should.equal @one
|
119
119
|
end
|
120
|
+
|
121
|
+
it "round trips xml with the native_to_xml" do
|
122
|
+
MARC4J4R::Record.from_xml_string(@one.native_to_xml).should.equal @one
|
123
|
+
end
|
124
|
+
|
120
125
|
end
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
10
|
+
version: 1.1.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-09-
|
18
|
+
date: 2010-09-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- Rakefile
|
62
62
|
- VERSION
|
63
63
|
- jars/javamarc.jar
|
64
|
+
- jars/marc4j_serializations.jar
|
64
65
|
- lib/marc4j4r.rb
|
65
66
|
- lib/marc4j4r/controlfield.rb
|
66
67
|
- lib/marc4j4r/datafield.rb
|