mixed in enumerable to result set class. added result set method to get the size...
[zcc.git] / examples / zcc.yaml
blobc2de0ff67fa2ad48da41f94764d72be26f7532a8
1 # ZOOMER CONFIG FILE\r
2 # This is in YAML format\r
3 # Configure this file if you want:\r
4 # 1. to search multiple Z39.50 servers\r
5 # 2. the added functionality of scripting\r
6 # 3. creation of csv files. \r
7 # See below in each section for more information. \r
8 \r
9 #BASIC config\r
11 #What is the maximum number of records you want to show from the search result set?\r
12 to_show: 40\r
14 # Do you want to save your MARC files by 'search_term' or by 'timestamp'? Choosing timestamp will save all records from a single session to the same file, while search_term will save to separate files for each different search term used.\r
15 save_filename: timestamp\r
17 #Do you want scripting turned on?\r
18 scripting_on: yes\r
20 #Do you want subfield editing turned on?\r
21 subfield_editing: yes\r
23 #Do you want CSV file creation turned on?\r
24 csv_on: yes\r
26 #Do you want to use the optional MARC linter? Perl and the MARC::Lint module are necessary for the functionality to work.\r
27 linter_on: yes\r
29 #How do you want your records saved? Current choices are [marc, xml, zebra]\r
30 #'marc' means ISO2709, marc transmission format, not human readable\r
31 #'xml' currently means marcxml \r
32 #'zebra' means marc IS02709 saved to the directory of the zebra database by timestamp.\r
33 # STILL TO BE IMPLEMENTED: 'koha' save directly to a koha installation using bulkmarcimport.pl\r
34 # for 'zebra' a copy is also saved to the working directory.\r
35 #See for more information on setting up zebra: http://zcc.rubyforge.org/zebra.html\r
36 save_record_syntax: zebra\r
42 ###########################\r
43 # Z39.50 servers\r
44 # Place zservers in the order of your preferences for records.\r
45 # The current zservers are preceded with a minus sign and a space.\r
46 # Each server is enclosed in brackets and values are separated by commas.\r
47 # Columns and tabs are not important and are only done for readability.\r
48 # For a list of other servers see: http://targettest.indexdata.com/\r
49 \r
50 ##########################\r
51 zservers:\r
52 #  server                       port    service\r
53 - [localhost, 9999, zcc] #if you use the zcc zebra server setup\r
55 # [128.148.19.6,                210,    INNOPAC     ] #bad server, for testing\r
56 #-[81.144.245.7, 210, INNOPAC] #wellcome.ac.uk latin1 charset\r
57 #- [142.51.8.7, 2200, unicorn]\r
58 - [z3950.loc.gov,               7090,   Voyager     ] # Library of Congress\r
59 - [es33.uits.indiana.edu,   2200, Unicorn] #IU\r
60 #- [webcat.lib.okayama-u.ac.jp, 2210, limedio ] #utf8 records by default\r
61 - [bobcat.nyu.edu, 210, ADVANCE] #New York University Libraries |  98%\r
62 - [128.197.130.200, 210, INNOPAC] #Boston U. |  100%\r
65 #######################################################\r
66 # CSV files\r
67 # Follows is the template for creating csv files. \r
68 # Saving information to a csv file might be useful for print labels in \r
69 # a program like glabels or for statistics.\r
70 #######################################################\r
71 labels:\r
72 - [245, a, 30]\r
73 - [1XX, a, 30]\r
74 - [952, c]\r
75 - [942, k]\r
76 - [942, j]\r
77 - [942, l]\r
78 - [952, m]\r
79 - [952, t]\r
80 - [952, p]\r
81   \r
82   \r
83 #################################################\r
84 # Scripting\r
85 # Scripting allows you to change the record before saving it.\r
86 # Below is where you make changes to the scripting\r
87 # that will be run on each record. This feature is\r
88 # turned on in the main script with the value of the\r
89 # constant SCRIPTING at the head of the file.\r
90 #################################################\r
91 scripting:\r
92 - [remove,          9XX]\r
93 - [create-field,    942, " ",   " "] #create new field with empty indicators\r
94 - [create-field,    952, " ",   " "]\r
95 - [append-subfield, 952, 2,     DLC]\r
96 - [append-subfield, 952, b,     MRML]\r
97 #- [append-subfield, 952, c, BIO] # BIO, Fic\r
98 - [append-subfield, 942, c,     BOOK]\r
99 - [append-subfield, 942, k,     proc get_dewey] # "proc name" is the way to get\r
100                                                 # the script to evaluate a block\r
101                                                 # of code. See below. comment out for BIO\r
102 - [append-subfield, 942, j,     proc get_decimal] #comment out for BIO\r
103 #- [append-subfield,  942, l, proc prompt_cutter] #BIO\r
104 - [append-subfield, 942, l,     proc get_cutter] #comment out for BIO\r
105 - [append-subfield, 952, k,     proc get_combined_callnum]\r
106 - [prompt,          942, x,     IS THERE A CIP]\r
107 - [append-subfield, 942, y,     proc get_cip_callnum]\r
108 - [prompt,          942, z,     OLD CALL NUMBER]\r
109 - [prompt,          952, z,     PUBLIC NOTE FOR ITEM]\r
110 - [prompt,          952, x,     INTERNAL NOTE]\r
111 - [proc barcode_and_itemnum]\r
112 # [sort-tags] #This currently doesn't work.\r
115 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
116 # This is where the procs go for added scripting power.\r
117 # If you know some Ruby you can try to create one of these.\r
118 # If the block of code is placed in the last position,\r
119 # the last value evaluated will be returned and entered in the field.\r
120 # If the block of code is the only value within barckets,\r
121 # then you need to do the work yourself. For instance, if you want\r
122 # to create a field you need to do that yourself.\r
123 # The word variable record refers to the record the script is \r
124 # being run on.\r
125 # All blocks of code below must begin the this way:\r
126 # 1. Indent.\r
127 # 2. Name of the block exactly as you enter it above.\r
128 # 3. Colon, space, pipe.\r
129 # 4. The block of code starts on the next line with two indentations.\r
130 # 5. The block of code ends with a line between it and the next\r
131 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
132 procs:\r
133     prompt_cutter: |\r
134             print "What do you want the cutter to be?"\r
135             cutter = STDIN.gets.chomp\r
136             cutter\r
137     \r
138     get_dewey: |\r
139             puts "in the get dewey proc" if $testing    \r
140             if record['082']\r
141                 dewey = record['082']['a'] \r
142                 callnum = dewey.gsub(/\//, '') \r
143                 callnum = callnum.split(/\./) \r
144                 callnum[0]    \r
145             else\r
146                 print "What is the dewey (just the part before the decimal!)? " \r
147                 dewey = STDIN.gets.chomp \r
148                 dewey\r
149             end\r
150         \r
152     get_decimal: |\r
153            puts "in the get decimal proc" if $testing\r
154             if record['082']\r
155                 dewey = record['082']['a']\r
156                 dewey = dewey.gsub(/\//, '')\r
157                 puts "dewey: #{dewey} #{dewey.class}" if $testing\r
158                 puts "#{record['082']['a']}"\r
159                 #STDIN.gets if $testing\r
160                 #exit\r
161                 decimal = dewey.split(/\./)\r
162                 next if decimal[1] == nil\r
163                 decimal = decimal[1].slice(0, 3)\r
164                 decimal = decimal.gsub(/[0]+$/, '')\r
165                 decimal = "." + decimal\r
166                 #puts decimal\r
167                 decimal = nil if decimal == '.'\r
168                 #puts decimal\r
169                 \r
170                 decimal\r
171             else\r
172                 print "What is the decimal (leaving off the decimal point!)? "\r
173                 decimal = STDIN.gets.chomp\r
174                 decimal = "." + decimal\r
175                 decimal = nil if decimal == '.'\r
176                 decimal\r
177             end\r
178             \r
179          \r
181     get_cutter: |\r
182             #puts "|" , record , "|"\r
183             #puts "in the cutter proc"\r
184             if (record['952']) and (record['952']['c'] == ('BIO' or 'F'))\r
185                 print "This is a |#{record['952']['c']}|, so choose your cutter accordingly: "\r
186                 cutter = STDIN.gets.chomp\r
187                 cutter.upcase!\r
188                 return cutter\r
189             elsif record['100']\r
190                 cutter = record['100']['a'].dup\r
191             elsif record['110']\r
192                 cutter = record['110']['a'].dup\r
193             elsif record['111']\r
194                 cutter = record['111']['a'].dup\r
195             elsif record['130']\r
196                 cutter = record['130']['a'].dup\r
197             elsif record['245'].indicator1 == '0'\r
198                 cutter = record['245']['a']\r
199                 i = record['245'].indicator2.to_i\r
200                 cutter = cutter[i,99]\r
201             else\r
202                 print "What is the cutter for this book? "\r
203                 cutter = STDIN.gets.chomp\r
204             end\r
205             #puts cutter\r
206             #puts cutter.length\r
207             #puts cutter.jlength\r
208             #STDIN.gets\r
209             #puts cutter.usubstr(0, 3)\r
210                         \r
211             #STDIN.gets\r
212             if cutter.length == cutter.jlength\r
213                 cutter = cutter[0,4]\r
214                 #puts "cutter after slice", cutter\r
215                 cutter.gsub!("'", '')\r
216                 cutter.gsub!(" ", '')\r
217                 cutter = cutter[0,3]\r
218             else\r
219                 puts "This cutter appears to have multi-byte characters."\r
220                 print "What is the cutter for this book? "\r
221                 cutter = STDIN.gets.chomp\r
222             end\r
223              cutter.upcase!\r
224              puts "The final cutter: |#{cutter}|"\r
225              #puts cutter.jlength\r
226              cutter    \r
227         \r
229     get_cip_callnum: |\r
230         if record['942']['x'] == 'y'\r
231         print "What is the CIP call number? "\r
232         cipcall = STDIN.gets.chomp\r
233         cipcall\r
234         else\r
235           puts "Skipping CIP call number."          \r
236         end\r
237         \r
239     get_combined_callnum: |\r
240         #puts "into get_combined_callnum"\r
241         #puts record\r
242         #puts "**942 #{record['942']}"\r
243         #puts "**942k #{record['942']['k']}"\r
244         combined_callnum = record['942']['k'] if record['942']['k']\r
245         combined_callnum = combined_callnum + record['942']['j'] if record['942']['j'] \r
246         if record['942']['k']\r
247           combined_callnum = combined_callnum.to_s + " " + record['942']['l']\r
248         else\r
249           combined_callnum = record['942']['l']\r
250         end\r
252     barcode_and_itemnum: | \r
253         puts "BARCODE AND ITEMNUM!!!\a" if $testing\r
254         #STDIN.gets\r
255         #Dir.chdir("..") if Dir.pwd.include?('zoomer/saved')\r
256         #puts Dir.pwd\r
257         if $testing == 't'\r
258           iterator = File.new("~/.zcc/test-zoomer-iterator.txt", "r").gets\r
259         else\r
260           iterator = File.new("#{File.expand_path("~")}/.zcc/zoomer-iterator.txt", "r").gets \r
261         end\r
262         #iterator = File.new("test-zoomer-iterator.txt").gets if $testing == 't'\r
263         puts "iterator: #{iterator}"\r
264         iterator = iterator.chomp\r
265         barcode = "MRML-%05d" % iterator\r
266         new_iterator = iterator.to_i + 1\r
267         File.open("#{File.expand_path("~")}/.zcc/zoomer-iterator.txt", "w+") do |myfile|\r
268           myfile.write(new_iterator) unless $testing == 't'\r
269         end\r
270         record['952'].append(MARC::Subfield.new('p', barcode))\r
271         record['952'].append(MARC::Subfield.new('u', iterator))\r
272         \r