slapshot 0.0.13 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/slapshot +6 -2
- data/lib/slapshot/main.rb +22 -20
- data/lib/slapshot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba0c5d40c89ffc0726e73b406a41fc79f100ad7a
|
4
|
+
data.tar.gz: 369e6ed48d31278fcaf49fd11bc40cce2f96027e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b8557cee568b35d237e4d4bd82827bba086dbec03ef4dabf08d4eb78146d4b8597fd152be053d26423e3c7d3598f6292f4c6a2f67f3cc0f7cfaba33b4ebd901
|
7
|
+
data.tar.gz: 1270146806a5201a20aaa6aa472be94df97216bccef69e4757d474940db2bb778a3b5d830e879979a93ff2590cde55c511a66b2ed16ec538fa53bf5f6364092b
|
data/bin/slapshot
CHANGED
@@ -83,15 +83,19 @@ command :try do |c|
|
|
83
83
|
c.default_value 20
|
84
84
|
c.flag [:c, :count]
|
85
85
|
|
86
|
+
c.desc 'Pretty print the JSON result (if html was not chosen)'
|
87
|
+
c.default_value false
|
88
|
+
c.switch [:p, :pretty]
|
89
|
+
|
86
90
|
c.action do |global_options,options,args|
|
87
91
|
|
88
92
|
if args.length != 2
|
89
|
-
raise 'The
|
93
|
+
raise 'The try command takes exactly 2 arguments: a solr query and a parser file'
|
90
94
|
end
|
91
95
|
|
92
96
|
file = File.new(args[1], 'r');
|
93
97
|
|
94
|
-
r = @sc.try args[0], file, options[:c], options[:h]
|
98
|
+
r = @sc.try args[0], file, options[:c], options[:h], options[:p]
|
95
99
|
|
96
100
|
puts
|
97
101
|
puts "#{r}"
|
data/lib/slapshot/main.rb
CHANGED
@@ -74,33 +74,35 @@ class Appshot
|
|
74
74
|
|
75
75
|
end
|
76
76
|
|
77
|
-
def try(solrQuery, parserFile, count, html)
|
77
|
+
def try(solrQuery, parserFile, count, html, pretty)
|
78
78
|
|
79
|
-
=begin
|
80
79
|
response = RestClient.post "#{@url}/service/customParser/test", {:solrQuery => solrQuery, :parserFile => parserFile, :c => count, :h => html }, @headers
|
81
80
|
|
82
|
-
JSON.parse(response.body)
|
81
|
+
json_response = JSON.parse(response.body)
|
83
82
|
|
84
|
-
if (
|
85
|
-
|
86
|
-
|
83
|
+
if (json_response['count'].nil? || 0 == json_response['count'])
|
84
|
+
# there was an error
|
85
|
+
puts "Parse job failed!"
|
86
|
+
return json_response
|
87
|
+
else
|
88
|
+
if (Integer(json_response['count']) < Integer(count))
|
89
|
+
count = json_response['count']
|
90
|
+
end
|
87
91
|
|
88
|
-
|
92
|
+
puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['searchTime']} ms."
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
if html
|
95
|
+
json_response['html']
|
96
|
+
else
|
97
|
+
if pretty
|
98
|
+
JSON.pretty_generate(json_response['docs'])
|
99
|
+
else
|
100
|
+
json_response['docs']
|
101
|
+
end
|
102
|
+
end
|
96
103
|
|
97
|
-
if html
|
98
|
-
response = RestClient.post "#{@url}/service/customParser/testHtml", {:solrQuery => solrQuery, :parserFile => parserFile}, @headers
|
99
|
-
else
|
100
|
-
response = RestClient.post "#{@url}/service/customParser/test", {:solrQuery => solrQuery, :parserFile => parserFile}, @headers
|
101
|
-
JSON.parse(response.body)
|
102
104
|
end
|
103
|
-
|
105
|
+
|
104
106
|
end
|
105
107
|
|
106
108
|
def to_table(result)
|
@@ -147,4 +149,4 @@ class Appshot
|
|
147
149
|
book.write(out)
|
148
150
|
|
149
151
|
end
|
150
|
-
end
|
152
|
+
end
|
data/lib/slapshot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mik Lernout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|