marc 0.3.1 → 0.3.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.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- RUBY_MARC_VERSION = '0.3.1'
1
+ RUBY_MARC_VERSION = '0.3.2'
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rake'
data/lib/marc/writer.rb CHANGED
@@ -44,7 +44,8 @@ module MARC
44
44
  # encode the field
45
45
  field_data = ''
46
46
  if field.class == MARC::DataField
47
- field_data = field.indicator1 + field.indicator2
47
+ warn("Warn: Missing indicator") unless field.indicator1 && field.indicator2
48
+ field_data = (field.indicator1 || "z") + (field.indicator2 || "z")
48
49
  for s in field.subfields
49
50
  field_data += SUBFIELD_INDICATOR + s.code + s.value
50
51
  end
@@ -101,13 +101,13 @@ module MARC
101
101
 
102
102
  # If marc is leniently parsed, we may have some dirty data; using
103
103
  # the 'z' ind1 value should help us locate these later to fix
104
- if (field.indicator1.match(singleChar) == nil)
104
+ if field.indicator1.nil? || (field.indicator1.match(singleChar) == nil)
105
105
  field.indicator1 = 'z'
106
106
  end
107
107
 
108
108
  # If marc is leniently parsed, we may have some dirty data; using
109
109
  # the 'z' ind2 value should help us locate these later to fix
110
- if (field.indicator2.match(singleChar) == nil)
110
+ if field.indicator2.nil? || (field.indicator2.match(singleChar) == nil)
111
111
  field.indicator2 = 'z'
112
112
  end
113
113
 
data/test/tc_writer.rb CHANGED
@@ -19,6 +19,14 @@ class WriterTest < Test::Unit::TestCase
19
19
  # cleanup
20
20
  File.unlink('test/writer.dat')
21
21
  end
22
+
23
+ def test_forgiving_writer
24
+ marc = "00305cam a2200133 a 4500001000700000003000900007005001700016008004100033008004100074035002500115245001700140909001000157909000400167\036635145\036UK-BiLMS\03620060329173705.0\036s1982iieng6 000 0 eng||\036060116|||||||||xxk eng||\036 \037a(UK-BiLMS)M0017366ZW\03600\037aTest record.\036 \037aa\037b\037c\036\037b0\036\035\000"
25
+ rec = MARC::Record.new_from_marc(marc)
26
+ assert_nothing_raised do
27
+ rec.to_marc
28
+ end
29
+ end
22
30
 
23
31
  def test_ampersand
24
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Clarke
@@ -12,7 +12,7 @@ autorequire: marc
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-12-14 00:00:00 -05:00
15
+ date: 2009-12-17 00:00:00 -05:00
16
16
  default_executable:
17
17
  dependencies: []
18
18