added basic forward and backwards
[zcc.git] / examples / zcc.yaml
blobbf34884b2082d3582659a5e771abfa1968ec468d
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: [marc, 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 #- [Include zservers.yaml] #Optionall you can Include another file within your .zcc directory that contains a list of zservers. Only include the entries in the same for as the ones below. This option must be the first line for this feature to work correctly.\r
54 - [localhost, 9999, zcc, 0] #if you use the zcc zebra server setup\r
55 - [z3950.loc.gov,               7090,   Voyager, 1     ] # Library of Congress\r
56 - [es33.uits.indiana.edu,   2200, Unicorn, 2] #IU\r
57 - [bobcat.nyu.edu, 210, ADVANCE, 2] #New York University Libraries |  98%\r
58 - [128.197.130.200, 210, INNOPAC, 2] #Boston U. |  100%\r
60 # [128.148.19.6,                210,    INNOPAC     ] #bad server, for testing\r
61 #-[81.144.245.7, 210, INNOPAC] #wellcome.ac.uk latin1 charset\r
62 #- [142.51.8.7, 2200, unicorn]\r
63 #- [webcat.lib.okayama-u.ac.jp, 2210, limedio ] #utf8 records by default\r
67 #######################################################\r
68 # CSV files\r
69 # Follows is the template for creating csv files. \r
70 # Saving information to a csv file might be useful for print labels in \r
71 # a program like glabels or for statistics.\r
72 #######################################################\r
73 labels:\r
74 - [245, a, 30]\r
75 - [1XX, a, 30]\r
76 - [952, c]\r
77 - [942, k]\r
78 - [942, j]\r
79 - [942, l]\r
80 - [952, m]\r
81 - [952, t]\r
82 - [952, p]\r
83   \r
84   \r
85 #################################################\r
86 # Scripting\r
87 # Scripting allows you to change the record before saving it.\r
88 # Below is where you make changes to the scripting\r
89 # that will be run on each record. This feature is\r
90 # turned on in the main script with the value of the\r
91 # constant SCRIPTING at the head of the file.\r
92 #################################################\r
93 scripting:\r
94 - [remove,          9XX]\r
95 - [create-field,    942, " ",   " "] #create new field with empty indicators\r
96 - [create-field,    952, " ",   " "]\r
97 - [append-subfield, 952, 2,     DLC]\r
98 - [append-subfield, 952, b,     MRML]\r
99 #- [append-subfield, 952, c, BIO] # BIO, Fic\r
100 - [append-subfield, 942, c,     BOOK]\r
101 - [append-subfield, 942, k,     proc get_dewey] # "proc name" is the way to get\r
102                                                 # the script to evaluate a block\r
103                                                 # of code. See below. comment out for BIO\r
104 - [append-subfield, 942, j,     proc get_decimal] #comment out for BIO\r
105 #- [append-subfield,  942, l, proc prompt_cutter] #BIO\r
106 - [append-subfield, 942, l,     proc get_cutter] #comment out for BIO\r
107 - [append-subfield, 952, k,     proc get_combined_callnum]\r
108 - [prompt,          942, x,     IS THERE A CIP]\r
109 - [append-subfield, 942, y,     proc get_cip_callnum]\r
110 - [prompt,          942, z,     OLD CALL NUMBER]\r
111 - [prompt,          952, z,     PUBLIC NOTE FOR ITEM]\r
112 - [prompt,          952, x,     INTERNAL NOTE]\r
113 - [proc barcode_and_itemnum]\r
114 # [sort-tags] #This currently doesn't work.\r
117 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
118 # This is where the procs go for added scripting power.\r
119 # If you know some Ruby you can try to create one of these.\r
120 # If the block of code is placed in the last position,\r
121 # the last value evaluated will be returned and entered in the field.\r
122 # If the block of code is the only value within barckets,\r
123 # then you need to do the work yourself. For instance, if you want\r
124 # to create a field you need to do that yourself.\r
125 # The word variable record refers to the record the script is \r
126 # being run on.\r
127 # All blocks of code below must begin the this way:\r
128 # 1. Indent.\r
129 # 2. Name of the block exactly as you enter it above.\r
130 # 3. Colon, space, pipe.\r
131 # 4. The block of code starts on the next line with two indentations.\r
132 # 5. The block of code ends with a line between it and the next\r
133 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
134 procs:\r
135     prompt_cutter: |\r
136             print "What do you want the cutter to be?"\r
137             cutter = STDIN.gets.chomp\r
138             cutter\r
139     \r
140     get_dewey: |\r
141             puts "in the get dewey proc" if $testing    \r
142             if record['082']\r
143                 dewey = record['082']['a'] \r
144                 callnum = dewey.gsub(/\//, '') \r
145                 callnum = callnum.split(/\./) \r
146                 callnum[0]    \r
147             else\r
148                 print "What is the dewey (just the part before the decimal!)? " \r
149                 dewey = STDIN.gets.chomp \r
150                 dewey\r
151             end\r
152         \r
154     get_decimal: |\r
155            puts "in the get decimal proc" if $testing\r
156             if record['082']\r
157                 dewey = record['082']['a']\r
158                 dewey = dewey.gsub(/\//, '')\r
159                 puts "dewey: #{dewey} #{dewey.class}" if $testing\r
160                 puts "#{record['082']['a']}"\r
161                 #STDIN.gets if $testing\r
162                 #exit\r
163                 decimal = dewey.split(/\./)\r
164                 next if decimal[1] == nil\r
165                 decimal = decimal[1].slice(0, 3)\r
166                 decimal = decimal.gsub(/[0]+$/, '')\r
167                 decimal = "." + decimal\r
168                 #puts decimal\r
169                 decimal = nil if decimal == '.'\r
170                 #puts decimal\r
171                 \r
172                 decimal\r
173             else\r
174                 print "What is the decimal (leaving off the decimal point!)? "\r
175                 decimal = STDIN.gets.chomp\r
176                 decimal = "." + decimal\r
177                 decimal = nil if decimal == '.'\r
178                 decimal\r
179             end\r
180             \r
181          \r
183     get_cutter: |\r
184             #puts "|" , record , "|"\r
185             #puts "in the cutter proc"\r
186             if (record['952']) and (record['952']['c'] == ('BIO' or 'F'))\r
187                 print "This is a |#{record['952']['c']}|, so choose your cutter accordingly: "\r
188                 cutter = STDIN.gets.chomp\r
189                 cutter.upcase!\r
190                 return cutter\r
191             elsif record['100']\r
192                 cutter = record['100']['a'].dup\r
193             elsif record['110']\r
194                 cutter = record['110']['a'].dup\r
195             elsif record['111']\r
196                 cutter = record['111']['a'].dup\r
197             elsif record['130']\r
198                 cutter = record['130']['a'].dup\r
199             elsif record['245'].indicator1 == '0'\r
200                 cutter = record['245']['a']\r
201                 i = record['245'].indicator2.to_i\r
202                 cutter = cutter[i,99]\r
203             else\r
204                 print "What is the cutter for this book? "\r
205                 cutter = STDIN.gets.chomp\r
206             end\r
207             #puts cutter\r
208             #puts cutter.length\r
209             #puts cutter.jlength\r
210             #STDIN.gets\r
211             #puts cutter.usubstr(0, 3)\r
212                         \r
213             #STDIN.gets\r
214             if cutter.length == cutter.jlength\r
215                 cutter = cutter[0,4]\r
216                 #puts "cutter after slice", cutter\r
217                 cutter.gsub!("'", '')\r
218                 cutter.gsub!(" ", '')\r
219                 cutter = cutter[0,3]\r
220             else\r
221                 puts "This cutter appears to have multi-byte characters."\r
222                 print "What is the cutter for this book? "\r
223                 cutter = STDIN.gets.chomp\r
224             end\r
225              cutter.upcase!\r
226              puts "The final cutter: |#{cutter}|"\r
227              #puts cutter.jlength\r
228              cutter    \r
229         \r
231     get_cip_callnum: |\r
232         if record['942']['x'] == 'y'\r
233         print "What is the CIP call number? "\r
234         cipcall = STDIN.gets.chomp\r
235         cipcall\r
236         else\r
237           puts "Skipping CIP call number."          \r
238         end\r
239         \r
241     get_combined_callnum: |\r
242         #puts "into get_combined_callnum"\r
243         #puts record\r
244         #puts "**942 #{record['942']}"\r
245         #puts "**942k #{record['942']['k']}"\r
246         combined_callnum = record['942']['k'] if record['942']['k']\r
247         combined_callnum = combined_callnum + record['942']['j'] if record['942']['j'] \r
248         if record['942']['k']\r
249           combined_callnum = combined_callnum.to_s + " " + record['942']['l']\r
250         else\r
251           combined_callnum = record['942']['l']\r
252         end\r
254     barcode_and_itemnum: | \r
255         puts "BARCODE AND ITEMNUM!!!\a" if $testing\r
256         #STDIN.gets\r
257         #Dir.chdir("..") if Dir.pwd.include?('zoomer/saved')\r
258         #puts Dir.pwd\r
259         if $testing == 't'\r
260           iterator = File.new("~/.zcc/test-zoomer-iterator.txt", "r").gets\r
261         else\r
262           iterator = File.new("#{File.expand_path("~")}/.zcc/zoomer-iterator.txt", "r").gets \r
263         end\r
264         #iterator = File.new("test-zoomer-iterator.txt").gets if $testing == 't'\r
265         puts "iterator: #{iterator}"\r
266         iterator = iterator.chomp\r
267         barcode = "MRML-%05d" % iterator\r
268         new_iterator = iterator.to_i + 1\r
269         File.open("#{File.expand_path("~")}/.zcc/zoomer-iterator.txt", "w+") do |myfile|\r
270           myfile.write(new_iterator) unless $testing == 't'\r
271         end\r
272         record['952'].append(MARC::Subfield.new('p', barcode))\r
273         record['952'].append(MARC::Subfield.new('u', iterator))\r
274         \r