zcc 0.0.3 → 0.1.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.
- data/History.txt +15 -0
- data/Manifest.txt +12 -19
- data/Rakefile +2 -1
- data/bin/zcc +228 -202
- data/examples/zcc.yaml +21 -12
- data/examples/zebra/{register/empty → key/remove_me} +1 -1
- data/examples/zebra/{key/empty → lock/remove_me} +1 -1
- data/examples/zebra/records/0.mrc +1 -0
- data/examples/zebra/{lock/empty → register/remove_me} +1 -1
- data/examples/zebra/tab/marc21.abs +67 -0
- data/examples/zebra/tab/record.abs +1 -0
- data/examples/zebra/zebra.cfg +2 -2
- data/examples/zservers.yaml +869 -0
- data/lib/zcc.rb +8 -0
- data/lib/zcc/ansicolorz.rb +26 -0
- data/lib/zcc/cli_display.rb +461 -0
- data/lib/zcc/query.rb +183 -0
- data/lib/zcc/record.rb +265 -0
- data/lib/zcc/resultset.rb +169 -0
- data/lib/zcc/version.rb +2 -2
- data/lib/zcc/zoomer.rb +16 -2
- data/lib/zcc/zserver.rb +38 -0
- data/website/index.html +1 -1
- data/website/koha.html +18 -10
- data/website/koha.txt +13 -8
- data/website/zcc.html +35 -33
- data/website/zcc.txt +30 -32
- data/website/zebra.html +57 -15
- data/website/zebra.txt +56 -15
- metadata +23 -21
- data/examples/zebra/README +0 -2
- data/examples/zebra/records/examples/0.xml +0 -1
- data/examples/zebra/records/examples/1.xml +0 -1
- data/examples/zebra/records/examples/2.xml +0 -1
- data/examples/zebra/records/examples/3.xml +0 -1
- data/examples/zebra/records/examples/4.xml +0 -1
- data/examples/zebra/records/examples/5.xml +0 -1
- data/examples/zebra/records/examples/6.xml +0 -1
- data/examples/zebra/records/examples/7.xml +0 -1
- data/examples/zebra/records/examples/8.xml +0 -1
- data/examples/zebra/records/examples/9.xml +0 -1
- data/examples/zebra/shadow/empty +0 -1
- data/examples/zebra/tab/kohalis +0 -1
- data/examples/zebra/tmp/empty +0 -1
- data/lib/zcc/marcadditions.rb +0 -221
- data/lib/zcc/pickers.rb +0 -176
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 0.1.0
|
2
|
+
* The version is incompatible with previous versions.
|
3
|
+
* major changes:
|
4
|
+
* Major rewrite of the code to make the library more object oriented and reusable. Major improvements here include the ability of records to carry around the z-target source.
|
5
|
+
* Added dependency to gem term-ansicolor.
|
6
|
+
* Rewrite of menuing system to utilize HighLine and add functionality like better help. Adding new functionality is now much easier as well.
|
7
|
+
* Corrected some configuration issues with zebra that should allow it to work with different installations and changed to storing MARC21 instead of MARCXML.
|
8
|
+
* Threaded searches. Ability to group Z39.50 targets and search them in parallel.
|
9
|
+
* Added option to save directly to Koha-2.2.X
|
10
|
+
* minor changes:
|
11
|
+
* Simple relevancy ranking on title searches.
|
12
|
+
* Fields that show in browse are configurable as well as the number of records to show per page.
|
13
|
+
* Sorting of records in browse, selected record highlighting, forwards and backwards through result set.
|
14
|
+
* Search error logging so user can remove bad z-targets--or report a bug in zcc :)
|
15
|
+
|
1
16
|
== 0.0.3
|
2
17
|
* major changes:
|
3
18
|
* added dependencies to Rakefile
|
data/Manifest.txt
CHANGED
@@ -6,21 +6,10 @@ Rakefile
|
|
6
6
|
bin/zcc
|
7
7
|
examples/linter.pl
|
8
8
|
examples/zcc.yaml
|
9
|
-
examples/zebra/key/
|
10
|
-
examples/zebra/lock/
|
11
|
-
examples/zebra/
|
12
|
-
examples/zebra/register/
|
13
|
-
examples/zebra/records/examples/0.xml
|
14
|
-
examples/zebra/records/examples/1.xml
|
15
|
-
examples/zebra/records/examples/2.xml
|
16
|
-
examples/zebra/records/examples/3.xml
|
17
|
-
examples/zebra/records/examples/4.xml
|
18
|
-
examples/zebra/records/examples/5.xml
|
19
|
-
examples/zebra/records/examples/6.xml
|
20
|
-
examples/zebra/records/examples/7.xml
|
21
|
-
examples/zebra/records/examples/8.xml
|
22
|
-
examples/zebra/records/examples/9.xml
|
23
|
-
examples/zebra/shadow/empty
|
9
|
+
examples/zebra/key/remove_me
|
10
|
+
examples/zebra/lock/remove_me
|
11
|
+
examples/zebra/records/0.mrc
|
12
|
+
examples/zebra/register/remove_me
|
24
13
|
examples/zebra/tab/bib1.abs
|
25
14
|
examples/zebra/tab/bib1.att
|
26
15
|
examples/zebra/tab/default.idx
|
@@ -28,22 +17,26 @@ examples/zebra/tab/explain.abs
|
|
28
17
|
examples/zebra/tab/explain.att
|
29
18
|
examples/zebra/tab/explain.tag
|
30
19
|
examples/zebra/tab/gils.att
|
31
|
-
examples/zebra/tab/
|
20
|
+
examples/zebra/tab/marc21.abs
|
32
21
|
examples/zebra/tab/numeric.chr
|
33
22
|
examples/zebra/tab/record.abs
|
34
23
|
examples/zebra/tab/sort-string-utf.chr
|
35
24
|
examples/zebra/tab/tagsetm.tag
|
36
25
|
examples/zebra/tab/usmarc.mar
|
37
26
|
examples/zebra/tab/word-phrase-utf.chr
|
38
|
-
examples/zebra/tmp/empty
|
39
27
|
examples/zebra/zebra.cfg
|
40
28
|
examples/zoomer-iterator.txt
|
29
|
+
examples/zservers.yaml
|
41
30
|
lib/zcc.rb
|
42
|
-
lib/zcc/
|
43
|
-
lib/zcc/
|
31
|
+
lib/zcc/ansicolorz.rb
|
32
|
+
lib/zcc/cli_display.rb
|
33
|
+
lib/zcc/query.rb
|
34
|
+
lib/zcc/record.rb
|
35
|
+
lib/zcc/resultset.rb
|
44
36
|
lib/zcc/subfieldeditor.rb
|
45
37
|
lib/zcc/version.rb
|
46
38
|
lib/zcc/zoomer.rb
|
39
|
+
lib/zcc/zserver.rb
|
47
40
|
scripts/txt2html
|
48
41
|
setup.rb
|
49
42
|
test/test_helper.rb
|
data/Rakefile
CHANGED
@@ -75,7 +75,8 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
75
75
|
['marc','>=0.1.6'],
|
76
76
|
['zoom', '>=0.3.0'],
|
77
77
|
['unicode','>=0.1'],
|
78
|
-
['highline', '>=1.2.9']
|
78
|
+
['highline', '>=1.2.9'],
|
79
|
+
['term-ansicolor', '>=1.0.2']
|
79
80
|
] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
80
81
|
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
81
82
|
end
|
data/bin/zcc
CHANGED
@@ -1,202 +1,228 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
## Jason Ronallo
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
require '
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
|
21
|
-
require '
|
22
|
-
|
23
|
-
|
24
|
-
termsize = HighLine::SystemExtensions.terminal_size
|
25
|
-
$term_width = termsize[0]
|
26
|
-
$term_height = termsize[1]
|
27
|
-
$clear_code = %x{clear}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
puts "
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
print
|
135
|
-
|
136
|
-
say("
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
aFile.
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
puts
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
}
|
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
|
+
}
|