marc 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changes CHANGED
@@ -1,3 +1,6 @@
1
+ v0.2.2 Tue Dec 30 09:50:33 EST 2008
2
+ - DataField tags that are all numeric are now padded with leading zeros
3
+
1
4
  v0.2.1 Mon Aug 18 14:14:16 EDT 2008
2
5
  - can now process records that have fields tags that are non-numeric (thanks
3
6
  Ross Singer)
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- RUBY_MARC_VERSION = '0.2.1'
1
+ RUBY_MARC_VERSION = '0.2.2'
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rake'
@@ -50,7 +50,13 @@ module MARC
50
50
  # ['c', 'by Edward O. Wilson.'] )
51
51
 
52
52
  def initialize(tag, i1=' ', i2=' ', *subfields)
53
- @tag = tag
53
+ # if the tag is less than 3 characters long and
54
+ # the string is all numeric then we pad with zeros
55
+ if tag.length < 3 and /^[0-9]*$/ =~ tag
56
+ @tag = "%03d" % tag
57
+ else
58
+ @tag = tag
59
+ end
54
60
  # can't allow nil to be passed in or else it'll
55
61
  # screw us up later when we try to encode
56
62
  @indicator1 = i1 == nil ? ' ' : i1
File without changes
@@ -0,0 +1 @@
1
+ <ns0:record xmlns:ns0="http://www.loc.gov/MARC21/slim"><ns0:leader> Z 22 4500</ns0:leader><ns0:datafield ind1="0" ind2="0" tag="245"><ns0:subfield code="a">The Untamed</ns0:subfield><ns0:subfield code="b" /><ns0:subfield code="c">by Max Brand</ns0:subfield></ns0:datafield><ns0:datafield ind1="0" ind2="z" tag="100"><ns0:subfield code="a">Brand, Max,</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="42"><ns0:subfield code="a">dc</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="100"><ns0:subfield code="d">1892-1944</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="245"><ns0:subfield code="h">[electronic resource] /</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="260"><ns0:subfield code="b">Project Gutenberg,</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="260"><ns0:subfield code="c">2004</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="500"><ns0:subfield code="a">Project Gutenberg</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="506"><ns0:subfield code="a">Freely available.</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="516"><ns0:subfield code="a">Electronic text</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="830"><ns0:subfield code="a">Project Gutenberg</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="830"><ns0:subfield code="v">10886</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="856"><ns0:subfield code="u">http://www.gutenberg.org/etext/10886</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="856"><ns0:subfield code="u">http://www.gutenberg.org/license</ns0:subfield></ns0:datafield><ns0:datafield ind1="z" ind2="z" tag="856"><ns0:subfield code="3">Rights</ns0:subfield></ns0:datafield></ns0:record>
File without changes
data/test/tc_xml.rb CHANGED
@@ -44,6 +44,12 @@ class XMLTest < Test::Unit::TestCase
44
44
  assert_equal('1', record['LOC']['9'])
45
45
  end
46
46
 
47
+ def test_read_no_leading_zero_write_leading_zero
48
+ reader = MARC::XMLReader.new('test/no-leading-zero.xml')
49
+ record = reader.to_a[0]
50
+ assert_equal("042 zz $a dc ", record['042'].to_s)
51
+ end
52
+
47
53
  def test_leader_from_xml
48
54
  reader = MARC::XMLReader.new('test/one.xml')
49
55
  record = reader.entries[0]
metadata CHANGED
@@ -1,77 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: marc
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2008-08-18 00:00:00 -04:00
8
- summary: A ruby library for working with Machine Readable Cataloging
9
- require_paths:
10
- - lib
11
- email: ehs@pobox.com
12
- homepage: http://www.textualize.com/ruby_marc
13
- rubyforge_project:
14
- description:
15
- autorequire: marc
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.6
24
- version:
4
+ version: 0.2.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Ed Summers
8
+ autorequire: marc
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ehs@pobox.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
31
24
  files:
32
25
  - lib/marc.rb
33
26
  - lib/marc
34
- - lib/marc/reader.rb
35
- - lib/marc/writer.rb
36
- - lib/marc/dublincore.rb
37
27
  - lib/marc/xmlwriter.rb
38
28
  - lib/marc/controlfield.rb
39
- - lib/marc/datafield.rb
40
- - lib/marc/constants.rb
41
29
  - lib/marc/xmlreader.rb
42
- - lib/marc/exception.rb
30
+ - lib/marc/reader.rb
43
31
  - lib/marc/record.rb
32
+ - lib/marc/exception.rb
33
+ - lib/marc/datafield.rb
44
34
  - lib/marc/subfield.rb
45
- - test/tc_reader.rb
35
+ - lib/marc/constants.rb
36
+ - lib/marc/dublincore.rb
37
+ - lib/marc/writer.rb
38
+ - test/non-numeric.dat
39
+ - test/tc_dublincore.rb
46
40
  - test/tc_datafield.rb
47
- - test/batch.dat
48
- - test/tc_record.rb
49
- - test/batch.xml
41
+ - test/non-numeric.xml
42
+ - test/no-leading-zero.xml
50
43
  - test/ts_marc.rb
51
- - test/tc_subfield.rb
52
44
  - test/tc_writer.rb
45
+ - test/batch.xml
53
46
  - test/tc_xml.rb
54
- - test/non-numeric.xml
55
- - test/tc_dublincore.rb
56
47
  - test/one.dat
57
- - test/non-numeric.dat
48
+ - test/tc_record.rb
58
49
  - test/one.xml
50
+ - test/batch.dat
59
51
  - test/tc_controlfield.rb
52
+ - test/tc_reader.rb
53
+ - test/tc_subfield.rb
60
54
  - Rakefile
61
55
  - README
62
56
  - Changes
63
57
  - LICENSE
64
- test_files:
65
- - test/ts_marc.rb
58
+ has_rdoc: true
59
+ homepage: http://www.textualize.com/ruby_marc
60
+ post_install_message:
66
61
  rdoc_options: []
67
62
 
68
- extra_rdoc_files: []
69
-
70
- executables: []
71
-
72
- extensions: []
73
-
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.6
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
74
77
  requirements: []
75
78
 
76
- dependencies: []
77
-
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.1
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: A ruby library for working with Machine Readable Cataloging
84
+ test_files:
85
+ - test/ts_marc.rb