marc4r 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +4 -0
  4. data/README.md +4 -0
  5. data/Rakefile +13 -0
  6. data/VERSION +1 -0
  7. data/lib/marc4r.rb +24 -0
  8. data/lib/marc4r/fields.rb +28 -0
  9. data/lib/marc4r/fields/control_field.rb +19 -0
  10. data/lib/marc4r/fields/data_field.rb +46 -0
  11. data/lib/marc4r/fields/subfield.rb +12 -0
  12. data/lib/marc4r/marc_stream_reader.rb +82 -0
  13. data/lib/marc4r/record.rb +92 -0
  14. data/marc4r.gemspec +21 -0
  15. data/spec/fixtures/OCLC_814388508.xml +123 -0
  16. data/spec/fixtures/bad_leaders_10_11.mrc +1 -0
  17. data/spec/fixtures/bad_too_long_plus_2.mrc +1 -0
  18. data/spec/fixtures/brkrtest.mrc +1 -0
  19. data/spec/fixtures/chabon.mrc +1 -0
  20. data/spec/fixtures/chabon.xml +116 -0
  21. data/spec/fixtures/chinese_mangled_multibyte.mrc +1 -0
  22. data/spec/fixtures/cruel-cruel-indicatorless-summerland.xml +55 -0
  23. data/spec/fixtures/cyrillic_capital_e.mrc +1 -0
  24. data/spec/fixtures/greekmissingcharsetchange.mrc +1 -0
  25. data/spec/fixtures/illegal-marc-in-json.json +401 -0
  26. data/spec/fixtures/legal-json-marc-in-json.json +380 -0
  27. data/spec/fixtures/loongboonmee.mrc +1 -0
  28. data/spec/fixtures/marc-in-json.json +380 -0
  29. data/spec/fixtures/marc-json.json +195 -0
  30. data/spec/fixtures/summerland-indented-marc-json.json +104 -0
  31. data/spec/fixtures/summerland-marc-in-json-indented.json +183 -0
  32. data/spec/fixtures/summerland-marc-in-json.json +1 -0
  33. data/spec/fixtures/summerland-marc-json.json +1 -0
  34. data/spec/fixtures/summerland.mrc +1 -0
  35. data/spec/fixtures/summerland.xml +52 -0
  36. data/spec/fixtures/u335.mrc +1 -0
  37. data/spec/lib/marc4r/fields/control_field_spec.rb +46 -0
  38. data/spec/lib/marc4r/fields/data_field_spec.rb +39 -0
  39. data/spec/lib/marc4r/marc_stream_reader.rb +19 -0
  40. data/spec/lib/marc4r/record_spec.rb +111 -0
  41. data/spec/spec_helper.rb +120 -0
  42. data/spec/test_constants.rb +22 -0
  43. data/tasks/marc4r-dev.rake +3 -0
  44. metadata +142 -0
@@ -0,0 +1,195 @@
1
+ {
2
+ leader : "01471cjm a2200349 a 4500",
3
+ controlfield :
4
+ [
5
+ { tag : "001", data : "5674874" },
6
+ { tag : "005", data : "20030305110405.0" },
7
+ { tag : "007", data : "sdubsmennmplu" },
8
+ { tag : "008", data : "930331s1963 nyuppn eng d" }
9
+ ]
10
+ datafield :
11
+ [
12
+ {
13
+ tag : "035", ind : " ",
14
+ subfield :
15
+ [
16
+ { code : "9", data : "(DLC) 93707283" }
17
+ ]
18
+ },
19
+ {
20
+ tag : "906", ind : " ",
21
+ subfield :
22
+ [
23
+ { code : "a", data : "7" },
24
+ { code : "b", data : "cbc" },
25
+ { code : "c", data : "copycat" },
26
+ { code : "d", data : "4" },
27
+ { code : "e", data : "ncip" },
28
+ { code : "f", data : "19" },
29
+ { code : "g", data : "y-soundrec" }
30
+ ]
31
+ },
32
+ {
33
+ tag : "010", ind : " ",
34
+ subfield :
35
+ [
36
+ { code : "a", data : " 93707283 " }
37
+ ]
38
+ },
39
+ {
40
+ tag : "028", ind : "02",
41
+ subfield :
42
+ [
43
+ { code : "a", data : "CS 8786" },
44
+ { code : "b", data : "Columbia" }
45
+ ]
46
+ },
47
+ {
48
+ tag : "035", ind : " ",
49
+ subfield :
50
+ [
51
+ { code : "a", data : "(OCoLC)13083787" }
52
+ ]
53
+ },
54
+ {
55
+ tag : "040", ind : " ",
56
+ subfield :
57
+ [
58
+ { code : "a", data : "OClU" },
59
+ { code : "c", data : "DLC" },
60
+ { code : "d", data : "DLC" }
61
+ ]
62
+ },
63
+ {
64
+ tag : "041", ind : "0 ",
65
+ subfield :
66
+ [
67
+ { code : "d", data : "eng" },
68
+ { code : "g", data : "eng" }
69
+ ]
70
+ },
71
+ {
72
+ tag : "042", ind : " ",
73
+ subfield :
74
+ [
75
+ { code : "a", data : "lccopycat" }
76
+ ]
77
+ },
78
+ {
79
+ tag : "050", ind : "00",
80
+ subfield :
81
+ [
82
+ { code : "a", data : "Columbia CS 8786" }
83
+ ]
84
+ },
85
+ {
86
+ tag : "100", ind : "1 ",
87
+ subfield :
88
+ [
89
+ { code : "a", data : "Dylan, Bob," },
90
+ { code : "d", data : "1941-" }
91
+ ]
92
+ },
93
+ {
94
+ tag : "245", ind : "14",
95
+ subfield :
96
+ [
97
+ { code : "a", data : "The freewheelin' Bob Dylan" },
98
+ { code : "h", data : "[sound recording]." }
99
+ ]
100
+ },
101
+ {
102
+ tag : "260", ind : " ",
103
+ subfield :
104
+ [
105
+ { code : "a", data : "[New York, N.Y.] :" },
106
+ { code : "b", data : "Columbia," },
107
+ { code : "c", data : "[1963]" }
108
+ ]
109
+ },
110
+ {
111
+ tag : "300", ind : " ",
112
+ subfield :
113
+ [
114
+ { code : "a", data : "1 sound disc :" },
115
+ { code : "b", data : "analog, 33 1/3 rpm, stereo. ;" },
116
+ { code : "c", data : "12 in." }
117
+ ]
118
+ },
119
+ {
120
+ tag : "500", ind : " ",
121
+ subfield :
122
+ [
123
+ { code : "a", data : "Songs." }
124
+ ]
125
+ },
126
+ {
127
+ tag : "511", ind : "0 ",
128
+ subfield :
129
+ [
130
+ { code : "a", data : "The composer accompanying himself on the guitar ; in part with instrumental ensemble." }
131
+ ]
132
+ },
133
+ {
134
+ tag : "500", ind : " ",
135
+ subfield :
136
+ [
137
+ { code : "a", data : "Program notes by Nat Hentoff on container." }
138
+ ]
139
+ },
140
+ {
141
+ tag : "505", ind : "0 ",
142
+ subfield :
143
+ [
144
+ { code : "a", data : "Blowin' in the wind -- Girl from the north country -- Masters of war -- Down the highway -- Bob Dylan's blues -- A hard rain's a-gonna fall -- Don't think twice, it's all right -- Bob Dylan's dream -- Oxford town -- Talking World War III blues -- Corrina, Corrina -- Honey, just allow me one more chance -- I shall be free." }
145
+ ]
146
+ },
147
+ {
148
+ tag : "650", ind : " 0",
149
+ subfield :
150
+ [
151
+ { code : "a", data : "Popular music" },
152
+ { code : "y", data : "1961-1970." }
153
+ ]
154
+ },
155
+ {
156
+ tag : "650", ind : " 0",
157
+ subfield :
158
+ [
159
+ { code : "a", data : "Blues (Music)" },
160
+ { code : "y", data : "1961-1970." }
161
+ ]
162
+ },
163
+ {
164
+ tag : "856", ind : "41",
165
+ subfield :
166
+ [
167
+ { code : "3", data : "Preservation copy (limited access)" },
168
+ { code : "u", data : "http://hdl.loc.gov/loc.mbrsrs/lp0001.dyln" }
169
+ ]
170
+ },
171
+ {
172
+ tag : "952", ind : " ",
173
+ subfield :
174
+ [
175
+ { code : "a", data : "New" }
176
+ ]
177
+ },
178
+ {
179
+ tag : "953", ind : " ",
180
+ subfield :
181
+ [
182
+ { code : "a", data : "TA28" }
183
+ ]
184
+ },
185
+ {
186
+ tag : "991", ind : " ",
187
+ subfield :
188
+ [
189
+ { code : "b", data : "c-RecSound" },
190
+ { code : "h", data : "Columbia CS 8786" },
191
+ { code : "w", data : "MUSIC" }
192
+ ]
193
+ }
194
+ ]
195
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ leader:"00714cam a2200205 a 4500",
3
+ controlfield:
4
+ [
5
+ { tag : "001", data : "12883376" },
6
+ { tag : "005", data : "20030616111422.0" },
7
+ { tag : "008", data : "020805s2002 nyu j 000 1 eng " }
8
+ ]
9
+ datafield :
10
+ [
11
+ {
12
+ tag : "020", ind : " ",
13
+ subfield :
14
+ [
15
+ { code : "a", data : "0786808772" }
16
+ ]
17
+ },
18
+ {
19
+ tag : "020", ind : " ",
20
+ subfield :
21
+ [
22
+ { code : "a", data : "0786816155 (pbk.)" }
23
+ ]
24
+ },
25
+ {
26
+ tag : "040", ind : " ",
27
+ subfield :
28
+ [
29
+ { code : "a", data : "DLC" },
30
+ { code : "c", data : "DLC" },
31
+ { code : "d", data : "DLC" }
32
+ ]
33
+ },
34
+ {
35
+ tag : "100", ind : "1 ",
36
+ subfield :
37
+ [
38
+ { code : "a", data : "Chabon, Michael." }
39
+ ]
40
+ },
41
+ {
42
+ tag : "245", ind : "10",
43
+ subfield :
44
+ [
45
+ { code : "a", data : "Summerland /" },
46
+ { code : "c", data : "Michael Chabon." }
47
+ ]
48
+ },
49
+ {
50
+ tag : "250", ind : " ",
51
+ subfield :
52
+ [
53
+ { code : "a", data : "1st ed." }
54
+ ]
55
+ },
56
+ {
57
+ tag : "260", ind : " ",
58
+ subfield :
59
+ [
60
+ { code : "a", data : "New York :" },
61
+ { code : "b", data : "Miramax Books/Hyperion Books for Children," },
62
+ { code : "c", data : "c2002." }
63
+ ]
64
+ },
65
+ {
66
+ tag : "300", ind : " ",
67
+ subfield :
68
+ [
69
+ { code : "a", data : "500 p. ;" },
70
+ { code : "c", data : "22 cm." }
71
+ ]
72
+ },
73
+ {
74
+ tag : "520", ind : " ",
75
+ subfield :
76
+ [
77
+ { code : "a", data : "Ethan Feld, the worst baseball player in the history of the game, finds himself recruited by a 100-year-old scout to help a band of fairies triumph over an ancient enemy." }
78
+ ]
79
+ },
80
+ {
81
+ tag : "650", ind : " 1",
82
+ subfield :
83
+ [
84
+ { code : "a", data : "Fantasy." }
85
+ ]
86
+ },
87
+ {
88
+ tag : "650", ind : " 1",
89
+ subfield :
90
+ [
91
+ { code : "a", data : "Baseball" },
92
+ { code : "v", data : "Fiction." }
93
+ ]
94
+ },
95
+ {
96
+ tag : "650", ind : " 1",
97
+ subfield :
98
+ [
99
+ { code : "a", data : "Magic" },
100
+ { code : "v", data : "Fiction." }
101
+ ]
102
+ }
103
+ ]
104
+ }
@@ -0,0 +1,183 @@
1
+ {
2
+ "leader":"00714cam a2200205 a 4500",
3
+ "fields":
4
+ [
5
+ {
6
+ "001":"12883376"
7
+ },
8
+ {
9
+ "005":"20030616111422.0"
10
+ },
11
+ {
12
+ "008":"020805s2002 nyu j 000 1 eng "
13
+ },
14
+ {
15
+ "020":
16
+ {"subfields":
17
+ [
18
+ {
19
+ "a":"0786808772"
20
+ }
21
+ ],
22
+ "ind1":" ",
23
+ "ind2":" "
24
+ }
25
+ },
26
+ {
27
+ "020":
28
+ {"subfields":
29
+ [
30
+ {
31
+ "a":"0786816155 (pbk.)"
32
+ }
33
+ ],
34
+ "ind1":" ",
35
+ "ind2":" "
36
+ }
37
+ },
38
+ {
39
+ "040":
40
+ {"subfields":
41
+ [
42
+ {
43
+ "a":"DLC"
44
+ },
45
+ {
46
+ "c":"DLC"
47
+ },
48
+ {
49
+ "d":"DLC"
50
+ }
51
+ ],
52
+ "ind1":" ",
53
+ "ind2":" "
54
+ }
55
+ },
56
+ {
57
+ "100":
58
+ {"subfields":
59
+ [
60
+ {
61
+ "a":"Chabon, Michael."
62
+ }
63
+ ],
64
+ "ind1":"1",
65
+ "ind2":" "
66
+ }
67
+ },
68
+ {
69
+ "245":
70
+ {"subfields":
71
+ [
72
+ {
73
+ "a":"Summerland /"
74
+ },
75
+ {
76
+ "c":"Michael Chabon."
77
+ }
78
+ ],
79
+ "ind1":"1",
80
+ "ind2":"0"
81
+ }
82
+ },
83
+ {
84
+ "250":
85
+ {"subfields":
86
+ [
87
+ {
88
+ "a":"1st ed."
89
+ }
90
+ ],
91
+ "ind1":" ",
92
+ "ind2":" "
93
+ }
94
+ },
95
+ {
96
+ "260":
97
+ {"subfields":
98
+ [
99
+ {
100
+ "a":"New York :"
101
+ },
102
+ {
103
+ "b":"Miramax Books/Hyperion Books for Children,"
104
+ },
105
+ {
106
+ "c":"c2002."
107
+ }
108
+ ],
109
+ "ind1":" ",
110
+ "ind2":" "
111
+ }
112
+ },
113
+ {
114
+ "300":
115
+ {"subfields":
116
+ [
117
+ {
118
+ "a":"500 p. ;"
119
+ },
120
+ {
121
+ "c":"22 cm."
122
+ }
123
+ ],
124
+ "ind1":" ",
125
+ "ind2":" "
126
+ }
127
+ },
128
+ {
129
+ "520":
130
+ {"subfields":
131
+ [
132
+ {
133
+ "a":"Ethan Feld, the worst baseball player in the history of the game, finds himself recruited by a 100-year-old scout to help a band of fairies triumph over an ancient enemy."
134
+ }
135
+ ],
136
+ "ind1":" ",
137
+ "ind2":" "
138
+ }
139
+ },
140
+ {
141
+ "650":
142
+ {"subfields":
143
+ [
144
+ {
145
+ "a":"Fantasy."
146
+ }
147
+ ],
148
+ "ind1":" ",
149
+ "ind2":"1"
150
+ }
151
+ },
152
+ {
153
+ "650":
154
+ {"subfields":
155
+ [
156
+ {
157
+ "a":"Baseball"
158
+ },
159
+ {
160
+ "v":"Fiction."
161
+ }
162
+ ],
163
+ "ind1":" ",
164
+ "ind2":"1"
165
+ }
166
+ },
167
+ {
168
+ "650":
169
+ {"subfields":
170
+ [
171
+ {
172
+ "a":"Magic"
173
+ },
174
+ {
175
+ "v":"Fiction."
176
+ }
177
+ ],
178
+ "ind1":" ",
179
+ "ind2":"1"
180
+ }
181
+ }
182
+ ]
183
+ }