code_zauker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Rakefile +5 -0
- data/bin/czindexer +81 -8
- data/bin/czsearch +10 -8
- data/bin/startRedis +4 -0
- data/devel.org +18 -0
- data/doc/CodeZauker/FileScanner.html +742 -0
- data/doc/CodeZauker.html +169 -0
- data/doc/_index.html +112 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file_list.html +46 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +112 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +94 -0
- data/doc/top-level-namespace.html +103 -0
- data/etc/redis.conf +493 -0
- data/lib/code_zauker/constants.rb +24 -0
- data/lib/code_zauker/grep.rb +138 -0
- data/lib/code_zauker/version.rb +1 -1
- data/lib/code_zauker.rb +108 -37
- data/readme.org +27 -3
- data/test/test_search.rb +29 -4
- metadata +29 -8
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -15,7 +15,12 @@ end
|
|
15
15
|
require 'yard'
|
16
16
|
YARD::Rake::YardocTask.new do |t|
|
17
17
|
t.files = ['lib/**/*.rb'] # optional
|
18
|
+
t.options += ['--title', "Code Zauker #{CodeZauker::VERSION} Documentation"]
|
18
19
|
#t.options = ['--any', '--extra', '--opts'] # optional
|
19
20
|
end
|
20
21
|
|
22
|
+
desc "Code Zauker default task for generating doucmentation, running tests and packing gem"
|
23
|
+
task :default => [ :test, :yard, :build] do
|
24
|
+
end
|
25
|
+
|
21
26
|
|
data/bin/czindexer
CHANGED
@@ -2,14 +2,87 @@
|
|
2
2
|
# Suggested execution is mixing find / xargs with the parallel (P) parameters:
|
3
3
|
# find test/fixture/ -type f | xargs -P 5 -n 10 ./bin/czindexer
|
4
4
|
# will fire 5 czindexer each with 10 files to process...
|
5
|
+
require 'optparse'
|
6
|
+
options={}
|
7
|
+
optparse= OptionParser.new do |opts|
|
8
|
+
opts.banner="Usage: $0 [options] [file1] [file2]..."
|
9
|
+
options[:verbose] = false
|
10
|
+
|
11
|
+
opts.on( '-v', '--verbose', 'Output more information' ) do
|
12
|
+
options[:verbose] = true
|
13
|
+
end
|
14
|
+
|
15
|
+
options[:reindex]=false
|
16
|
+
opts.on( '-f', '--force-reindex', 'Force Reindex (default:false)') do
|
17
|
+
options[:reindex]=true
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
#TODO ADD REMOVE ALL option
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
optparse.parse!
|
5
30
|
require 'code_zauker'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
31
|
+
|
32
|
+
|
33
|
+
def processElement(l,fs,options)
|
34
|
+
#Remove trailing / from l before proceeding
|
35
|
+
if l[-1]=="/"
|
36
|
+
l=l.chop
|
37
|
+
end
|
38
|
+
if Dir.exists?(l)
|
39
|
+
puts "Processing Dir #{l}" if options[:verbose]
|
40
|
+
Dir["#{l}/*"].each do |elem|
|
41
|
+
processElement(elem,fs,options)
|
42
|
+
end
|
43
|
+
# puts "Processing via find+xargs" if options[:verbose]
|
44
|
+
# if options[:reindex]==false
|
45
|
+
# system("find #{l} -type f -print0 | xargs -0 -P 7 -n 5 #{$0}")
|
46
|
+
# else
|
47
|
+
# system("find #{l} -type f -print0 | xargs -0 -P 7 -n 5 #{$0} -f ")
|
48
|
+
# end
|
49
|
+
else
|
50
|
+
# avoid processing bad guys...
|
51
|
+
toExclude=false
|
52
|
+
CodeZauker::DEFAULT_EXCLUDED_EXTENSION.each do | ext |
|
53
|
+
if l.end_with?(ext)
|
54
|
+
toExclude=true
|
55
|
+
break
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if !toExclude && !l.include?("/.hg/") && !l.include?("/CVS/") && !l.include?("/.svn/") && !l.include?("/.git/")
|
59
|
+
#puts "Meganoids indexing #{l}"
|
60
|
+
puts "Processing File #{l}" if options[:verbose]
|
61
|
+
if options[:reindex] == true
|
62
|
+
fs.reindex([l])
|
63
|
+
else
|
64
|
+
fs.load(l,noReload=true)
|
65
|
+
end
|
66
|
+
$PROCESSED_FILES+=1
|
67
|
+
else
|
68
|
+
puts "SKIPPED binary file: #{l}" if options[:verbose]
|
69
|
+
end
|
70
|
+
if options[:verbose]
|
71
|
+
puts "czindexer: processed #{$PROCESSED_FILES} by this instance"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
begin
|
79
|
+
# Allocated here to recycle connection
|
80
|
+
fs=CodeZauker::FileScanner.new()
|
81
|
+
$PROCESSED_FILES=0
|
82
|
+
puts "Reindexing..." if options[:verbose]==true and options[:reindex]==true
|
83
|
+
ARGV.each do | l |
|
84
|
+
processElement(l,fs,options)
|
14
85
|
end
|
86
|
+
ensure
|
87
|
+
fs.disconnect
|
15
88
|
end
|
data/bin/czsearch
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#== czsearch is a userful command to search via the Code Zauker facility
|
3
|
-
# Send
|
3
|
+
# Send something like -W0 to ruby, for a cleaner output
|
4
4
|
$VERBOSE=nil
|
5
5
|
require 'code_zauker'
|
6
|
+
require 'code_zauker/grep'
|
7
|
+
include Grep
|
8
|
+
|
6
9
|
ARGV.each do | s |
|
7
|
-
#puts "Code Zauker Searching for #{s}"
|
10
|
+
#puts "Code Zauker Searching for #{s}"
|
8
11
|
fs=CodeZauker::FileScanner.new()
|
9
12
|
files=fs.search(s)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
system(cmd)
|
13
|
+
files.each do |f|
|
14
|
+
lines=grep(f,s);
|
15
|
+
lines.each do |l |
|
16
|
+
puts "#{f}:#{l}"
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
data/bin/startRedis
ADDED
data/devel.org
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
* Future/Study
|
2
|
+
To fulfill Google code options:
|
3
|
+
** Google code input
|
4
|
+
Offers regula expression search like
|
5
|
+
^java/.*\.java$
|
6
|
+
and also:
|
7
|
+
|
8
|
+
Package package:linux-2.6
|
9
|
+
Language lang:c++
|
10
|
+
File Path file:(code|[^or]g)search
|
11
|
+
Class class:HashMap
|
12
|
+
Function function:toString
|
13
|
+
License license:mozilla
|
14
|
+
Case Sensitive case:yes
|
15
|
+
|
16
|
+
** Reference
|
17
|
+
http://www.rubyinside.com/21-ruby-tricks-902.html
|
18
|
+
|