darkhelmet-darkext 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/VERSION.yml +1 -1
- data/lib/darkext/beagle.rb +8 -10
- metadata +1 -1
data/History.txt
CHANGED
data/VERSION.yml
CHANGED
data/lib/darkext/beagle.rb
CHANGED
@@ -27,11 +27,13 @@ module Beagle
|
|
27
27
|
system('beagle-shutdown')
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.query(query, verbose = false)
|
30
|
+
def self.query(query, verbose = false, max_hits = 40)
|
31
31
|
raise BeagleError, "Beagle.home (BEAGLE_HOME) not set!" if home.nil?
|
32
32
|
args = Array.new
|
33
33
|
args << 'beagle-query'
|
34
34
|
args << '--verbose' if verbose
|
35
|
+
args << '--max-hits'
|
36
|
+
args << max_hits.to_s
|
35
37
|
args << query
|
36
38
|
output = DarkIO.capture_output(:stderr => false) { system(*args) }
|
37
39
|
parser = verbose ? verbose_parser : regular_parser
|
@@ -53,12 +55,7 @@ private
|
|
53
55
|
|
54
56
|
def self.verbose_parser
|
55
57
|
lambda do |output|
|
56
|
-
|
57
|
-
2.times do
|
58
|
-
lines.shift
|
59
|
-
lines.pop
|
60
|
-
end
|
61
|
-
sections = lines.join("\n").strip.split("\n\n")
|
58
|
+
sections = output.strip.split("\n\n")
|
62
59
|
results = sections.map do |section|
|
63
60
|
section_lines = section.split("\n")
|
64
61
|
section_hash = Hash.new
|
@@ -67,16 +64,17 @@ private
|
|
67
64
|
parts = line.split(':')
|
68
65
|
k = parts.shift
|
69
66
|
v = parts.join(':')
|
70
|
-
|
67
|
+
section_hash[k.strip] = v.strip
|
68
|
+
elsif line.include?('=')
|
71
69
|
k,v = line.split('=')
|
72
70
|
k = k.split(':').last
|
73
71
|
v.gsub!("'",'')
|
72
|
+
section_hash[k.strip] = v.strip
|
74
73
|
end
|
75
|
-
section_hash[k.strip] = v.strip
|
76
74
|
end
|
77
75
|
section_hash
|
78
76
|
end
|
79
|
-
results.sort { |l,r| l['Score'] <=> r['Score'] }
|
77
|
+
results.sort { |l,r| l['Score'].to_f <=> r['Score'].to_f }
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|