zcc 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +16 -0
- data/Manifest.txt +4 -4
- data/Rakefile +1 -1
- data/bin/zcc +352 -228
- data/examples/zcc.yaml +62 -34
- data/examples/zebra/accessfile +1 -0
- data/examples/zebra/records/0.xml +1 -0
- data/examples/zebra/shadow/remove_me +1 -0
- data/examples/zebra/tab/bib1.att +9 -56
- data/examples/zebra/tab/record.abs +215 -44
- data/examples/zebra/zcc_passw +1 -0
- data/examples/zebra/zebra.cfg +20 -15
- data/lib/zcc/cli_display.rb +64 -42
- data/lib/zcc/query.rb +30 -27
- data/lib/zcc/record.rb +38 -3
- data/lib/zcc/resultset.rb +1 -0
- data/lib/zcc/version.rb +1 -1
- data/website/index.html +7 -5
- data/website/index.txt +2 -2
- data/website/koha.html +32 -19
- data/website/koha.txt +3 -3
- data/website/stylesheets/screen.css +2 -2
- data/website/zcc.html +86 -34
- data/website/zcc.txt +49 -28
- data/website/zebra.html +15 -46
- data/website/zebra.txt +11 -47
- metadata +8 -8
- data/examples/zebra/records/0.mrc +0 -1
- data/examples/zebra/tab/marc21.abs +0 -67
- data/lib/zcc/subfieldeditor.rb +0 -70
- data/lib/zcc/zoomer.rb +0 -86
data/website/zebra.html
CHANGED
@@ -33,86 +33,55 @@
|
|
33
33
|
<h1>Very simple setup of local zebra server</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/zcc"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/zcc" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/zcc" class="numbers">0.2.0</a>
|
37
37
|
</div>
|
38
|
-
<p>These instructions are probably
|
38
|
+
<p>These instructions are probably still less complete than I would like them to be. Please let me know if you find errors.</p>
|
39
39
|
|
40
40
|
|
41
41
|
<p>Install all the dependencies to zcc and confirm that it is working.</p>
|
42
42
|
|
43
43
|
|
44
|
-
<p>Install <a href="http://www.indexdata.dk/zebra/">zebra</a> If using Debian or RedHat it is suggested that you add the indexdata repositories.</p>
|
44
|
+
<p>Install the latest <a href="http://www.indexdata.dk/zebra/">zebra</a> If using Debian or RedHat it is suggested that you add the indexdata repositories or build from source. Older versions of zebra are no longer compatible with the example zebra.cfg.</p>
|
45
45
|
|
46
46
|
|
47
|
-
You may have already moved the zebra directory into your
|
47
|
+
You may have already moved the zebra directory into your root zcc directory. If not do something like the following:
|
48
48
|
<pre syntax="ruby">
|
49
49
|
$ cd ~/.zcc
|
50
50
|
$ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/zebra .
|
51
51
|
</pre>
|
52
|
+
|
52
53
|
Now change into the zebra directory:
|
53
54
|
<pre syntax="ruby>
|
54
55
|
$ cd zebra
|
55
56
|
</pre>
|
56
|
-
<p>Now edit the zebra.cfg file. You must replace ‘jason’ with your username in all places.</p>
|
57
|
-
|
58
57
|
|
59
|
-
<
|
60
|
-
$ zebraidx update records
|
61
|
-
</pre>
|
62
|
-
<p>If the initial record update goes off without warnings or errors try this to start up the server in daemon mode (silent mode that runs in the background).</p>
|
58
|
+
<p>Now you may need to edit the zebra.cfg file, but it is configured already to work with zcc. Stay in the zebra directory and run:</p>
|
63
59
|
|
64
60
|
|
65
61
|
<pre syntax="ruby">
|
66
|
-
$ zebrasrv -D
|
62
|
+
$ zebrasrv @:9998 -l zebrasrv.log -D
|
67
63
|
</pre>
|
68
|
-
<p>You may see loaded filter module messages and then be returned to a prompt. Now you can try it out:</p>
|
69
|
-
|
70
64
|
|
71
|
-
<
|
72
|
-
$ yaz-client localhost:9999/zcc
|
73
|
-
Z> f @attr 1=4 bicycle
|
74
|
-
Z> show 1
|
75
|
-
Sent presentRequest (1+1).
|
76
|
-
Records: 1
|
77
|
-
[zcc]Record type: USmarc
|
78
|
-
00907pam a2200241 a 4500
|
79
|
-
001 3487522
|
80
|
-
005 19950117081431.7
|
81
|
-
008 940606s1994 cauab b 001 0 eng
|
82
|
-
035 $9 (DLC) 94026226
|
83
|
-
906 $a 7 $b cbc $c orignew $d 1 $e ocip $f 19 $g y-gencatlg
|
84
|
-
955 $a pc05 RUSH to sa00 06-06-94; sj06 06-07-94; sj09 06-07-94; sj04 06-08-94; CIP ver. ta06; to SL 01-17-95
|
85
|
-
010 $a 94026226
|
86
|
-
020 $a 0899971741 (pbk.)
|
87
|
-
040 $a DLC $c DLC $d DLC
|
88
|
-
050 00 $a GV1044 $b .B88 1994
|
89
|
-
100 1 $a Butterman, Steve.
|
90
|
-
245 10 $a Bicycle touring : $b how to prepare for long rides / $c Steve Butterman.
|
91
|
-
260 $a Berkeley, CA : $b Wilderness Press, $c c1994.
|
92
|
-
300 $a viii, 88 p. : $b ill., map ; $c 22 cm.
|
93
|
-
504 $a Includes bibliographical references (p. 78) and index.
|
94
|
-
650 0 $a Bicycle touring.
|
95
|
-
650 0 $a Bicycle touring $x Equipment and supplies.
|
96
|
-
991 $b c-GenColl $h GV1044 $i .B88 1994 $t Copy 1 $w BOOKS
|
97
|
-
</pre>
|
98
|
-
<p>If you see a record displayed then it works! Congratulations.</p>
|
65
|
+
<p>Or you can configure your zcc.yaml configuration file to automatically start the zebra server on startup and stop it when you quit zcc.</p>
|
99
66
|
|
100
67
|
|
101
68
|
Now you can configure your local zserver in the zcc.yaml file in ~/.zcc. Add (or uncomment) this line if necessary:
|
102
|
-
<pre>- [localhost,
|
69
|
+
<pre>- [localhost, 9998, zcc, 0]</pre>
|
103
70
|
My suggestion is to put this server in group 0 (zero) of your zservers to check in see whether you already have an appropriate record.
|
104
|
-
|
71
|
+
|
72
|
+
<p>If you want to add records to the zebra database manually you will need to return to your ~/.zcc/zebra directory and reindex the whole bunk of records. Just drop a <span class="caps">UTF</span>-8 encoded <span class="caps">MARCXML</span> record anywhere in the directory below ~/.zcc/zebra/records. The record should contain a 901a field as a unique identifier and it will be indexed after running this:</p>
|
105
73
|
|
106
74
|
|
107
75
|
<pre syntax="ruby">$ cd ~/.zcc/zebra
|
108
76
|
$ zebraidx update records</pre>
|
109
|
-
|
77
|
+
|
78
|
+
<p>This reindexing could take some time, especially if you have a large number of files, though zebra does index quickly. With version 0.2.0 <span class="caps">ZCC</span> now uses ruby-zoom (0.4.0+) extended services for safe insert of records. To make the zebra server a default place to save records enter ‘zebra’ (no quotes) under save_record_syntax in zcc.yaml.</p>
|
110
79
|
|
111
80
|
|
112
|
-
<p>If you shutdown your computer make sure to restart the zebrasrv!</p>
|
81
|
+
<p>If you shutdown your computer make sure to restart the zebrasrv or configure the zcc.yaml file to bring it back up for you!</p>
|
113
82
|
|
114
83
|
|
115
|
-
<p>If port
|
84
|
+
<p>If port 9998, the default zebrasrv port for zcc, is exposed to the world, others may be able to search your database as well. You may find this a good thing :) or it may be a security risk? You can specify a different port on the command line. See the <a href="http://www.indexdata.dk/zebra/doc/">zebra docs</a> for more information on changing the port and other configuration options for zebra. What you have been presented with here is just the simplest quickest way of getting I’ve found for getting zebra for zcc up and running on my Debian systems.</p>
|
116
85
|
|
117
86
|
</div>
|
118
87
|
|
data/website/zebra.txt
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
h1. Very simple setup of local zebra server
|
2
2
|
|
3
|
-
These instructions are probably
|
3
|
+
These instructions are probably still less complete than I would like them to be. Please let me know if you find errors.
|
4
4
|
|
5
5
|
Install all the dependencies to zcc and confirm that it is working.
|
6
6
|
|
7
|
-
Install "zebra":http://www.indexdata.dk/zebra/ If using Debian or RedHat it is suggested that you add the indexdata repositories.
|
7
|
+
Install the latest "zebra":http://www.indexdata.dk/zebra/ If using Debian or RedHat it is suggested that you add the indexdata repositories or build from source. Older versions of zebra are no longer compatible with the example zebra.cfg.
|
8
8
|
|
9
|
-
You may have already moved the zebra directory into your
|
9
|
+
You may have already moved the zebra directory into your root zcc directory. If not do something like the following:
|
10
10
|
<pre syntax="ruby">
|
11
11
|
$ cd ~/.zcc
|
12
12
|
$ cp -r /var/lib/gems/1.8/gems/zcc-0.0.4/examples/zebra .
|
@@ -17,61 +17,25 @@ Now change into the zebra directory:
|
|
17
17
|
$ cd zebra
|
18
18
|
</pre>
|
19
19
|
|
20
|
-
Now edit the zebra.cfg file
|
21
|
-
|
22
|
-
<pre>
|
23
|
-
$ zebraidx update records
|
24
|
-
</pre>
|
25
|
-
|
26
|
-
If the initial record update goes off without warnings or errors try this to start up the server in daemon mode (silent mode that runs in the background).
|
27
|
-
|
28
|
-
<pre syntax="ruby">
|
29
|
-
$ zebrasrv -D
|
30
|
-
</pre>
|
31
|
-
|
32
|
-
You may see loaded filter module messages and then be returned to a prompt. Now you can try it out:
|
20
|
+
Now you may need to edit the zebra.cfg file, but it is configured already to work with zcc. Stay in the zebra directory and run:
|
33
21
|
|
34
22
|
<pre syntax="ruby">
|
35
|
-
$
|
36
|
-
Z> f @attr 1=4 bicycle
|
37
|
-
Z> show 1
|
38
|
-
Sent presentRequest (1+1).
|
39
|
-
Records: 1
|
40
|
-
[zcc]Record type: USmarc
|
41
|
-
00907pam a2200241 a 4500
|
42
|
-
001 3487522
|
43
|
-
005 19950117081431.7
|
44
|
-
008 940606s1994 cauab b 001 0 eng
|
45
|
-
035 $9 (DLC) 94026226
|
46
|
-
906 $a 7 $b cbc $c orignew $d 1 $e ocip $f 19 $g y-gencatlg
|
47
|
-
955 $a pc05 RUSH to sa00 06-06-94; sj06 06-07-94; sj09 06-07-94; sj04 06-08-94; CIP ver. ta06; to SL 01-17-95
|
48
|
-
010 $a 94026226
|
49
|
-
020 $a 0899971741 (pbk.)
|
50
|
-
040 $a DLC $c DLC $d DLC
|
51
|
-
050 00 $a GV1044 $b .B88 1994
|
52
|
-
100 1 $a Butterman, Steve.
|
53
|
-
245 10 $a Bicycle touring : $b how to prepare for long rides / $c Steve Butterman.
|
54
|
-
260 $a Berkeley, CA : $b Wilderness Press, $c c1994.
|
55
|
-
300 $a viii, 88 p. : $b ill., map ; $c 22 cm.
|
56
|
-
504 $a Includes bibliographical references (p. 78) and index.
|
57
|
-
650 0 $a Bicycle touring.
|
58
|
-
650 0 $a Bicycle touring $x Equipment and supplies.
|
59
|
-
991 $b c-GenColl $h GV1044 $i .B88 1994 $t Copy 1 $w BOOKS
|
23
|
+
$ zebrasrv @:9998 -l zebrasrv.log -D
|
60
24
|
</pre>
|
61
25
|
|
62
|
-
|
26
|
+
Or you can configure your zcc.yaml configuration file to automatically start the zebra server on startup and stop it when you quit zcc.
|
63
27
|
|
64
28
|
Now you can configure your local zserver in the zcc.yaml file in ~/.zcc. Add (or uncomment) this line if necessary:
|
65
|
-
<pre>- [localhost,
|
29
|
+
<pre>- [localhost, 9998, zcc, 0]</pre>
|
66
30
|
My suggestion is to put this server in group 0 (zero) of your zservers to check in see whether you already have an appropriate record.
|
67
31
|
|
68
|
-
|
32
|
+
If you want to add records to the zebra database manually you will need to return to your ~/.zcc/zebra directory and reindex the whole bunk of records. Just drop a UTF-8 encoded MARCXML record anywhere in the directory below ~/.zcc/zebra/records. The record should contain a 901a field as a unique identifier and it will be indexed after running this:
|
69
33
|
|
70
34
|
<pre syntax="ruby">$ cd ~/.zcc/zebra
|
71
35
|
$ zebraidx update records</pre>
|
72
36
|
|
73
|
-
|
37
|
+
This reindexing could take some time, especially if you have a large number of files, though zebra does index quickly. With version 0.2.0 ZCC now uses ruby-zoom (0.4.0+) extended services for safe insert of records. To make the zebra server a default place to save records enter 'zebra' (no quotes) under save_record_syntax in zcc.yaml.
|
74
38
|
|
75
|
-
If you shutdown your computer make sure to restart the zebrasrv!
|
39
|
+
If you shutdown your computer make sure to restart the zebrasrv or configure the zcc.yaml file to bring it back up for you!
|
76
40
|
|
77
|
-
If port
|
41
|
+
If port 9998, the default zebrasrv port for zcc, is exposed to the world, others may be able to search your database as well. You may find this a good thing :) or it may be a security risk? You can specify a different port on the command line. See the "zebra docs":http://www.indexdata.dk/zebra/doc/ for more information on changing the port and other configuration options for zebra. What you have been presented with here is just the simplest quickest way of getting I've found for getting zebra for zcc up and running on my Debian systems.
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: zcc
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-11-21 00:00:00 -05:00
|
8
8
|
summary: zcc is a command line script for copy cataloging MARC records
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -37,10 +37,12 @@ files:
|
|
37
37
|
- bin/zcc
|
38
38
|
- examples/linter.pl
|
39
39
|
- examples/zcc.yaml
|
40
|
+
- examples/zebra/accessfile
|
40
41
|
- examples/zebra/key/remove_me
|
41
42
|
- examples/zebra/lock/remove_me
|
42
|
-
- examples/zebra/records/0.
|
43
|
+
- examples/zebra/records/0.xml
|
43
44
|
- examples/zebra/register/remove_me
|
45
|
+
- examples/zebra/shadow/remove_me
|
44
46
|
- examples/zebra/tab/bib1.abs
|
45
47
|
- examples/zebra/tab/bib1.att
|
46
48
|
- examples/zebra/tab/default.idx
|
@@ -48,13 +50,13 @@ files:
|
|
48
50
|
- examples/zebra/tab/explain.att
|
49
51
|
- examples/zebra/tab/explain.tag
|
50
52
|
- examples/zebra/tab/gils.att
|
51
|
-
- examples/zebra/tab/marc21.abs
|
52
53
|
- examples/zebra/tab/numeric.chr
|
53
54
|
- examples/zebra/tab/record.abs
|
54
55
|
- examples/zebra/tab/sort-string-utf.chr
|
55
56
|
- examples/zebra/tab/tagsetm.tag
|
56
57
|
- examples/zebra/tab/usmarc.mar
|
57
58
|
- examples/zebra/tab/word-phrase-utf.chr
|
59
|
+
- examples/zebra/zcc_passw
|
58
60
|
- examples/zebra/zebra.cfg
|
59
61
|
- examples/zoomer-iterator.txt
|
60
62
|
- examples/zservers.yaml
|
@@ -64,9 +66,7 @@ files:
|
|
64
66
|
- lib/zcc/query.rb
|
65
67
|
- lib/zcc/record.rb
|
66
68
|
- lib/zcc/resultset.rb
|
67
|
-
- lib/zcc/subfieldeditor.rb
|
68
69
|
- lib/zcc/version.rb
|
69
|
-
- lib/zcc/zoomer.rb
|
70
70
|
- lib/zcc/zserver.rb
|
71
71
|
- scripts/txt2html
|
72
72
|
- setup.rb
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.4.1
|
125
125
|
version:
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: unicode
|
@@ -1 +0,0 @@
|
|
1
|
-
00907pam a2200241 a 4500001000800000005001700008008003900025035002100064906004500085955010700130010001300237020002200250040001800272050002200290100002200312245007300334260004600407300003900453504005900492650002100551650004500572991004800617348752219950117081431.7940606s1994 cauab b 001 0 eng 9(DLC) 94026226 a7bcbccorignewd1eocipf19gy-gencatlg apc05 RUSH to sa00 06-06-94; sj06 06-07-94; sj09 06-07-94; sj04 06-08-94; CIP ver. ta06; to SL 01-17-95 a94026226 a0899971741 (pbk.) aDLCcDLCdDLC00aGV1044b.B88 19941 aButterman, Steve.10aBicycle touring :bhow to prepare for long rides /cSteve Butterman. aBerkeley, CA :bWilderness Press,cc1994. aviii, 88 p. :bill., map ;c22 cm. aIncludes bibliographical references (p. 78) and index. 0aBicycle touring. 0aBicycle touringxEquipment and supplies. bc-GenCollhGV1044i.B88 1994tCopy 1wBOOKS
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# $Id: record.abs,v 1.10 2007/05/08 12:50:06 adam Exp $
|
2
|
-
|
3
|
-
name marcxml
|
4
|
-
attset bib1.att
|
5
|
-
|
6
|
-
esetname F @
|
7
|
-
esetname B @
|
8
|
-
|
9
|
-
marc usmarc.mar
|
10
|
-
|
11
|
-
xpath disable
|
12
|
-
|
13
|
-
#xelm /record/leader leader:w:range(data,0,5),leader2:w:range(data,5,3)
|
14
|
-
melm 001 Identifier-Standard:0
|
15
|
-
#melm 008 Code-Language:w
|
16
|
-
melm 010 LC-card-number:w
|
17
|
-
melm 017 Number-legal-deposit,Identifier-standard
|
18
|
-
melm 018 Identifier-standard
|
19
|
-
melm 020$a ISBN:w,Identifier-standard:w
|
20
|
-
melm 020 ISBN,Identifier-standard
|
21
|
-
melm 022$a ISSN:w,ISBN:w
|
22
|
-
melm 022 ISSN,Identifier-standard
|
23
|
-
melm 023 Identifier-standard
|
24
|
-
melm 024 Identifier-standard
|
25
|
-
melm 025 Identifier-standard
|
26
|
-
melm 027 Report-number,Identifier-standard
|
27
|
-
melm 028 Number-music-publisher,Identifier-standard
|
28
|
-
melm 030 CODEN,Identifier-standard
|
29
|
-
melm 033 Date
|
30
|
-
melm 034 Map-scale
|
31
|
-
melm 035 Local-number,Identifier-standard
|
32
|
-
melm 037 Identifier-standard,Stock-number
|
33
|
-
melm 040 Code-institution,Record-source
|
34
|
-
melm 041 ln
|
35
|
-
melm 043 Code-geographic
|
36
|
-
melm 046 pubdate
|
37
|
-
melm 050$b LC-call-number:w, LC-call-number:p, LC-call-number:s
|
38
|
-
melm 050 LC-call-number:w, LC-call-number:p, LC-call-number:s
|
39
|
-
melm 052 Geographic-class
|
40
|
-
melm 060 NLM-call-number
|
41
|
-
melm 070 NAL-call-number
|
42
|
-
melm 080 UDC-classification
|
43
|
-
melm 082 Dewey-classification:w,Dewey-classification:s
|
44
|
-
melm 086 Number-govt-pub
|
45
|
-
melm 100$a author:w,author:s
|
46
|
-
melm 245 title:w
|
47
|
-
melm 650 LC-subject-heading:w,LC-subject-heading:p
|
48
|
-
xelm /record/datafield[@tag="710"]/subfield Server-choice:p:range(data,first(data,'.'))
|
49
|
-
#melm 700$9 Cross-Reference
|
50
|
-
melm 700$a Author,Author:p
|
51
|
-
melm 700$n Thematic-number
|
52
|
-
melm 700$r Music-key
|
53
|
-
melm 700$t author,Author-title,Name-and-title,Title,Title-uniform
|
54
|
-
melm 700$t Author-title,Name-and-title,Title,Title-uniform
|
55
|
-
melm 700 Author,Author-name-corporate,Author-name-personal,Name,Editor,Personal-name
|
56
|
-
melm 710 Author,Corporate-name
|
57
|
-
melm 710$t author,Author-title,Name-and-title,Title,Title-uniform
|
58
|
-
melm 710$t Author-title,Name-and-title,Title,Title-uniform
|
59
|
-
melm 710 author,Name
|
60
|
-
melm 710 Author,Name
|
61
|
-
melm 711$a Name-and-title
|
62
|
-
melm 711$t Author-title,Title,Title-uniform
|
63
|
-
melm 711 author,Author-name-corporate,Name,Conference-name
|
64
|
-
melm 711 Author-name-corporate,Name,Conference-name
|
65
|
-
melm 730$n Thematic-number
|
66
|
-
melm 730$r Music-key
|
67
|
-
melm 730 Title,Title-uniform
|
data/lib/zcc/subfieldeditor.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
module MARC
|
2
|
-
|
3
|
-
#edit is a wrapper method to loop until done
|
4
|
-
class Record
|
5
|
-
|
6
|
-
|
7
|
-
def edit
|
8
|
-
puts "Subfield Editing"
|
9
|
-
puts "To denote which subfield you want to edit put it in the form of 245a.\nIn the case of repeating fields or subfields you will be prompted\nto choose the one you wish to edit. "
|
10
|
-
continue = true
|
11
|
-
while continue
|
12
|
-
fs = ask("What field and subfield would you like to edit (in form 245a) or quit?\n> "){|q| q.readline = true}
|
13
|
-
if fs == 'q' || fs == 'quit'
|
14
|
-
continue = false
|
15
|
-
next
|
16
|
-
end
|
17
|
-
if !(fs =~/\d\d\d\w/ )
|
18
|
-
puts "That's not a valid value"
|
19
|
-
next
|
20
|
-
end
|
21
|
-
self.change_subfield(fs)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
#edit_subfield is passed to a MARC::Record object and give a subfield
|
26
|
-
def change_subfield(fs)
|
27
|
-
field_subfield = subfield_parse(fs)
|
28
|
-
field = field_subfield[0]
|
29
|
-
subfield = field_subfield[1]
|
30
|
-
|
31
|
-
fields = self.find_all {|f| f.tag == field}
|
32
|
-
subfields = []
|
33
|
-
for field in fields
|
34
|
-
subfields << field.find_all {|s| s.code == subfield}
|
35
|
-
end
|
36
|
-
subfields.flatten!
|
37
|
-
if subfields.length > 1
|
38
|
-
i = 0
|
39
|
-
for subfield in subfields
|
40
|
-
puts "#{i}\t#{subfield}"
|
41
|
-
i += 1
|
42
|
-
end
|
43
|
-
num_to_change = ask("Which subfield do you want to change?"){|q| q.readline = true}
|
44
|
-
subfield_to_change = subfields[num_to_change.to_i]
|
45
|
-
elsif subfields.length == 1
|
46
|
-
subfield_to_change = subfields[0]
|
47
|
-
elsif subfields.empty?
|
48
|
-
puts "No such subfield!"
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
puts self; puts
|
54
|
-
|
55
|
-
print "Currently:\t"
|
56
|
-
puts subfield_to_change.value
|
57
|
-
edit = ask("Your edit:\t"){|q| q.readline = true}
|
58
|
-
subfield_to_change.value = edit
|
59
|
-
puts; puts self; puts
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
#subfield_parse method for getting from '245a' to ['245','a']
|
64
|
-
def subfield_parse(combined)
|
65
|
-
field_subfield = []
|
66
|
-
field_subfield << combined[0, 3]
|
67
|
-
field_subfield << combined[3,1]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/zcc/zoomer.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
module ZCC
|
2
|
-
#main search method
|
3
|
-
def ZCC.zoomer(search_term, server, port, database )
|
4
|
-
puts "\n-------------------------------------\n#{server} #{port} #{database} \n"
|
5
|
-
|
6
|
-
conn = ZOOM::Connection.new
|
7
|
-
conn.connect(server, port) #do |conn|
|
8
|
-
conn.set_option('charset', 'UTF-8')
|
9
|
-
conn.preferred_record_syntax = 'MARC21'
|
10
|
-
conn.database_name = database
|
11
|
-
|
12
|
-
# Determines kind of search and creates query
|
13
|
-
full_search = ''
|
14
|
-
if search_term =~ /\d+-\d+/
|
15
|
-
search_term = ZCC.lccn_conversion(search_term)
|
16
|
-
puts "converted lccn to #{search_term}"
|
17
|
-
full_search = "@attr 1=9 #{search_term}"
|
18
|
-
elsif search_term =~ /\d+[X||\d]/ and !(search_term.match( /[a-wyz]/i ))
|
19
|
-
puts "Searching for ISBN: #{search_term}"
|
20
|
-
full_search = "@attr 1=7 #{search_term}"
|
21
|
-
elsif ( search_term[/[a-z]/i] ) #-- This check for a string could be better!
|
22
|
-
puts "searching for title:#{search_term}"
|
23
|
-
search_term = "\'#{search_term}\'"
|
24
|
-
full_search = "@attr 1=4 \"#{search_term}\""
|
25
|
-
else
|
26
|
-
puts "What is this search? Does not compute."
|
27
|
-
exit
|
28
|
-
end
|
29
|
-
|
30
|
-
#conducts search
|
31
|
-
rset = conn.search(full_search)
|
32
|
-
if ( rset.length == 0)
|
33
|
-
return nil
|
34
|
-
end
|
35
|
-
puts "Number of results: #{rset.length}"
|
36
|
-
#Grabs only as many records as are set to be shown
|
37
|
-
rset_recs = rset[0,TO_SHOW]
|
38
|
-
|
39
|
-
|
40
|
-
# Turns result set into MARC::Record objects which are returned
|
41
|
-
xmlrecs = ''
|
42
|
-
rset_recs.each do |rsetrec|
|
43
|
-
#puts rsetrec
|
44
|
-
xmlrec = ZCC.convert_char(rsetrec)
|
45
|
-
xmlrecs += xmlrec
|
46
|
-
end
|
47
|
-
return records = MARC::XMLReader.new(StringIO.new(string=xmlrecs))
|
48
|
-
|
49
|
-
rescue Exception => except
|
50
|
-
puts "Error! #{except}"
|
51
|
-
return nil
|
52
|
-
end
|
53
|
-
|
54
|
-
# Tests leader of MARC21 records for character encoding
|
55
|
-
# If leader position 9 is ' ' then convert to UTF-8.
|
56
|
-
# If leader position 9 is 'a' then the record is already UTF-8.
|
57
|
-
# Finally converts to xml
|
58
|
-
#def ZCC.convert_char rsetrec
|
59
|
-
# rec = MARC::Record.new_from_marc(rsetrec.raw)
|
60
|
-
# ldr9 = rec.leader[9, 1]
|
61
|
-
# return_rec = ''
|
62
|
-
# if ldr9 == ' '
|
63
|
-
# return_rec = rsetrec.xml('MARC-8', 'UTF-8')
|
64
|
-
# elsif ldr9 == 'a'
|
65
|
-
# return_rec = rsetrec.xml
|
66
|
-
# else
|
67
|
-
# raise "Invalid value in leader 9 for MARC21"
|
68
|
-
# end
|
69
|
-
# return_rec
|
70
|
-
#end
|
71
|
-
|
72
|
-
def ZCC.convert_char rsetrec
|
73
|
-
rec = MARC::Record.new_from_marc(rsetrec.raw)
|
74
|
-
ldr9 = rec.leader[9, 1]
|
75
|
-
return_rec = ''
|
76
|
-
if ldr9 == ' '
|
77
|
-
return_rec = rsetrec.raw('MARC-8', 'UTF-8')
|
78
|
-
elsif ldr9 == 'a'
|
79
|
-
return_rec = rsetrec.raw
|
80
|
-
else
|
81
|
-
raise "Invalid value in leader 9 for MARC21"
|
82
|
-
end
|
83
|
-
return_rec
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|