code_zauker 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/bin/mczindexer ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ set -x -e
3
+ echo "Parallel Indexer"
4
+ time find $* -type f -print0 | xargs -0 -P 10 -n 25 czindexer -v
data/bin/report.rb ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ require 'set'
3
+ require 'code_zauker'
4
+ require 'code_zauker/grep'
5
+ require 'code_zauker/cli'
6
+ require 'redis/connection/hiredis'
7
+ require 'redis'
8
+ require 'tempfile'
9
+ require 'pdf/reader'
10
+
11
+ puts "Redis Code Zauker Report"
12
+ require 'optparse'
13
+ options={}
14
+ optparse= OptionParser.new do |opts|
15
+ opts.banner="Usage: report [options] "
16
+
17
+ options[:redis_host]="127.0.0.1"
18
+ options[:redis_port]=6379
19
+ options[:redis_password]=nil
20
+
21
+ opts.on('-h','--redis-server pass@SERVER:port', String,
22
+ 'Specify the alternate redis server to use')do |server|
23
+ myoptions=CodeZauker::CliUtil.new().parse_host_options(server)
24
+ options[:redis_host]=myoptions[:redis_host]
25
+ options[:redis_port]=myoptions[:redis_port]
26
+ options[:redis_password]=myoptions[:redis_password]
27
+
28
+ if options[:redis_password]
29
+ puts "Server: #{options[:redis_host]} Port:#{options[:redis_port]} WithPassword"
30
+ else
31
+ puts "Server: #{options[:redis_host]} Port:#{options[:redis_port]}"
32
+ end
33
+ end
34
+ end
35
+ optparse.parse!
36
+
37
+ util=CodeZauker::CliUtil.new()
38
+ redisConnection=Redis.new(:host => options[:redis_host], :port => options[:redis_port], :password=> options[:redis_password])
39
+ util.do_report(redisConnection)
40
+
data/code_zauker.gemspec CHANGED
@@ -27,6 +27,9 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency "redis", "~> 2.2"
28
28
  s.add_runtime_dependency "pdf-reader", "~> 1.0.0"
29
29
  s.add_runtime_dependency "sinatra", "~> 1.3"
30
+ s.add_runtime_dependency "redis_logger", "~> 0.1"
31
+ # Eval http://github.com/masonoise/redis_logger-web
32
+
30
33
  # thin unable to be installed for missing g++ on my dev platform (shame on debian)
31
34
  #s.add_runtime_dependency "thin"
32
35
  ## Install and require the hiredis gem before redis-rb for maximum performances.
@@ -36,5 +36,47 @@ module CodeZauker
36
36
  end
37
37
  return options
38
38
  end
39
+
40
+ def do_report(redis)
41
+ puts "Simple Reporting....on #{redis.client.host}"
42
+ id2filename=redis.keys "fscan:id2filename:*"
43
+ puts "File Stored:\t\t#{id2filename.length}"
44
+ processedFiles=redis.scard("fscan:processedFiles")
45
+ puts "Processed Files:\t#{processedFiles}"
46
+ # Complex... compute average "fscan:trigramsOnFile:#{fid}"
47
+ sum=0.0
48
+ max=0
49
+ min=90000000000000000
50
+ fileName2Ids=redis.keys "fscan:id:*"
51
+ count=fileName2Ids.length+0.0
52
+ puts "Finding ids..."
53
+ ids=redis.mget(*(redis.keys("fscan:id:*")))
54
+ puts "Scanning ids..."
55
+ ids.each do | fid |
56
+ # Forma fscan:trigramsOnFile:5503
57
+ trigramsOnFile=redis.scard("fscan:trigramsOnFile:#{fid}")
58
+ sum = sum + trigramsOnFile
59
+ # if trigramsOnFile == 0 or trigramsOnFile >=max
60
+ # fname=redis.get("fscan:id2filename:#{fid}")
61
+ # puts "Note fscan:trigramsOnFile:#{fid} -> #{trigramsOnFile} #{fname}"
62
+ # end
63
+ max=trigramsOnFile if trigramsOnFile >max
64
+ min=trigramsOnFile if trigramsOnFile <min and trigramsOnFile>0
65
+ end
66
+ av=sum/count
67
+ puts "Average Trigrams per file:#{av} Min: #{min} Max: #{max}"
68
+ tagCharSize=max/80
69
+ #tagCharSize=max/10 if tagCharSize>80
70
+ puts "Graphic summary... +=#{tagCharSize}"
71
+ ids.each do | fid |
72
+ trigramsOnFile=redis.scard("fscan:trigramsOnFile:#{fid}")
73
+ if trigramsOnFile>= (tagCharSize*3)
74
+ fname=redis.get("fscan:id2filename:#{fid}")
75
+ bar="+"*(trigramsOnFile/tagCharSize)
76
+ puts "#{bar} #{fname}"
77
+ end
78
+ end
79
+
80
+ end
39
81
  end
40
82
  end
@@ -10,9 +10,11 @@ module CodeZauker
10
10
  DEFAULT_EXCLUDED_EXTENSION=[
11
11
  # Documents
12
12
  ".xps",
13
- ".zip",".7z",
13
+ ".zip",".7z","rar",
14
14
  # MS Office zip-like files...
15
15
  ".pptx",".docx",".xlsx",
16
+ # Avoid slurping text document too...
17
+ ".doc",
16
18
  ".ppt",".xls",".rtf",".vsd", ".odf",
17
19
  # Binary bad stuff
18
20
  ".dll",".exe",".out",".elf",".lib",".so",
@@ -25,7 +27,9 @@ module CodeZauker
25
27
  ".tar",
26
28
  ".gz",".Z",
27
29
  ".dropbox",
28
- ".svn-base",".pdb",".cache",
30
+ ".svn-base",".pdb",".cache",
31
+ #IDE STUFF
32
+ ".wlwLock",
29
33
  # Music exclusion
30
34
  ".mp3",".mp4",".wav",
31
35
  # Image exclusion
@@ -1,3 +1,3 @@
1
1
  module CodeZauker
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -24,7 +24,8 @@ get '/search' do
24
24
  pattern=/#{Regexp.escape(askedQuery)}/i
25
25
  lines=grep(f,pattern, pre_context=2, post_context=2);
26
26
  desc=""
27
- lines.each do |l |
27
+ lines.each do | l |
28
+ # http://stackoverflow.com/questions/1287630/ruby-gsub-and-regex
28
29
  hilighted=l.gsub(/(#{Regexp.escape(askedQuery)})/i){ "<b>#{$1}</b>"}
29
30
  desc=desc+ "#{f}:#{hilighted}\n"
30
31
  end
data/readme.org CHANGED
@@ -14,13 +14,60 @@ You need also [[http://redis.io/][redis-2.4.6]] or better.
14
14
  For a sample redis configuration see the etc/ directory of the project
15
15
 
16
16
  * Try it out
17
- Take a look to czindex and czsearch commands help for usage patterns.
17
+ ** To index all your files
18
+ The following command will index all the code file below /full_path_of_sources/ providing
19
+ a feedback on standard output
20
+ #+BEGIN_SRC sh
21
+ czindexer -v /full_path_of_sources/
22
+ #+END_SRC
23
+ If your redis server is on another machine, you can use the following command
24
+ #+BEGIN_SRC sh
25
+ czindexer --redis-server myredisserver -v /full_path_of_sources/
26
+ #+END_SRC
27
+ Also authentication over redis is supported:
28
+ #+BEGIN_SRC sh
29
+ czindexer --redis-server password@rediserverpwp -v /full_path_of_sources/
30
+ #+END_SRC
31
+
32
+
33
+ To search for the 'my_beautiful_method' try out:
34
+ #+BEGIN_SRC sh
35
+ czsearch my_beautiful_method
36
+ #+END_SRC
18
37
 
38
+ Looking case insensitive can be userful too....
39
+ #+BEGIN_SRC sh
40
+ czsearch -i 'Select USER_id'
41
+ #+END_SRC
42
+
43
+ Tip:Take a look to czindex and czsearch commands help for full options list
44
+ ** Web interface
45
+ There is a new shiny web interface based on sinatra. To try it out, fire
46
+ #+BEGIN_SRC sh
47
+ ./bin/webgui
48
+ #+END_SRC
49
+ It is still beta, but it is *very* fast, thank to redis!
50
+
51
+
52
+ ** Parallel execution
53
+ If you want to speed up indexing, you can use the mczindexer command.
54
+ For instance:
55
+ mczindexer eclipse-sources/
56
+ will fire at most 10 parallel czindexer.
57
+
58
+ ** Simple stats
59
+ You can ask code zauker to print a nice stats on standard output.
60
+ Run
61
+ #+BEGIN_SRC sh
62
+ ./bin/report.rb
63
+ #+END_SRC
64
+ and enjoy!
19
65
 
20
66
 
21
67
  * Release History
22
68
  | Version | Date | Summary |
23
69
  |---------+-------------+-----------------------------------------------------------------|
70
+ | 0.0.7 | 13 May 2012 | Better documentation, mczindexer, new report command
24
71
  | 0.0.6 | 04 May 2012 | New redis-server option. Better web search with results hilight |
25
72
  | 0.0.5 | 09 Apr 2012 | Added Sinatra-based web search page, featuring bootrstrap css |
26
73
  | 0.0.4 | 12 Feb 2012 | PDF Searching |
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_zauker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-04 00:00:00.000000000 Z
12
+ date: 2012-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
16
- requirement: &74198570 !ruby/object:Gem::Requirement
16
+ requirement: &83355880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.7'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *74198570
24
+ version_requirements: *83355880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &74197690 !ruby/object:Gem::Requirement
27
+ requirement: &83355530 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.9'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *74197690
35
+ version_requirements: *83355530
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hiredis
38
- requirement: &74196880 !ruby/object:Gem::Requirement
38
+ requirement: &83355130 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *74196880
46
+ version_requirements: *83355130
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redis
49
- requirement: &74196090 !ruby/object:Gem::Requirement
49
+ requirement: &83354730 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *74196090
57
+ version_requirements: *83354730
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pdf-reader
60
- requirement: &74187710 !ruby/object:Gem::Requirement
60
+ requirement: &83354000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *74187710
68
+ version_requirements: *83354000
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sinatra
71
- requirement: &74186780 !ruby/object:Gem::Requirement
71
+ requirement: &83130590 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,18 @@ dependencies:
76
76
  version: '1.3'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *74186780
79
+ version_requirements: *83130590
80
+ - !ruby/object:Gem::Dependency
81
+ name: redis_logger
82
+ requirement: &83130330 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.1'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *83130330
80
91
  description: Code Zauker is based from ideas taken by old Google Code Search and uses
81
92
  Redis as a basic platform
82
93
  email:
@@ -84,6 +95,8 @@ email:
84
95
  executables:
85
96
  - czindexer
86
97
  - czsearch
98
+ - mczindexer
99
+ - report.rb
87
100
  - startRedis
88
101
  - webgui
89
102
  extensions: []
@@ -96,6 +109,8 @@ files:
96
109
  - Rakefile
97
110
  - bin/czindexer
98
111
  - bin/czsearch
112
+ - bin/mczindexer
113
+ - bin/report.rb
99
114
  - bin/startRedis
100
115
  - bin/webgui
101
116
  - code_zauker.gemspec