zcc 0.1.0 → 0.2.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.
@@ -1,3 +1,19 @@
1
+ == 0.2.0 Wed Nov 21 14:43:00 EST 2007
2
+ * This version is incompatible with previous versions.
3
+ * major changes:
4
+ * added full record editing using yaz-marcdump command line utility and
5
+ the plain text editor of your choice
6
+ * uses extended services of zoom-0.4.1 to save records to zebra database
7
+ * ability added to configure and pick from various different script to
8
+ be run over records
9
+ * minor changes:
10
+ * menu options and how choices work have changed
11
+ * shows whole record if only one is fetched
12
+ * added config option to automatically start and
13
+ kill a zebra server
14
+
15
+
16
+
1
17
  == 0.1.0
2
18
  * The version is incompatible with previous versions.
3
19
  * major changes:
@@ -6,10 +6,12 @@ Rakefile
6
6
  bin/zcc
7
7
  examples/linter.pl
8
8
  examples/zcc.yaml
9
+ examples/zebra/accessfile
9
10
  examples/zebra/key/remove_me
10
11
  examples/zebra/lock/remove_me
11
- examples/zebra/records/0.mrc
12
+ examples/zebra/records/0.xml
12
13
  examples/zebra/register/remove_me
14
+ examples/zebra/shadow/remove_me
13
15
  examples/zebra/tab/bib1.abs
14
16
  examples/zebra/tab/bib1.att
15
17
  examples/zebra/tab/default.idx
@@ -17,13 +19,13 @@ examples/zebra/tab/explain.abs
17
19
  examples/zebra/tab/explain.att
18
20
  examples/zebra/tab/explain.tag
19
21
  examples/zebra/tab/gils.att
20
- examples/zebra/tab/marc21.abs
21
22
  examples/zebra/tab/numeric.chr
22
23
  examples/zebra/tab/record.abs
23
24
  examples/zebra/tab/sort-string-utf.chr
24
25
  examples/zebra/tab/tagsetm.tag
25
26
  examples/zebra/tab/usmarc.mar
26
27
  examples/zebra/tab/word-phrase-utf.chr
28
+ examples/zebra/zcc_passw
27
29
  examples/zebra/zebra.cfg
28
30
  examples/zoomer-iterator.txt
29
31
  examples/zservers.yaml
@@ -33,9 +35,7 @@ lib/zcc/cli_display.rb
33
35
  lib/zcc/query.rb
34
36
  lib/zcc/record.rb
35
37
  lib/zcc/resultset.rb
36
- lib/zcc/subfieldeditor.rb
37
38
  lib/zcc/version.rb
38
- lib/zcc/zoomer.rb
39
39
  lib/zcc/zserver.rb
40
40
  scripts/txt2html
41
41
  setup.rb
data/Rakefile CHANGED
@@ -73,7 +73,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
73
73
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
74
74
  p.extra_deps = [
75
75
  ['marc','>=0.1.6'],
76
- ['zoom', '>=0.3.0'],
76
+ ['zoom', '>=0.4.1'],
77
77
  ['unicode','>=0.1'],
78
78
  ['highline', '>=1.2.9'],
79
79
  ['term-ansicolor', '>=1.0.2']
data/bin/zcc CHANGED
@@ -1,228 +1,352 @@
1
- #!/usr/bin/ruby -w
2
- ## Jason Ronallo
3
- # July, 2007
4
- #zcc-new
5
-
6
- require 'rubygems'
7
- require 'zoom'
8
- require 'marc'
9
- require 'highline/import'
10
- require 'term/ansicolor'
11
- #include Term::ANSIColor
12
-
13
- require 'stringio'
14
- require 'yaml'
15
- require 'tempfile'
16
-
17
- $KCODE = 'u'
18
- require 'jcode'
19
- require 'unicode'
20
-
21
- require 'zcc'
22
- include ZCC
23
-
24
- termsize = HighLine::SystemExtensions.terminal_size
25
- $term_width = termsize[0]
26
- $term_height = termsize[1]
27
- $clear_code = %x{clear}
28
- HighLine.track_eof = false
29
-
30
- ##Setting up testing parameter
31
- $testing = ARGV[0]
32
- $testing = nil unless $testing == 'v' or $testing == 't'
33
- file_mode = true if ARGV[0] == 'file'
34
- puts "We're testing " if $testing
35
- STDIN.gets if $testing
36
-
37
- #reading in config from yaml file
38
- yamlfile = YAML.load_file( "#{File.expand_path("~")}/.zcc/zcc.yaml" )
39
- zservers = yamlfile['zservers']
40
-
41
- if zservers[0][0] =~ /Include/
42
- filename = zservers[0][0][8, 99]
43
- contents = YAML.load_file("#{File.expand_path("~")}/.zcc/#{filename}")
44
- contents.each{|c| zservers.push(c)}
45
- zservers[0] = nil
46
- end
47
- zservers.compact!
48
-
49
- labels = yamlfile['labels']
50
- scripting = yamlfile['scripting']
51
- $procs = yamlfile['procs']
52
-
53
- TO_SHOW = yamlfile['to_show']
54
- SHOW_PER_PAGE = yamlfile['show_per_page']
55
- FIELDS_TO_SHOW = yamlfile['fields_to_show']
56
- HOW_TO_SAVE = yamlfile['save_filename']
57
- TIMESTAMP = Time.now.strftime("%Y%m%d%H%M%S")
58
- SCRIPTING = yamlfile['scripting_on']
59
- EDITING = yamlfile['subfield_editing']
60
- CSV = yamlfile['csv_on']
61
- LINTER = yamlfile['linter_on']
62
- FORMAT_TO_SAVE = yamlfile['save_record_syntax']
63
-
64
- print $clear_code
65
- #printed once when starting the program.
66
- say("Zcc, Copyright (C) 2007 Jason Ronallo\nZcc comes with ABSOLUTELY NO WARRANTY.\nZcc is released under the terms of the GPL v.2 or later.\nSee LICENSE for full information.\n".bold)
67
- say("Simply enter a title, LCCN or ISBN and hit enter.\nTitle: enter the title exactly as it is on the source\n for better relevancy ranking by title.\nLCCN: Include the dash, like 81-21962\nEnter ISBNs without dashes.\nNot all servers accept it, but you can also do a narrowing search\nby including an author's name after the title like so:\nFinnegans Wake :au Joyce")
68
- say("For more help see: http://zcc.rubyforge.org/zcc.html")
69
-
70
- zserver_objects = []
71
- zservers.each do |server|
72
- zserver_objects << Zserver.new(server[0], server[1], server[2], server[3])
73
- end
74
-
75
- server_h = Hash.new {|hash, key| hash[key] = [] }
76
- zserver_objects.each {|z| server_h[z.group] << z}
77
-
78
- groups = []
79
- server_h.each_key{|k| groups << k}
80
- groups.uniq!
81
- groups.sort!
82
-
83
- loop {
84
- search_term = ask("\nEnter search. [ISBN, title, LCCN (with dash), or :q to quit]\nsearch> ".boldz, String){ |q| q.readline = true }
85
- exit if search_term == ':q'
86
-
87
- taken = ResultSet.new
88
- groups.each do |group|
89
- print $clear_code
90
- servers = server_h[group]
91
- query = Query.new(search_term, servers)
92
- results = query.search(TO_SHOW)
93
- results.index_pos = SHOW_PER_PAGE - 1
94
- if results.records.empty?
95
- puts "There are no results from group #{group} servers!\n\n\n"
96
- another_group = ask("Do you want to continue searcing the next group of servers? [y], anything ".boldz)
97
- if another_group == 'y' || another_group == ''
98
- next
99
- else
100
- print $clear_code
101
- break
102
- end
103
- end
104
- results.rank_by_relevance!
105
- return_value = zcc_select_good_marc(results, 'multi')
106
- taken << results
107
- break if return_value == 'done'
108
- end
109
-
110
- taken.remove_unselected!
111
- next if taken.empty?
112
- continue = true
113
- print $clear_code
114
- say("\aThis is your combined result set.\nWe will winnow until you choose ".white.bold.on_black + "'done'".red.bold + "\nor you unselect all records.".white.bold.on_black)
115
- sleep 3
116
- while continue
117
- return_value = zcc_select_good_marc(taken, 'multi')
118
- continue = false if taken.selected_length == 0
119
- continue = false if return_value == 'done'
120
- end
121
- taken.remove_unselected!
122
- unless taken.length == 0
123
- puts "Here are the records you've selected for processing:"
124
- taken.each do |record|
125
- puts record.title
126
- end
127
- sleep 2
128
- end
129
-
130
- taken.records.each do |final_taken|
131
-
132
- #SCRIPTING and EDITING
133
- if SCRIPTING
134
- print $clear_code
135
- print "\a"
136
- say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
137
- say("SCRIPTING...".bold.white.on_black)
138
- final_taken.local_script(scripting)
139
- end
140
-
141
- if EDITING
142
- print $clear_code
143
- print "\a"
144
- say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
145
- edit = ask("Would you like to " + "edit".headline + " this record [yes or ANYTHING]? ")
146
- if edit == ('y' or 'yes')
147
- print $clear_code
148
- say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
149
- final_taken.edit
150
- end
151
- end
152
-
153
- print $clear_code
154
- say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
155
- say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
156
- say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
157
- to_save_or_not_to_save = ask("Would you like to keep this FINAL RECORD? (ANYTHING or n)")
158
-
159
- if to_save_or_not_to_save == 'n'
160
- next #if continue? == 'again'
161
- end
162
-
163
- if CSV
164
- print $clear_code
165
- print "\a"
166
- say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
167
- say("Label making time!".headline)
168
- csv = final_taken.marc_to_csv(labels)
169
- print "Final csv:\n#{csv}\n"
170
- end
171
-
172
- print $clear_code
173
- clear_code_do = false
174
-
175
-
176
- #saves in the directory in which zcc was run
177
- if HOW_TO_SAVE == 'search_term'
178
- filename = search_term.gsub(' ','_')
179
- elsif HOW_TO_SAVE == 'timestamp'
180
- filename = TIMESTAMP
181
- end
182
-
183
- FORMAT_TO_SAVE.each do |format|
184
- if format == 'marc'
185
- puts
186
- aFile = File.new("#{filename}\.mrc","a+")
187
- aFile.write(final_taken.marc.to_marc)
188
- puts "#{final_taken.marc['245']['a']} saved in #{filename}\.mrc"
189
- aFile.close
190
- puts
191
- elsif format == 'xml'
192
- #puts final_taken.marc.to_xml
193
- aFile = File.new("#{filename}\.xml","a+")
194
- aFile.write(final_taken.marc.to_xml)
195
- puts "#{final_taken.marc['245']['a']} saved in #{filename}\.xml"
196
- aFile.close
197
- elsif format == 'zebra'
198
- #puts final_taken.to_xml
199
- File.open("#{File.expand_path("~")}/.zcc/zebra/records/#{Time.now.strftime("%Y%m%d%H%M%S")}\.mrc", "w") do |f|
200
- f.write final_taken.marc.to_marc
201
- end
202
- Dir.chdir("#{File.expand_path("~")}/.zcc/zebra") do
203
- record_update = `zebraidx update records`
204
- puts record_update
205
- end
206
- #saving to koha2 is untested. Please let me know if it doesn't work--or even if it does.
207
- elsif format == 'koha2'
208
- puts
209
- out = Tempfile.new("koha2-")
210
- out << final_taken.marc.to_marc
211
- out.close
212
- koha_save = `perl /usr/local/koha/intranet/scripts/misc/migration_tools/bulkmarcimport.pl -v 6 -file #{out.path}`
213
- puts koha_save
214
- puts
215
- end
216
- end
217
-
218
- if CSV
219
- puts
220
- csvFile = File.new("csv-#{filename}\.txt","a+")
221
- csvFile.write(csv)
222
- puts "csv for #{final_taken.marc['245']['a']} saved in csv-#{filename}\.txt"
223
- csvFile.close
224
- puts
225
- end
226
- end
227
-
228
- }
1
+ #!/usr/bin/ruby -w
2
+ ## Jason Ronallo
3
+ # July, 2007
4
+ #zcc-new
5
+
6
+ require 'rubygems'
7
+ require 'zoom'
8
+ require 'marc'
9
+ require 'highline/import'
10
+ require 'term/ansicolor'
11
+ require 'getoptlong'
12
+ #include Term::ANSIColor
13
+
14
+ require 'stringio'
15
+ require 'yaml'
16
+ require 'tempfile'
17
+
18
+ $KCODE = 'u'
19
+ require 'jcode'
20
+ require 'unicode'
21
+
22
+ require 'zcc'
23
+ include ZCC
24
+ $testing = false
25
+ opts = GetoptLong.new( [ '--yaml', '-y', GetoptLong::REQUIRED_ARGUMENT ],
26
+ ['--testing', '-t', GetoptLong::NO_ARGUMENT]
27
+ )
28
+ opts_yaml =''
29
+ opts.each do |opt, arg|
30
+ case opt
31
+ when '--yaml'
32
+ opts_yaml = arg
33
+ when '--testing'
34
+ $testing = true
35
+ end
36
+ end
37
+
38
+ if opts_yaml.length > 0
39
+ file_yaml = opts_yaml
40
+ else
41
+ file_yaml = 'zcc.yaml'
42
+ end
43
+
44
+ termsize = HighLine::SystemExtensions.terminal_size
45
+ $term_width = termsize[0]
46
+ $term_height = termsize[1]
47
+ $clear_code = %x{clear}
48
+ HighLine.track_eof = false
49
+
50
+ ##Setting up testing parameter
51
+ #$testing = ARGV[0]
52
+ #$testing = nil unless $testing == 'v' or $testing == 't'
53
+
54
+ ## FIXME: make use of a 'file' version of zcc where records are not taken from zservers but from a file. Way to process a batch of records with the same scripting.
55
+ file_mode = true if ARGV[0] == 'file'
56
+
57
+ #reading in config from yaml file
58
+ begin
59
+ yamlfile = YAML.load_file( "#{file_yaml}" )
60
+ rescue Exception
61
+ puts "You must either start zcc in the same directory as a file named 'zcc.yaml' or give the '-yaml' switch with the full path to the yaml file which includes configuration information. This feature allows you to start zcc with different configuration files.\nzcc -yaml /home/jason/.zcc/zcc.yaml"
62
+ exit
63
+ end
64
+
65
+ labels = yamlfile['labels']
66
+ scripting = yamlfile['scripting']
67
+ #puts scripting.inspect
68
+ #gets
69
+ $procs = yamlfile['procs']
70
+
71
+ TO_SHOW = yamlfile['to_show']
72
+ SHOW_PER_PAGE = yamlfile['show_per_page']
73
+ FIELDS_TO_SHOW = yamlfile['fields_to_show']
74
+ HOW_TO_SAVE = yamlfile['save_filename']
75
+ TIMESTAMP = Time.now.strftime("%Y%m%d%H%M%S")
76
+ SCRIPTING = yamlfile['scripting_on']
77
+ EDITING = yamlfile['subfield_editing']
78
+ FULL_EDITING = yamlfile['full_editing']
79
+ TEXT_EDITOR = yamlfile['text_editor']
80
+ CSV = yamlfile['csv_on']
81
+ LINTER = yamlfile['linter_on']
82
+ FORMAT_TO_SAVE = yamlfile['save_record_syntax']
83
+ ROOT = yamlfile['root']
84
+ START_ZEBRA = yamlfile['start_zebra']
85
+ KILL_ZEBRA = yamlfile['kill_zebra']
86
+
87
+
88
+
89
+ def get_user_pass
90
+ user_pass = IO.read("#{ROOT}/zebra/zcc_passw").chomp
91
+ user, pass = user_pass.split(":")
92
+ end
93
+ USER, PASS = get_user_pass
94
+ puts "user |" + USER + "|"
95
+ puts "pass |" + PASS + "|"
96
+
97
+ def quit_routine
98
+ #print "killing zebra: "
99
+ puts $zebra_pid if $zebra_pid
100
+ Process.kill('TERM', $zebra_pid) if KILL_ZEBRA
101
+ exit
102
+ end
103
+
104
+ print $clear_code
105
+ #printed once when starting the program.
106
+ say("ZCC v. 0.2.0.\nZCC, Copyright (C) 2007 Jason Ronallo\nZcc comes with ABSOLUTELY NO WARRANTY.\nZcc is released under the terms of the GPL v.2 or later.\nSee LICENSE for full information.\n".bold)
107
+ say("Simply enter a title, LCCN or ISBN and hit enter.\nTitle: enter the title exactly as it is on the source\n for better relevancy ranking by title.\nLCCN: Include the dash, like 81-21962\nEnter ISBNs without dashes.\nNot all servers accept it, but you can also do a narrowing search\nby including an author's name after the title like so:\nFinnegans Wake :au Joyce")
108
+ say("For more help see: http://zcc.rubyforge.org/zcc.html")
109
+
110
+ #start zebra server if
111
+ if START_ZEBRA
112
+ Dir.chdir("#{ROOT}/zebra") do
113
+ $zebra_pid = fork do
114
+ STDERR.close
115
+ exec "zebrasrv @:9998 -l zebrasrv.log"
116
+ end
117
+ end
118
+ else
119
+ $zebra_pid = false
120
+ end
121
+
122
+ zservers = yamlfile['zservers']
123
+
124
+ if zservers[0][0] =~ /Include/
125
+ filename = zservers[0][0][8, 99]
126
+ contents = YAML.load_file("#{ROOT}/#{filename}")
127
+ contents.each{|c| zservers.push(c)}
128
+ zservers[0] = nil
129
+ end
130
+ zservers.compact!
131
+
132
+ zserver_objects = []
133
+ zservers.each do |server|
134
+ zserver_objects << Zserver.new(server[0], server[1], server[2], server[3])
135
+ end
136
+
137
+ server_h = Hash.new {|hash, key| hash[key] = [] }
138
+ zserver_objects.each {|z| server_h[z.group] << z}
139
+
140
+ groups = []
141
+ server_h.each_key{|k| groups << k}
142
+ groups.uniq!
143
+ groups.sort!
144
+
145
+ loop {
146
+ search_term = ask("\nEnter search. [ISBN, title, LCCN (with dash), or :q to quit]\nsearch> ".boldz, String){ |q| q.readline = true }
147
+ quit_routine if search_term == ':q'
148
+
149
+ taken = ResultSet.new
150
+ groups.each do |group|
151
+ print $clear_code
152
+ servers = server_h[group]
153
+ query = Query.new(search_term, servers)
154
+ results = query.search(TO_SHOW)
155
+ results.index_pos = SHOW_PER_PAGE - 1
156
+ if results.records.empty?
157
+ puts "There are no results from group #{group} servers!\n\n\n"
158
+ another_group = ask("Do you want to continue searching the next group of servers? [y], anything ".boldz)
159
+ if another_group == 'y' || another_group == ''
160
+ next
161
+ else
162
+ print $clear_code
163
+ break
164
+ end
165
+ end
166
+ results.rank_by_relevance!
167
+ return_value = zcc_select_good_marc(results, 'multi')
168
+ quit_routine if return_value == 'quit'
169
+ taken << results
170
+ break if return_value == 'done'
171
+ end
172
+
173
+ taken.remove_unselected!
174
+ next if taken.empty?
175
+ continue = true
176
+ print $clear_code
177
+ #say("\aThis is your combined result set.\nWe will winnow until you choose ".white.bold.on_black + "'done'".red.bold + "\nor you unselect all records.".white.bold.on_black)
178
+ #sleep 1
179
+ while continue
180
+ return_value = zcc_select_good_marc(taken, 'winnow')
181
+ quit_routine if return_value == 'quit'
182
+ continue = false if taken.selected_length == 0
183
+ continue = false if return_value == 'done'
184
+ end
185
+ taken.remove_unselected!
186
+ unless taken.length == 0
187
+ puts "Here are the records you've selected for processing:"
188
+ taken.each do |record|
189
+ puts record.title
190
+ end
191
+ #sleep 2
192
+ end
193
+
194
+ taken.records.each do |final_taken|
195
+ #puts final_taken.class; STDIN.gets
196
+ #SCRIPTING and EDITING
197
+ def which_script scripting
198
+ loop do
199
+ choose do |scripting_menu|
200
+ scripting_menu.layout = :list
201
+ scripting_menu.index = :number
202
+ scripting_menu.readline = true
203
+ scripting_menu.shell = true
204
+ scripting_menu.prompt = "Enter which script you would like to run on this record: "
205
+ scripting_menu.select_by = :index_or_name
206
+ scripting_menu.choice(:none, "No script will be run.") {|cmd, d| return 'none'}
207
+ scripting.each do |key, value|
208
+ unless key == 'start' || key == 'end'
209
+ scripting_menu.choice(key, "no help, ha!") do |cmd, d|
210
+ if cmd == :help
211
+ next
212
+ else
213
+ return scripting[cmd]
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+
222
+ def display_record record
223
+ print $clear_code
224
+ print "\a"
225
+ say("#{ZCC.zcc_marc_str_bold(record.to_s, 'record')}")
226
+ end
227
+
228
+ if SCRIPTING
229
+ display_record(final_taken)
230
+ picked_scripting = which_script scripting
231
+ display_record(final_taken)
232
+ say("SCRIPTING...".bold.white.on_black)
233
+ final_taken.local_script(scripting["start"]) if scripting["start"] && picked_scripting != 'none'
234
+ final_taken.local_script(picked_scripting) unless picked_scripting == 'none'
235
+ final_taken.local_script(scripting["end"]) if scripting["end"] && picked_scripting != 'none'
236
+ end
237
+
238
+ if EDITING
239
+ display_record(final_taken)
240
+ edit = ask("Would you like to " + "edit any subfields".headline + " in this record [yes or ANYTHING]? ")
241
+ if edit == ('y' or 'yes')
242
+ print $clear_code
243
+ say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
244
+ puts final_taken.class
245
+ final_taken.edit
246
+ end
247
+ end
248
+
249
+
250
+ if FULL_EDITING
251
+ display_record(final_taken)
252
+ edit2 = ask("Would you like to " + "edit".headline + " this record in" + " #{TEXT_EDITOR} ".headline + "[yes or ANYTHING]? ")
253
+ if edit2 == ('y' or 'yes')
254
+ print $clear_code
255
+ say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
256
+ final_taken.full_edit
257
+ end
258
+ end
259
+
260
+ print $clear_code
261
+ say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
262
+ say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
263
+ say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
264
+ to_save_or_not_to_save = ask("Would you like to keep this FINAL RECORD? (ANYTHING or n)")
265
+
266
+ if to_save_or_not_to_save == 'n'
267
+ next #if continue? == 'again'
268
+ end
269
+
270
+ if CSV
271
+ display_record(final_taken)
272
+ say("Label making time!".headline)
273
+ csv = final_taken.marc_to_csv(labels)
274
+ print "Final csv:\n#{csv}\n"
275
+ end
276
+
277
+ print $clear_code
278
+ clear_code_do = false
279
+
280
+
281
+ #saves in the directory in which zcc was run
282
+ if HOW_TO_SAVE == 'search_term'
283
+ filename = search_term.gsub(' ','_')
284
+ elsif HOW_TO_SAVE == 'timestamp'
285
+ filename = TIMESTAMP
286
+ end
287
+
288
+ FORMAT_TO_SAVE.each do |format|
289
+ if format == 'marc'
290
+ puts
291
+ aFile = File.new("#{filename}\.mrc","a+")
292
+ aFile.write(final_taken.marc.to_marc)
293
+ puts "#{final_taken.marc['245']['a']} saved in #{filename}\.mrc"
294
+ aFile.close
295
+ puts
296
+ elsif format == 'xml'
297
+ #puts final_taken.marc.to_xml
298
+ aFile = File.new("#{filename}\.xml","a+")
299
+ aFile.write(final_taken.marc.to_xml)
300
+ puts "#{final_taken.marc['245']['a']} saved in #{filename}\.xml"
301
+ aFile.close
302
+ elsif format == 'zebra'
303
+ #create the recordID which zebra will use to index
304
+ t = Time.now
305
+ the_time = "%10.6f" % t.to_f
306
+ final_taken.marc.append(MARC::DataField.new('901', '0', '1', ['a', "#{the_time}"])) unless final_taken.marc['901'] && final_taken.marc['901']['a']
307
+
308
+ #connect to zebrasrv and insert record
309
+ conn = ZOOM::Connection.new('user' => USER, 'password' => PASS).connect('localhost:9998/zcc')
310
+ p = conn.package
311
+ p.wait_action = 'waitIfPossible'
312
+ p.action = 'specialUpdate'
313
+ p.record = final_taken.marc.to_xml
314
+ p.send('update')
315
+ p.send('commit')
316
+ puts "Finished commit of #{final_taken.marc['245']['a']} to zebra server."
317
+
318
+ #place backup filesystem copy in zebra directory
319
+ #with extended services the record is saved to zebra internal store
320
+ #this also saves it to the file system
321
+ File.open("#{ROOT}/zebra/records/#{final_taken.marc['901']['a']}\.xml", "w") do |f|
322
+ f.write final_taken.marc.to_xml
323
+ end
324
+ elsif format == 'koha2'
325
+ puts
326
+ out = Tempfile.new("koha2-")
327
+ out << final_taken.marc.to_marc
328
+ out.close
329
+ koha_save = `perl /usr/local/koha/intranet/scripts/misc/migration_tools/bulkmarcimport.pl -v 6 -file #{out.path}`
330
+ puts koha_save
331
+ puts
332
+ end
333
+ end
334
+
335
+ if CSV
336
+ puts
337
+ csvFile = File.new("csv-#{filename}\.txt","a+")
338
+ csvFile.write(csv)
339
+ puts "csv for #{final_taken.marc['245']['a']} saved in csv-#{filename}\.txt"
340
+ csvFile.close
341
+ puts
342
+ end
343
+ end
344
+
345
+ }
346
+
347
+
348
+
349
+
350
+
351
+
352
+