marc 0.0.9 → 0.1.0

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/lib/marc.rb CHANGED
@@ -1,3 +1,30 @@
1
+ #marc is a ruby library for reading and writing MAchine Readable Cataloging
2
+ #(MARC). More information about MARC can be found at <http://www.loc.gov/marc>.
3
+ #
4
+ #USAGE
5
+ #
6
+ # require 'marc'
7
+ #
8
+ # # reading records from a batch file
9
+ # reader = MARC::Reader.new('marc.dat')
10
+ # for record in reader
11
+ # puts record['245']['a']
12
+ # end
13
+ #
14
+ # # creating a record
15
+ # record = MARC::Record.new()
16
+ # record.add_field(MARC::DataField.new('100', '0', ' ', ['a', 'John Doe']))
17
+ #
18
+ # # writing a record
19
+ # writer = MARC::Writer.new('marc.dat')
20
+ # writer.write(record)
21
+ # writer.close()
22
+ #
23
+ # # writing a record as XML
24
+ # writer = MARC::XMLWriter.new('marc.xml')
25
+ # writer.write(record)
26
+ # writer.close()
27
+
1
28
  require 'marc/constants'
2
29
  require 'marc/record'
3
30
  require 'marc/datafield'
@@ -138,5 +138,15 @@ module MARC
138
138
  return self.to_s =~ regex
139
139
  end
140
140
 
141
+
142
+ # to get the field as a string, without the tag and indicators
143
+ # useful in situations where you want a legible version of the field
144
+ #
145
+ # print record['245'].value
146
+
147
+ def value
148
+ return(@subfields.map {|s| s.value} .join '')
149
+ end
150
+
141
151
  end
142
152
  end
@@ -24,10 +24,10 @@ module MARC
24
24
  throw "must pass in file name or handle"
25
25
  end
26
26
 
27
- @fh.write("<?xml version='1.0'?>")
27
+ @fh.write("<?xml version='1.0'?>\n")
28
28
  if opts[:stylesheet]
29
29
  @fh.write(
30
- %Q{<?xml-stylesheet type="text/xsl" href="#{opts[:stylesheet]}"?>})
30
+ %Q{<?xml-stylesheet type="text/xsl" href="#{opts[:stylesheet]}"?>\n})
31
31
  end
32
32
  @fh.write("<collection xmlns='" + MARC_NS + "' " +
33
33
  "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
data/test/tc_datafield.rb CHANGED
@@ -30,6 +30,7 @@ class TestField < Test::Unit::TestCase
30
30
  MARC::Subfield.new('a', 'Foo'),
31
31
  MARC::Subfield.new('b', 'Bar') )
32
32
  assert_equal("100 01 $a Foo $b Bar ", f1.to_s)
33
+ assert_equal("FooBar", f1.value)
33
34
  f2 = MARC::DataField.new('100', '0', '1',
34
35
  MARC::Subfield.new('a', 'Foo'),
35
36
  MARC::Subfield.new('b', 'Bar') )
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: marc
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.9
7
- date: 2006-03-28 00:00:00 -06:00
6
+ version: 0.1.0
7
+ date: 2006-12-06 00:00:00 -05:00
8
8
  summary: A ruby library for working with Machine Readable Cataloging
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: ehs@pobox.com
12
12
  homepage: http://www.textualize.com/ruby_marc
13
13
  rubyforge_project:
@@ -18,45 +18,51 @@ bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
27
26
  signing_key:
28
27
  cert_chain:
28
+ post_install_message:
29
29
  authors:
30
- - Ed Summers
30
+ - Ed Summers
31
31
  files:
32
- - lib/marc
33
- - lib/marc.rb
34
- - lib/marc/constants.rb
35
- - lib/marc/controlfield.rb
36
- - lib/marc/datafield.rb
37
- - lib/marc/exception.rb
38
- - lib/marc/reader.rb
39
- - lib/marc/record.rb
40
- - lib/marc/subfield.rb
41
- - lib/marc/writer.rb
42
- - lib/marc/xmlreader.rb
43
- - lib/marc/xmlwriter.rb
44
- - test/batch.dat
45
- - test/batch.xml
46
- - test/one.dat
47
- - test/tc_controlfield.rb
48
- - test/tc_datafield.rb
49
- - test/tc_reader.rb
50
- - test/tc_record.rb
51
- - test/tc_subfield.rb
52
- - test/tc_writer.rb
53
- - test/tc_xml.rb
54
- - test/ts_marc.rb
32
+ - lib/marc
33
+ - lib/marc.rb
34
+ - lib/marc/constants.rb
35
+ - lib/marc/controlfield.rb
36
+ - lib/marc/datafield.rb
37
+ - lib/marc/exception.rb
38
+ - lib/marc/reader.rb
39
+ - lib/marc/record.rb
40
+ - lib/marc/subfield.rb
41
+ - lib/marc/writer.rb
42
+ - lib/marc/xmlreader.rb
43
+ - lib/marc/xmlwriter.rb
44
+ - test/batch.dat
45
+ - test/batch.xml
46
+ - test/one.dat
47
+ - test/tc_controlfield.rb
48
+ - test/tc_datafield.rb
49
+ - test/tc_reader.rb
50
+ - test/tc_record.rb
51
+ - test/tc_subfield.rb
52
+ - test/tc_writer.rb
53
+ - test/tc_xml.rb
54
+ - test/ts_marc.rb
55
55
  test_files:
56
- - test/ts_marc.rb
56
+ - test/ts_marc.rb
57
57
  rdoc_options: []
58
+
58
59
  extra_rdoc_files: []
60
+
59
61
  executables: []
62
+
60
63
  extensions: []
64
+
61
65
  requirements: []
62
- dependencies: []
66
+
67
+ dependencies: []
68
+