marc 0.4.4 → 0.5.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/Changes +13 -0
- data/README.md +88 -0
- data/Rakefile +2 -26
- data/lib/marc.rb +1 -1
- data/lib/marc/reader.rb +270 -50
- data/lib/marc/version.rb +3 -0
- data/lib/marc/writer.rb +11 -3
- data/test/bare_cp866.txt +1 -0
- data/test/cp866_multirecord.marc +1 -0
- data/test/cp866_unimarc.marc +1 -0
- data/test/jruby_bad_transcode.rb +52 -0
- data/test/jruby_just_string.rb +39 -0
- data/test/marc8_accented_chars.marc +1 -0
- data/test/tc_bare_ruby_strings.rb +43 -0
- data/test/tc_reader.rb +21 -6
- data/test/tc_reader_char_encodings.rb +256 -0
- data/test/tc_writer.rb +14 -2
- data/test/test_cp866.txt +1 -0
- data/test/{000039829.marc → utf8.marc} +0 -0
- data/test/utf8_multirecord.marc +1 -0
- data/test/utf8_with_bad_bytes.marc +1 -0
- metadata +73 -41
- data/README +0 -55
- data/test/t +0 -1
data/test/tc_writer.rb
CHANGED
@@ -28,8 +28,20 @@ class WriterTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
31
|
+
def test_unicode_roundtrip
|
32
|
+
record = MARC::Reader.new('test/utf8.marc').first
|
33
|
+
|
34
|
+
writer = MARC::Writer.new('test/writer.dat')
|
35
|
+
writer.write(record)
|
36
|
+
writer.close
|
37
|
+
|
38
|
+
read_back_record = MARC::Reader.new('test/writer.dat').first
|
33
39
|
|
40
|
+
# Make sure the one we wrote out then read in again
|
41
|
+
# is the same as the one we read the first time
|
42
|
+
# Looks like "==" is over-ridden to do that. Don't ever change, #==
|
43
|
+
assert (record == read_back_record), "Round-tripped record must equal original record"
|
44
|
+
end
|
45
|
+
|
34
46
|
|
35
47
|
end
|
data/test/test_cp866.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
���
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
01378nam a22004091i 4500001001000000003000400010005001700014006001900031007001500050008004100065035002500106035002400131035002300155040001300178041001400191100003200205245009500237260003900332300002100371500002000392500004800412500011800460538003000578650006500608650004200673650004200715650004500757852003400802970001300836970002100849971000800870972001300878973001700891973001900908974002700927998001400954000039829MiU20011011000000.0m d cr bn ---auaua880715q19701979th 00010 chi a(RLIN)MIUG16009126-B a(CaOTULAS)159860611 a(OCoLC)ocm65664201 aMiUcMiU0 achithaeng0 aČhamlō̜ng Phitsanākha.10aPhotčhanānukrom Čhin Klāng-TǣčhiuʻAngkrit-Thai /c[dōi Čhamlō̜ng Phitsanākha. aKrungthēp :bBantānsān,c197-?] a921 p. ;c19 cm. aIn Thai script. aAuthor's name and imprint from dust jacket. aEntries in Chinese characters with Mandarin and Swatow pronunciation in Thai script and English and Thai glosses. aMode of access: Internet. 0aChinese languagexDialectszChinazShantou (Guangdong Sheng) 0aChinese languagexDialectszThailand. 0aChinese languagexDictionariesxThai. 0aChinese languagexDictionariesxEnglish.0 aMiUbBUHRcGRADhPL 2127 .C42 aBKbBook aDIbDictionaries aMiU c20040625 aHTbavail_ht aACbavail_circ umdp.39015058645139ric cJKMs911401378nam a22004091i 4500001001000000003000400010005001700014006001900031007001500050008004100065035002500106035002400131035002300155040001300178041001400191100003200205245009500237260003900332300002100371500002000392500004800412500011800460538003000578650006500608650004200673650004200715650004500757852003400802970001300836970002100849971000800870972001300878973001700891973001900908974002700927998001400954000039829MiU20011011000000.0m d cr bn ---auaua880715q19701979th 00010 chi a(RLIN)MIUG16009126-B a(CaOTULAS)159860611 a(OCoLC)ocm65664201 aMiUcMiU0 achithaeng0 aČhamlō̜ng Phitsanākha.10aPhotčhanānukrom Čhin Klāng-TǣčhiuʻAngkrit-Thai /c[dōi Čhamlō̜ng Phitsanākha. aKrungthēp :bBantānsān,c197-?] a921 p. ;c19 cm. aIn Thai script. aAuthor's name and imprint from dust jacket. aEntries in Chinese characters with Mandarin and Swatow pronunciation in Thai script and English and Thai glosses. aMode of access: Internet. 0aChinese languagexDialectszChinazShantou (Guangdong Sheng) 0aChinese languagexDialectszThailand. 0aChinese languagexDictionariesxThai. 0aChinese languagexDictionariesxEnglish.0 aMiUbBUHRcGRADhPL 2127 .C42 aBKbBook aDIbDictionaries aMiU c20040625 aHTbavail_ht aACbavail_circ umdp.39015058645139ric cJKMs9114
|
@@ -0,0 +1 @@
|
|
1
|
+
01396nam a22004091i 4500001001000000003000400010005001700014006001900031007001500050008004100065035002500106035002400131035002300155040001300178041001400191100003200205245011300237260003900350300002100389500002000410500004800430500011800478538003000596650006500626650004200691650004200733650004500775852003400820970001300854970002100867971000800888972001300896973001700909973001900926974002700945998001400972000039829MiU20011011000000.0m d cr bn ---auaua880715q19701979th 00010 chi a(RLIN)MIUG16009126-B a(CaOTULAS)159860611 a(OCoLC)ocm65664201 aMiUcMiU0 achithaeng0 aČhamlō̜ng Phitsanākha.10aPhotčhanānukrom Čhin Klāng-TǣčhiuʻAngkrit-Thai /bad bytes => �( <=c[dōi Čhamlō̜ng Phitsanākha. aKrungthēp :bBantānsān,c197-?] a921 p. ;c19 cm. aIn Thai script. aAuthor's name and imprint from dust jacket. aEntries in Chinese characters with Mandarin and Swatow pronunciation in Thai script and English and Thai glosses. aMode of access: Internet. 0aChinese languagexDialectszChinazShantou (Guangdong Sheng) 0aChinese languagexDialectszThailand. 0aChinese languagexDictionariesxThai. 0aChinese languagexDictionariesxEnglish.0 aMiUbBUHRcGRADhPL 2127 .C42 aBKbBook aDIbDictionaries aMiU c20040625 aHTbavail_ht aACbavail_circ umdp.39015058645139ric cJKMs9114
|
metadata
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: marc
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Kevin Clarke
|
9
14
|
- Bill Dueber
|
10
15
|
- William Groppe
|
@@ -13,77 +18,104 @@ authors:
|
|
13
18
|
autorequire: marc
|
14
19
|
bindir: bin
|
15
20
|
cert_chain: []
|
16
|
-
|
21
|
+
|
22
|
+
date: 2012-05-07 00:00:00 Z
|
17
23
|
dependencies: []
|
24
|
+
|
18
25
|
description:
|
19
26
|
email: ehs@pobox.com
|
20
27
|
executables: []
|
28
|
+
|
21
29
|
extensions: []
|
30
|
+
|
22
31
|
extra_rdoc_files: []
|
23
|
-
|
24
|
-
|
32
|
+
|
33
|
+
files:
|
34
|
+
- lib/marc/xml_parsers.rb
|
25
35
|
- lib/marc/controlfield.rb
|
26
|
-
- lib/marc/datafield.rb
|
27
|
-
- lib/marc/dublincore.rb
|
28
|
-
- lib/marc/exception.rb
|
29
36
|
- lib/marc/reader.rb
|
37
|
+
- lib/marc/dublincore.rb
|
38
|
+
- lib/marc/xmlwriter.rb
|
39
|
+
- lib/marc/datafield.rb
|
30
40
|
- lib/marc/record.rb
|
31
|
-
- lib/marc/
|
41
|
+
- lib/marc/exception.rb
|
32
42
|
- lib/marc/writer.rb
|
33
|
-
- lib/marc/xml_parsers.rb
|
34
43
|
- lib/marc/xmlreader.rb
|
35
|
-
- lib/marc/
|
44
|
+
- lib/marc/version.rb
|
45
|
+
- lib/marc/constants.rb
|
46
|
+
- lib/marc/subfield.rb
|
36
47
|
- lib/marc.rb
|
37
|
-
- test/000039829.marc
|
38
|
-
- test/batch.dat
|
39
|
-
- test/batch.xml
|
40
|
-
- test/no-leading-zero.xml
|
41
|
-
- test/non-numeric.dat
|
42
|
-
- test/non-numeric.xml
|
43
48
|
- test/one.dat
|
44
49
|
- test/one.xml
|
50
|
+
- test/batch.xml
|
51
|
+
- test/cp866_multirecord.marc
|
45
52
|
- test/random_tag_order.dat
|
46
|
-
- test/
|
47
|
-
- test/
|
53
|
+
- test/no-leading-zero.xml
|
54
|
+
- test/tc_record.rb
|
55
|
+
- test/tc_parsers.rb
|
56
|
+
- test/tc_hash.rb
|
57
|
+
- test/tc_subfield.rb
|
58
|
+
- test/non-numeric.dat
|
59
|
+
- test/test_cp866.txt
|
60
|
+
- test/batch.dat
|
61
|
+
- test/jruby_bad_transcode.rb
|
48
62
|
- test/tc_controlfield.rb
|
63
|
+
- test/tc_bare_ruby_strings.rb
|
64
|
+
- test/tc_marchash.rb
|
65
|
+
- test/marc8_accented_chars.marc
|
66
|
+
- test/cp866_unimarc.marc
|
49
67
|
- test/tc_datafield.rb
|
68
|
+
- test/tc_reader_char_encodings.rb
|
69
|
+
- test/utf8_with_bad_bytes.marc
|
70
|
+
- test/utf8.marc
|
71
|
+
- test/bare_cp866.txt
|
50
72
|
- test/tc_dublincore.rb
|
51
|
-
- test/
|
52
|
-
- test/tc_marchash.rb
|
53
|
-
- test/tc_parsers.rb
|
54
|
-
- test/tc_reader.rb
|
55
|
-
- test/tc_record.rb
|
56
|
-
- test/tc_subfield.rb
|
73
|
+
- test/utf8_multirecord.marc
|
57
74
|
- test/tc_writer.rb
|
58
75
|
- test/tc_xml.rb
|
76
|
+
- test/non-numeric.xml
|
77
|
+
- test/random_tag_order2.dat
|
59
78
|
- test/ts_marc.rb
|
79
|
+
- test/tc_reader.rb
|
80
|
+
- test/jruby_just_string.rb
|
60
81
|
- Rakefile
|
61
|
-
- README
|
82
|
+
- README.md
|
62
83
|
- Changes
|
63
84
|
- LICENSE
|
64
|
-
homepage:
|
85
|
+
homepage: https://github.com/ruby-marc/ruby-marc/
|
65
86
|
licenses: []
|
87
|
+
|
66
88
|
post_install_message:
|
67
89
|
rdoc_options: []
|
68
|
-
|
90
|
+
|
91
|
+
require_paths:
|
69
92
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
94
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 59
|
99
|
+
segments:
|
100
|
+
- 1
|
101
|
+
- 8
|
102
|
+
- 6
|
75
103
|
version: 1.8.6
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
105
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 3
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
version: "0"
|
82
113
|
requirements: []
|
114
|
+
|
83
115
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.23
|
85
117
|
signing_key:
|
86
118
|
specification_version: 3
|
87
119
|
summary: A ruby library for working with Machine Readable Cataloging
|
88
|
-
test_files:
|
120
|
+
test_files:
|
89
121
|
- test/ts_marc.rb
|
data/README
DELETED
@@ -1,55 +0,0 @@
|
|
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
|
-
# print out field 245 subfield a
|
12
|
-
puts record['245']['a']
|
13
|
-
end
|
14
|
-
|
15
|
-
# creating a record
|
16
|
-
record = MARC::Record.new()
|
17
|
-
record.append(MARC::DataField.new('100', '0', ' ', ['a', 'John Doe']))
|
18
|
-
|
19
|
-
# writing a record
|
20
|
-
writer = MARC::Writer.new('marc.dat')
|
21
|
-
writer.write(record)
|
22
|
-
writer.close()
|
23
|
-
|
24
|
-
# writing a record as XML
|
25
|
-
writer = MARC::XMLWriter.new('marc.xml')
|
26
|
-
writer.write(record)
|
27
|
-
writer.close()
|
28
|
-
|
29
|
-
# encoding a record
|
30
|
-
MARC::Writer.encode(record) # or record.to_marc
|
31
|
-
|
32
|
-
INSTALLATION
|
33
|
-
|
34
|
-
If you are looking at this file you may want to be able to install the code.
|
35
|
-
First you'll need to test:
|
36
|
-
|
37
|
-
rake test
|
38
|
-
|
39
|
-
then build the gem:
|
40
|
-
|
41
|
-
rake package
|
42
|
-
|
43
|
-
and install the versioned gem:
|
44
|
-
|
45
|
-
gem install pkg/marc-x.x.x.gem
|
46
|
-
|
47
|
-
AUTHORS
|
48
|
-
|
49
|
-
Kevin Clarke <ksclarke@gmail.com>
|
50
|
-
Bill Dueber <bill@dueber.com>
|
51
|
-
William Groppe <will.groppe@gmail.com>
|
52
|
-
Ross Singer <rossfsinger@gmail.com>
|
53
|
-
Ed Summers <ehs@pobox.com>
|
54
|
-
|
55
|
-
Please send bugs, requests and comments to Code4Lib Mailing list (https://listserv.nd.edu/cgi-bin/wa?A0=CODE4LIB).
|
data/test/t
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Logfile created on 2012-02-09 11:53:05 -0500 by logger.rb/31641
|