Class: CodeZauker::CliUtil
- Inherits:
-
Object
- Object
- CodeZauker::CliUtil
- Defined in:
- lib/code_zauker/cli.rb
Instance Method Summary (collapse)
- - (Object) do_report(redis)
- - (Object) doWildSearch(term, fileScanner)
- - (Object) parse_host_options(connection_string)
Instance Method Details
- (Object) do_report(redis)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/code_zauker/cli.rb', line 54 def do_report(redis) puts "Simple Reporting....on #{redis.client.host}" id2filename=redis.keys "fscan:id2filename:*" puts "File Stored:\t\t#{id2filename.length}" processedFiles=redis.scard("fscan:processedFiles") puts "Processed Files:\t#{processedFiles}" # Complex... compute average "fscan:trigramsOnFile:#{fid}" sum=0.0 max=0 min=90000000000000000 fileName2Ids=redis.keys "fscan:id:*" count=fileName2Ids.length+0.0 puts "Finding ids..." ids=redis.mget(*(redis.keys("fscan:id:*"))) puts "Scanning ids..." ids.each do | fid | # Forma fscan:trigramsOnFile:5503 trigramsOnFile=redis.scard("fscan:trigramsOnFile:#{fid}") sum = sum + trigramsOnFile # if trigramsOnFile == 0 or trigramsOnFile >=max # fname=redis.get("fscan:id2filename:#{fid}") # puts "Note fscan:trigramsOnFile:#{fid} -> #{trigramsOnFile} #{fname}" # end max=trigramsOnFile if trigramsOnFile >max min=trigramsOnFile if trigramsOnFile <min and trigramsOnFile>0 end av=sum/count puts "Average Trigrams per file:#{av} Min: #{min} Max: #{max}" tagCharSize=max/80 #tagCharSize=max/10 if tagCharSize>80 puts "Graphic summary... +=#{tagCharSize}" ids.each do | fid | trigramsOnFile=redis.scard("fscan:trigramsOnFile:#{fid}") if trigramsOnFile>= (tagCharSize*3) fname=redis.get("fscan:id2filename:#{fid}") ="+"*(trigramsOnFile/tagCharSize) puts "#{} #{fname}" end end end |
- (Object) doWildSearch(term, fileScanner)
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/code_zauker/cli.rb', line 5 def doWildSearch(term,fileScanner) fileGroup=fileScanner.wsearch(term) # Make a simple regexp from the wild stuff... finalRegexp="" term.split("*").each do |term| finalRegexp= finalRegexp+Regexp.escape(term)+".*" end return { :regexp=>finalRegexp, :files => fileGroup } end |
- (Object) parse_host_options(connection_string)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/code_zauker/cli.rb', line 19 def (connection_string) #puts "Parsing... #{connection_string}" ={} [:redis_host]="127.0.0.1" [:redis_port]=6379 [:redis_password]=nil r=/(\w+)@([a-zA-Z0-9.]+):([0-9]+)?/ rNoPass=/([a-zA-Z0-9.]+):([0-9]+)?/ rHostAndPass=/(\w+)@([a-zA-Z0-9.]+)/ m=r.match(connection_string) if m [:redis_password]=m.captures[0] [:redis_host]=m.captures[1] [:redis_port]=m.captures[2] else m=rNoPass.match(connection_string) if m [:redis_host]=m.captures[0] [:redis_port]=m.captures[1] else # Check the auth@host case right here m2=rHostAndPass.match(connection_string) if m2 [:redis_password]=m2.captures[0] [:redis_host]=m2.captures[1] else #puts "SERVER ONLY" [:redis_host]=connection_string end end end return end |