zcc 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/lib/zcc/pickers.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
module ZCC
|
2
|
-
def ZCC.display_menu(rec_copy, index)
|
3
|
-
field_width = $term_width - 8
|
4
|
-
say("<%= color(\"#{index}\", :index) %> ")
|
5
|
-
['245', '260', '300'].each do |field|
|
6
|
-
string = rec_copy[index][field].to_s
|
7
|
-
string.rstrip!
|
8
|
-
string.lstrip!
|
9
|
-
if string.length < field_width
|
10
|
-
say("\t#{ZCC.zcc_marc_str_bold(string, field)}")
|
11
|
-
else
|
12
|
-
better_string = ZCC.wrap_field(string, field_width)
|
13
|
-
#puts better_string
|
14
|
-
say("\t#{ZCC.zcc_marc_str_bold(better_string, field)}")
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
#currently this goes word by word. how difficult to go field by subfield?
|
21
|
-
def ZCC.wrap_field(s, width)
|
22
|
-
lines = []
|
23
|
-
line = ""
|
24
|
-
smaller_width = width - 7
|
25
|
-
s.split(/\s+/).each do |word|
|
26
|
-
if (line.size + word.size) >= (width - 3)
|
27
|
-
lines << line
|
28
|
-
line = word
|
29
|
-
width = smaller_width
|
30
|
-
elsif line.empty?
|
31
|
-
line = word
|
32
|
-
else
|
33
|
-
line << " " << word
|
34
|
-
end
|
35
|
-
end
|
36
|
-
lines << line if line
|
37
|
-
return lines.join "\n\t\t"
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def ZCC.zcc_marc_str_bold(string, field)
|
42
|
-
#puts field
|
43
|
-
string.gsub!("'", "\'")
|
44
|
-
#string.gsub!("(", "\(")
|
45
|
-
#string.gsub!(")", "\)")
|
46
|
-
if field == '245'
|
47
|
-
string.gsub!(/(\$a\s)(.*?)(\$.)/, "\\1<%= color(\"\\2\", :field_hilite) %>\\3")
|
48
|
-
elsif field == '260'
|
49
|
-
#puts 'gets here'
|
50
|
-
string.gsub!(/(\$c\s)([\[0-9A-Za-z\]]*)(.|$)/, "\\1<%= color(\"\\2\", :field_hilite) %>\\3")
|
51
|
-
|
52
|
-
#string.gsub!(/(\$c)(.*)(\$\s)/, "\\1<%= color(\"\\2\", :field_hilite) %>\\3")
|
53
|
-
#string.gsub!(/(\$c)(.*)(\.|$)/, "\\1<%= color(\"\\2\", :field_hilite) %>\\3")
|
54
|
-
elsif field == '300'
|
55
|
-
string.gsub!(/(\$a)(.*?)(\$|$)/, "\\1<%= color(\"\\2\", :field_hilite) %>\\3")
|
56
|
-
elsif field == 'record'
|
57
|
-
string.sub!(/(LEADER.{19})(.{1})/, "\\1<%= color(\"\\2\", :headline) %>") #colorizes the value of the standard (AACR2, ISBD, or none)
|
58
|
-
end
|
59
|
-
|
60
|
-
string.gsub!( /\$(.)/, "<%= color('$\\1', :marc_tag) %>" )
|
61
|
-
string.gsub!( /^(\d\d\d)\s/, "<%= color('\\1 ', :marc_tag) %>")
|
62
|
-
string
|
63
|
-
end
|
64
|
-
|
65
|
-
def ZCC.not_valid_value
|
66
|
-
print $clear_code
|
67
|
-
say("\a<%= color(\"That's not a valid value. Try again.\", :headline) %> ")
|
68
|
-
sleep 1
|
69
|
-
print "\a"
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
class Array
|
77
|
-
def zcc_select_good_marc(take_how_many)
|
78
|
-
#puts self[0]
|
79
|
-
unless self[0].is_a? MARC::Record
|
80
|
-
raise ArgumentError, "This Array doesn't have a MARC::Record!" end
|
81
|
-
#puts self
|
82
|
-
rec_copy = self.dup
|
83
|
-
rec_copy = rec_copy.sort_by {|rec| rec['245']['a']}
|
84
|
-
|
85
|
-
recs_to_return = []
|
86
|
-
loop {
|
87
|
-
print $clear_code
|
88
|
-
rec_copy.each_index do |index|
|
89
|
-
ZCC.display_menu(rec_copy, index)
|
90
|
-
puts "\n\n"
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
whichrec = ''
|
95
|
-
if take_how_many =='one'
|
96
|
-
whichrec = ask("\n<%= color('Enter # | s# | c#-# | l# | none :', UNDERLINE) %> ", String){ |q| q.readline = true }
|
97
|
-
else
|
98
|
-
whichrec = ask("\n<%= color('Enter # | n | s# | c#-# | l# | d :', UNDERLINE) %> ", String){ |q| q.readline = true }
|
99
|
-
end
|
100
|
-
|
101
|
-
#puts "whichrec #{whichrec[0,1]}"
|
102
|
-
#puts whichrec.class
|
103
|
-
#whichrec = whichrec.to_i unless whichrec.respond_to?(:upcase)
|
104
|
-
first_bit = whichrec[0,1]
|
105
|
-
puts "whichrec is an Integer" if whichrec.is_a?(Integer)
|
106
|
-
see_num = whichrec[1,9].to_i
|
107
|
-
if first_bit == 's'
|
108
|
-
print $clear_code
|
109
|
-
print "\a"
|
110
|
-
say("#{ZCC.zcc_marc_str_bold(rec_copy[see_num].to_s, 'record')}")
|
111
|
-
ask("<%= color('Hit ENTER to continue...', :headline) %> ")
|
112
|
-
#STDIN.gets
|
113
|
-
next
|
114
|
-
elsif first_bit == 'c'
|
115
|
-
say("<%= color('comparison:', :headline) %> ")
|
116
|
-
comparison = whichrec[1,99]
|
117
|
-
compare_nums = comparison.split('-')
|
118
|
-
rec_copy[compare_nums[0].to_i].compare_marc(rec_copy[compare_nums[1].to_i])
|
119
|
-
ask("<%= color('Hit ENTER to continue...', :headline) %> ")
|
120
|
-
#STDIN.gets
|
121
|
-
next
|
122
|
-
elsif first_bit == 'l'
|
123
|
-
#puts rec_copy[whichrec[1,99].to_i]
|
124
|
-
#gets
|
125
|
-
rec_copy[whichrec[1,99].to_i].linter
|
126
|
-
ask("<%= color('Hit ENTER to continue...', :headline) %> ")
|
127
|
-
#STDIN.gets
|
128
|
-
next
|
129
|
-
elsif take_how_many == 'one'
|
130
|
-
if ( whichrec == 'none' )
|
131
|
-
puts "Since you cannot decide on a good record, please refer the book to a cataloger."
|
132
|
-
return "none"
|
133
|
-
elsif ( first_bit =~ /[a-z]/i or whichrec == '' )
|
134
|
-
ZCC.not_valid_value
|
135
|
-
next
|
136
|
-
else
|
137
|
-
if whichrec.to_i > (rec_copy.length - 1)
|
138
|
-
puts "Your number exceeds the number of records in your retrieved set."
|
139
|
-
next
|
140
|
-
else
|
141
|
-
return recs_to_return << rec_copy[whichrec.to_i]
|
142
|
-
end
|
143
|
-
end
|
144
|
-
elsif take_how_many == 'multi'
|
145
|
-
if whichrec == 'd'
|
146
|
-
puts "You will not search any more zservers!"
|
147
|
-
recs_to_return << "done"
|
148
|
-
elsif ( whichrec == 'n' or whichrec == '' )
|
149
|
-
puts "recs that will be returned #{recs_to_return.length}"
|
150
|
-
return recs_to_return
|
151
|
-
elsif whichrec[0,1] =~ /[a-z]/i
|
152
|
-
ZCC.not_valid_value
|
153
|
-
next
|
154
|
-
else
|
155
|
-
if whichrec.to_i > (rec_copy.length - 1)
|
156
|
-
puts "Your number exceeds the number of records in your retrieved set."
|
157
|
-
next
|
158
|
-
else
|
159
|
-
#puts "adding record to recs_to_return"
|
160
|
-
recs_to_return << rec_copy[whichrec.to_i]
|
161
|
-
#puts "recs_to_return.length #{recs_to_return.length}"
|
162
|
-
next
|
163
|
-
end
|
164
|
-
end
|
165
|
-
else
|
166
|
-
puts "That's not a valid value take_how_many value to pass into select_good_marc!"
|
167
|
-
end
|
168
|
-
#puts "group whichrec.to_i #{whichrec.to_i}"
|
169
|
-
return recs_to_return
|
170
|
-
}
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
|
176
|
-
|