code_zauker 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -2,3 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ code_zauker_index.rdb
6
+ .yardoc
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
- ARGV.each do | l |
7
- if Dir.exists?(l)
8
- puts "Processing via find+xargs"
9
- system("find #{l} -type f | xargs -P 5 -n 10 #{$0}")
10
- else
11
- puts "Meganoids indexing #{l}"
12
- fs=CodeZauker::FileScanner.new()
13
- fs.load(l,noReload=false)
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 somethiing like -W0 to ruby, for a cleaner output
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
- if files.length >0
11
- fline=files.join(" ")
12
- # -H forces to print file name also with only one match
13
- cmd="grep -H --color -n '#{s}' #{fline}"
14
- #puts cmd
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
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ set -v -x
4
+ $REDIS_HOME/src/redis-server $(dirname $0)/../etc/redis.conf
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
+