code_zauker 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/czindexer +12 -1
- data/bin/czsearch +31 -8
- data/bin/mczindexer +1 -1
- data/devel.org +10 -0
- data/doc/CodeZauker/CliUtil.html +451 -0
- data/doc/CodeZauker/FileScanner.html +357 -190
- data/doc/CodeZauker/IndexManager.html +331 -0
- data/doc/CodeZauker/Util.html +65 -46
- data/doc/CodeZauker.html +58 -25
- data/doc/Grep.html +29 -19
- data/doc/_index.html +49 -23
- data/doc/class_list.html +12 -6
- data/doc/css/full_list.css +4 -2
- data/doc/css/style.css +50 -44
- data/doc/file_list.html +12 -6
- data/doc/frames.html +20 -5
- data/doc/index.html +49 -23
- data/doc/js/app.js +29 -26
- data/doc/js/full_list.js +9 -9
- data/doc/js/jquery.js +4 -16
- data/doc/method_list.html +66 -12
- data/doc/top-level-namespace.html +40 -18
- data/etc/redis.conf +3 -3
- data/lib/code_zauker/cli.rb +16 -1
- data/lib/code_zauker/constants.rb +7 -1
- data/lib/code_zauker/version.rb +2 -1
- data/lib/code_zauker.rb +85 -3
- data/readme.org +19 -22
- data/test/fixture/wildtest.txt +1 -0
- data/test/test_wild_search.rb +39 -0
- metadata +20 -16
data/bin/czindexer
CHANGED
@@ -43,7 +43,11 @@ optparse= OptionParser.new do |opts|
|
|
43
43
|
exit
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
options[:check_index]=false
|
47
|
+
opts.on( '-c', '--check-index', 'Do a sanity check of the index before starting') do
|
48
|
+
options[:check_index]=true
|
49
|
+
end
|
50
|
+
|
47
51
|
end
|
48
52
|
|
49
53
|
|
@@ -98,7 +102,14 @@ def processElement(l,fs,options)
|
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
105
|
+
################# MAIN STARTS HERE
|
101
106
|
|
107
|
+
if options[:check_index]
|
108
|
+
fixConn=Redis.new(:host => options[:redis_host], :port => options[:redis_port], :password=> options[:redis_password])
|
109
|
+
im=CodeZauker::IndexManager.new(fixConn)
|
110
|
+
im.check_repair()
|
111
|
+
exit
|
112
|
+
end
|
102
113
|
|
103
114
|
begin
|
104
115
|
$CUMULATED_TIME=0
|
data/bin/czsearch
CHANGED
@@ -23,6 +23,7 @@ optparse= OptionParser.new do |opts|
|
|
23
23
|
options[:redis_host]="127.0.0.1"
|
24
24
|
options[:redis_port]=6379
|
25
25
|
options[:redis_password]=nil
|
26
|
+
options[:be_wild]=false
|
26
27
|
|
27
28
|
opts.on('-i', '--ignore-case','ignore case distinctions') do
|
28
29
|
options[:ignorecase]=true
|
@@ -41,7 +42,6 @@ optparse= OptionParser.new do |opts|
|
|
41
42
|
options[:precontext]=options[:postcontext]
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
45
|
|
46
46
|
|
47
47
|
opts.on('-X','--exclude FILE_PATTERN',String,
|
@@ -49,6 +49,11 @@ optparse= OptionParser.new do |opts|
|
|
49
49
|
options[:file_to_exclude].push(/#{Regexp.escape(p)}/i);
|
50
50
|
end
|
51
51
|
|
52
|
+
opts.on('-w','--wild','Do a wildcharacter search. * means "every char". Imply -i') do
|
53
|
+
options[:be_wild] = true
|
54
|
+
options[:ignorecase]=true
|
55
|
+
end
|
56
|
+
|
52
57
|
|
53
58
|
opts.on('-h','--redis-server pass@SERVER:port', String,
|
54
59
|
'Specify the alternate redis server to use')do |server|
|
@@ -67,8 +72,7 @@ optparse= OptionParser.new do |opts|
|
|
67
72
|
|
68
73
|
|
69
74
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
70
|
-
puts opts
|
71
|
-
puts "Options are grep-like"
|
75
|
+
puts opts
|
72
76
|
puts "EXAMPLES:"
|
73
77
|
puts "czsearch ciao Koros"
|
74
78
|
puts " Will search Koros OR ciao"
|
@@ -76,6 +80,8 @@ optparse= OptionParser.new do |opts|
|
|
76
80
|
puts " Will match also GNU and Gnu"
|
77
81
|
puts "czsearch -X .orig -X .bak -X .java html:select"
|
78
82
|
puts " Will skip java and backup file"
|
83
|
+
puts "czsearch -w 'public*class School'"
|
84
|
+
puts " Will seach for a java class called School ignoring characters between public and class."
|
79
85
|
exit
|
80
86
|
end
|
81
87
|
end
|
@@ -86,13 +92,23 @@ ARGV.each do | s |
|
|
86
92
|
util=CodeZauker::Util.new()
|
87
93
|
redisConnection=Redis.new(:host => options[:redis_host], :port => options[:redis_port], :password=> options[:redis_password])
|
88
94
|
fs=CodeZauker::FileScanner.new(redisConnection)
|
89
|
-
|
90
|
-
|
91
|
-
|
95
|
+
|
96
|
+
if options[:be_wild]==true
|
97
|
+
puts "Wild MODE"
|
98
|
+
cli=CodeZauker::CliUtil.new()
|
99
|
+
r=cli.doWildSearch(s,fs)
|
100
|
+
files= r[:files]
|
101
|
+
pattern=r[:regexp]
|
92
102
|
else
|
93
|
-
|
94
|
-
|
103
|
+
if options[:ignorecase]==false
|
104
|
+
files=fs.search(s)
|
105
|
+
pattern=/#{Regexp.escape(s)}/
|
106
|
+
else
|
107
|
+
files=fs.isearch(s)
|
108
|
+
pattern=/#{Regexp.escape(s)}/i
|
109
|
+
end
|
95
110
|
end
|
111
|
+
|
96
112
|
files.each do |f|
|
97
113
|
to_exclude=false
|
98
114
|
if options[:file_to_exclude].length >0
|
@@ -107,6 +123,13 @@ ARGV.each do | s |
|
|
107
123
|
end
|
108
124
|
end
|
109
125
|
end
|
126
|
+
|
127
|
+
# Does it exist?
|
128
|
+
if !to_exclude && !File.exists?(f)
|
129
|
+
#puts "WARN: Not FOUND #{f}"
|
130
|
+
to_exclude=true
|
131
|
+
end
|
132
|
+
|
110
133
|
if !to_exclude
|
111
134
|
begin
|
112
135
|
if util.is_pdf?(f)==false
|
data/bin/mczindexer
CHANGED
data/devel.org
CHANGED
@@ -16,3 +16,13 @@ Case Sensitive case:yes
|
|
16
16
|
** Reference
|
17
17
|
http://www.rubyinside.com/21-ruby-tricks-902.html
|
18
18
|
|
19
|
+
|
20
|
+
* Aws tests
|
21
|
+
** Micro instance
|
22
|
+
Without multiplexing you get 4m39.599s
|
23
|
+
for indexing code_zauker
|
24
|
+
|
25
|
+
With
|
26
|
+
time find . -type f -print0 | xargs -0 -P 10 -n 20 ./bin/czindexer -v --redis-server awsserver
|
27
|
+
You get about 0m31.284s
|
28
|
+
|
@@ -0,0 +1,451 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: CodeZauker::CliUtil
|
8
|
+
|
9
|
+
— Code Zauker 0.0.8 Documentation
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../CodeZauker.html" title="CodeZauker (module)">CodeZauker</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">CliUtil</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: CodeZauker::CliUtil
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">CodeZauker::CliUtil</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<dt class="r2 last">Defined in:</dt>
|
97
|
+
<dd class="r2 last">lib/code_zauker/cli.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
<h2>
|
111
|
+
Instance Method Summary
|
112
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
113
|
+
</h2>
|
114
|
+
|
115
|
+
<ul class="summary">
|
116
|
+
|
117
|
+
<li class="public ">
|
118
|
+
<span class="summary_signature">
|
119
|
+
|
120
|
+
<a href="#do_report-instance_method" title="#do_report (instance method)">- (Object) <strong>do_report</strong>(redis) </a>
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
</span>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
135
|
+
|
136
|
+
</li>
|
137
|
+
|
138
|
+
|
139
|
+
<li class="public ">
|
140
|
+
<span class="summary_signature">
|
141
|
+
|
142
|
+
<a href="#doWildSearch-instance_method" title="#doWildSearch (instance method)">- (Object) <strong>doWildSearch</strong>(term, fileScanner) </a>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
</span>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
157
|
+
|
158
|
+
</li>
|
159
|
+
|
160
|
+
|
161
|
+
<li class="public ">
|
162
|
+
<span class="summary_signature">
|
163
|
+
|
164
|
+
<a href="#parse_host_options-instance_method" title="#parse_host_options (instance method)">- (Object) <strong>parse_host_options</strong>(connection_string) </a>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
</span>
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<div id="instance_method_details" class="method_details_list">
|
189
|
+
<h2>Instance Method Details</h2>
|
190
|
+
|
191
|
+
|
192
|
+
<div class="method_details first">
|
193
|
+
<h3 class="signature first" id="do_report-instance_method">
|
194
|
+
|
195
|
+
- (<tt>Object</tt>) <strong>do_report</strong>(redis)
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
</h3><table class="source_code">
|
202
|
+
<tr>
|
203
|
+
<td>
|
204
|
+
<pre class="lines">
|
205
|
+
|
206
|
+
|
207
|
+
54
|
208
|
+
55
|
209
|
+
56
|
210
|
+
57
|
211
|
+
58
|
212
|
+
59
|
213
|
+
60
|
214
|
+
61
|
215
|
+
62
|
216
|
+
63
|
217
|
+
64
|
218
|
+
65
|
219
|
+
66
|
220
|
+
67
|
221
|
+
68
|
222
|
+
69
|
223
|
+
70
|
224
|
+
71
|
225
|
+
72
|
226
|
+
73
|
227
|
+
74
|
228
|
+
75
|
229
|
+
76
|
230
|
+
77
|
231
|
+
78
|
232
|
+
79
|
233
|
+
80
|
234
|
+
81
|
235
|
+
82
|
236
|
+
83
|
237
|
+
84
|
238
|
+
85
|
239
|
+
86
|
240
|
+
87
|
241
|
+
88
|
242
|
+
89
|
243
|
+
90
|
244
|
+
91
|
245
|
+
92
|
246
|
+
93
|
247
|
+
94</pre>
|
248
|
+
</td>
|
249
|
+
<td>
|
250
|
+
<pre class="code"><span class="info file"># File 'lib/code_zauker/cli.rb', line 54</span>
|
251
|
+
|
252
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_do_report'>do_report</span><span class='lparen'>(</span><span class='id identifier rubyid_redis'>redis</span><span class='rparen'>)</span>
|
253
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Simple Reporting....on </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
254
|
+
<span class='id identifier rubyid_id2filename'>id2filename</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:id2filename:*</span><span class='tstring_end'>"</span></span>
|
255
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>File Stored:\t\t</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id2filename'>id2filename</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
256
|
+
<span class='id identifier rubyid_processedFiles'>processedFiles</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_scard'>scard</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:processedFiles</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
257
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Processed Files:\t</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_processedFiles'>processedFiles</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
258
|
+
<span class='comment'># Complex... compute average "fscan:trigramsOnFile:#{fid}"
|
259
|
+
</span> <span class='id identifier rubyid_sum'>sum</span><span class='op'>=</span><span class='float'>0.0</span>
|
260
|
+
<span class='id identifier rubyid_max'>max</span><span class='op'>=</span><span class='int'>0</span>
|
261
|
+
<span class='id identifier rubyid_min'>min</span><span class='op'>=</span><span class='int'>90000000000000000</span>
|
262
|
+
<span class='id identifier rubyid_fileName2Ids'>fileName2Ids</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:id:*</span><span class='tstring_end'>"</span></span>
|
263
|
+
<span class='id identifier rubyid_count'>count</span><span class='op'>=</span><span class='id identifier rubyid_fileName2Ids'>fileName2Ids</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='op'>+</span><span class='float'>0.0</span>
|
264
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Finding ids...</span><span class='tstring_end'>"</span></span>
|
265
|
+
<span class='id identifier rubyid_ids'>ids</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_mget'>mget</span><span class='lparen'>(</span><span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:id:*</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
266
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Scanning ids...</span><span class='tstring_end'>"</span></span>
|
267
|
+
<span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span> <span class='id identifier rubyid_fid'>fid</span> <span class='op'>|</span>
|
268
|
+
<span class='comment'># Forma fscan:trigramsOnFile:5503
|
269
|
+
</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_scard'>scard</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:trigramsOnFile:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fid'>fid</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
270
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>+</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span>
|
271
|
+
<span class='comment'># if trigramsOnFile == 0 or trigramsOnFile >=max
|
272
|
+
</span> <span class='comment'># fname=redis.get("fscan:id2filename:#{fid}")
|
273
|
+
</span> <span class='comment'># puts "Note fscan:trigramsOnFile:#{fid} -> #{trigramsOnFile} #{fname}"
|
274
|
+
</span> <span class='comment'># end
|
275
|
+
</span> <span class='id identifier rubyid_max'>max</span><span class='op'>=</span><span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span> <span class='kw'>if</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span> <span class='op'>></span><span class='id identifier rubyid_max'>max</span>
|
276
|
+
<span class='id identifier rubyid_min'>min</span><span class='op'>=</span><span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span> <span class='kw'>if</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span> <span class='op'><</span><span class='id identifier rubyid_min'>min</span> <span class='kw'>and</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span><span class='op'>></span><span class='int'>0</span>
|
277
|
+
<span class='kw'>end</span>
|
278
|
+
<span class='id identifier rubyid_av'>av</span><span class='op'>=</span><span class='id identifier rubyid_sum'>sum</span><span class='op'>/</span><span class='id identifier rubyid_count'>count</span>
|
279
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Average Trigrams per file:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_av'>av</span><span class='rbrace'>}</span><span class='tstring_content'> Min: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_min'>min</span><span class='rbrace'>}</span><span class='tstring_content'> Max: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_max'>max</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
280
|
+
<span class='id identifier rubyid_tagCharSize'>tagCharSize</span><span class='op'>=</span><span class='id identifier rubyid_max'>max</span><span class='op'>/</span><span class='int'>80</span>
|
281
|
+
<span class='comment'>#tagCharSize=max/10 if tagCharSize>80
|
282
|
+
</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Graphic summary... +=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_tagCharSize'>tagCharSize</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
283
|
+
<span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span> <span class='id identifier rubyid_fid'>fid</span> <span class='op'>|</span>
|
284
|
+
<span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_scard'>scard</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:trigramsOnFile:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fid'>fid</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
285
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span><span class='op'>>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_tagCharSize'>tagCharSize</span><span class='op'>*</span><span class='int'>3</span><span class='rparen'>)</span>
|
286
|
+
<span class='id identifier rubyid_fname'>fname</span><span class='op'>=</span><span class='id identifier rubyid_redis'>redis</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>fscan:id2filename:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fid'>fid</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
287
|
+
<span class='id identifier rubyid_bar'>bar</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>+</span><span class='tstring_end'>"</span></span><span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_trigramsOnFile'>trigramsOnFile</span><span class='op'>/</span><span class='id identifier rubyid_tagCharSize'>tagCharSize</span><span class='rparen'>)</span>
|
288
|
+
<span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_bar'>bar</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fname'>fname</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
289
|
+
<span class='kw'>end</span>
|
290
|
+
<span class='kw'>end</span>
|
291
|
+
|
292
|
+
<span class='kw'>end</span></pre>
|
293
|
+
</td>
|
294
|
+
</tr>
|
295
|
+
</table>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
<div class="method_details ">
|
299
|
+
<h3 class="signature " id="doWildSearch-instance_method">
|
300
|
+
|
301
|
+
- (<tt>Object</tt>) <strong>doWildSearch</strong>(term, fileScanner)
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
</h3><table class="source_code">
|
308
|
+
<tr>
|
309
|
+
<td>
|
310
|
+
<pre class="lines">
|
311
|
+
|
312
|
+
|
313
|
+
5
|
314
|
+
6
|
315
|
+
7
|
316
|
+
8
|
317
|
+
9
|
318
|
+
10
|
319
|
+
11
|
320
|
+
12
|
321
|
+
13
|
322
|
+
14
|
323
|
+
15
|
324
|
+
16
|
325
|
+
17</pre>
|
326
|
+
</td>
|
327
|
+
<td>
|
328
|
+
<pre class="code"><span class="info file"># File 'lib/code_zauker/cli.rb', line 5</span>
|
329
|
+
|
330
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_doWildSearch'>doWildSearch</span><span class='lparen'>(</span><span class='id identifier rubyid_term'>term</span><span class='comma'>,</span><span class='id identifier rubyid_fileScanner'>fileScanner</span><span class='rparen'>)</span>
|
331
|
+
<span class='id identifier rubyid_fileGroup'>fileGroup</span><span class='op'>=</span><span class='id identifier rubyid_fileScanner'>fileScanner</span><span class='period'>.</span><span class='id identifier rubyid_wsearch'>wsearch</span><span class='lparen'>(</span><span class='id identifier rubyid_term'>term</span><span class='rparen'>)</span>
|
332
|
+
<span class='comment'># Make a simple regexp from the wild stuff...
|
333
|
+
</span> <span class='id identifier rubyid_finalRegexp'>finalRegexp</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
334
|
+
<span class='id identifier rubyid_term'>term</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>*</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_term'>term</span><span class='op'>|</span>
|
335
|
+
<span class='id identifier rubyid_finalRegexp'>finalRegexp</span><span class='op'>=</span> <span class='id identifier rubyid_finalRegexp'>finalRegexp</span><span class='op'>+</span><span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_escape'>escape</span><span class='lparen'>(</span><span class='id identifier rubyid_term'>term</span><span class='rparen'>)</span><span class='op'>+</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.*</span><span class='tstring_end'>"</span></span>
|
336
|
+
<span class='kw'>end</span>
|
337
|
+
<span class='kw'>return</span> <span class='lbrace'>{</span>
|
338
|
+
<span class='symbol'>:regexp</span><span class='op'>=></span><span class='id identifier rubyid_finalRegexp'>finalRegexp</span><span class='comma'>,</span>
|
339
|
+
<span class='symbol'>:files</span> <span class='op'>=></span> <span class='id identifier rubyid_fileGroup'>fileGroup</span>
|
340
|
+
<span class='rbrace'>}</span>
|
341
|
+
|
342
|
+
<span class='kw'>end</span></pre>
|
343
|
+
</td>
|
344
|
+
</tr>
|
345
|
+
</table>
|
346
|
+
</div>
|
347
|
+
|
348
|
+
<div class="method_details ">
|
349
|
+
<h3 class="signature " id="parse_host_options-instance_method">
|
350
|
+
|
351
|
+
- (<tt>Object</tt>) <strong>parse_host_options</strong>(connection_string)
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
</h3><table class="source_code">
|
358
|
+
<tr>
|
359
|
+
<td>
|
360
|
+
<pre class="lines">
|
361
|
+
|
362
|
+
|
363
|
+
19
|
364
|
+
20
|
365
|
+
21
|
366
|
+
22
|
367
|
+
23
|
368
|
+
24
|
369
|
+
25
|
370
|
+
26
|
371
|
+
27
|
372
|
+
28
|
373
|
+
29
|
374
|
+
30
|
375
|
+
31
|
376
|
+
32
|
377
|
+
33
|
378
|
+
34
|
379
|
+
35
|
380
|
+
36
|
381
|
+
37
|
382
|
+
38
|
383
|
+
39
|
384
|
+
40
|
385
|
+
41
|
386
|
+
42
|
387
|
+
43
|
388
|
+
44
|
389
|
+
45
|
390
|
+
46
|
391
|
+
47
|
392
|
+
48
|
393
|
+
49
|
394
|
+
50
|
395
|
+
51
|
396
|
+
52</pre>
|
397
|
+
</td>
|
398
|
+
<td>
|
399
|
+
<pre class="code"><span class="info file"># File 'lib/code_zauker/cli.rb', line 19</span>
|
400
|
+
|
401
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parse_host_options'>parse_host_options</span><span class='lparen'>(</span><span class='id identifier rubyid_connection_string'>connection_string</span><span class='rparen'>)</span>
|
402
|
+
<span class='comment'>#puts "Parsing... #{connection_string}"
|
403
|
+
</span> <span class='id identifier rubyid_options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span>
|
404
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_host</span><span class='rbracket'>]</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>"</span></span>
|
405
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_port</span><span class='rbracket'>]</span><span class='op'>=</span><span class='int'>6379</span>
|
406
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_password</span><span class='rbracket'>]</span><span class='op'>=</span><span class='kw'>nil</span>
|
407
|
+
<span class='id identifier rubyid_r'>r</span><span class='op'>=</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\w+)@([a-zA-Z0-9.]+):([0-9]+)?</span><span class='regexp_end'>/</span></span>
|
408
|
+
<span class='id identifier rubyid_rNoPass'>rNoPass</span><span class='op'>=</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([a-zA-Z0-9.]+):([0-9]+)?</span><span class='regexp_end'>/</span></span>
|
409
|
+
<span class='id identifier rubyid_rHostAndPass'>rHostAndPass</span><span class='op'>=</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\w+)@([a-zA-Z0-9.]+)</span><span class='regexp_end'>/</span></span>
|
410
|
+
<span class='id identifier rubyid_m'>m</span><span class='op'>=</span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_connection_string'>connection_string</span><span class='rparen'>)</span>
|
411
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_m'>m</span>
|
412
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_password</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
413
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_host</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
414
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_port</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
415
|
+
|
416
|
+
<span class='kw'>else</span>
|
417
|
+
<span class='id identifier rubyid_m'>m</span><span class='op'>=</span><span class='id identifier rubyid_rNoPass'>rNoPass</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_connection_string'>connection_string</span><span class='rparen'>)</span>
|
418
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_m'>m</span>
|
419
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_host</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
420
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_port</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
421
|
+
<span class='kw'>else</span>
|
422
|
+
<span class='comment'># Check the auth@host case right here
|
423
|
+
</span> <span class='id identifier rubyid_m2'>m2</span><span class='op'>=</span><span class='id identifier rubyid_rHostAndPass'>rHostAndPass</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_connection_string'>connection_string</span><span class='rparen'>)</span>
|
424
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_m2'>m2</span>
|
425
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_password</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m2'>m2</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
426
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_host</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_m2'>m2</span><span class='period'>.</span><span class='id identifier rubyid_captures'>captures</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
427
|
+
<span class='kw'>else</span>
|
428
|
+
<span class='comment'>#puts "SERVER ONLY"
|
429
|
+
</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:redis_host</span><span class='rbracket'>]</span><span class='op'>=</span><span class='id identifier rubyid_connection_string'>connection_string</span>
|
430
|
+
<span class='kw'>end</span>
|
431
|
+
<span class='kw'>end</span>
|
432
|
+
<span class='kw'>end</span>
|
433
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_options'>options</span>
|
434
|
+
<span class='kw'>end</span></pre>
|
435
|
+
</td>
|
436
|
+
</tr>
|
437
|
+
</table>
|
438
|
+
</div>
|
439
|
+
|
440
|
+
</div>
|
441
|
+
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div id="footer">
|
445
|
+
Generated on Wed May 16 17:14:54 2012 by
|
446
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
447
|
+
0.8.1 (ruby-1.9.3).
|
448
|
+
</div>
|
449
|
+
|
450
|
+
</body>
|
451
|
+
</html>
|