slapshot 0.0.13 → 0.0.16

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b25d113ae7b0db720fc5052ad3b4e99df9bce14
4
- data.tar.gz: 42df251af565c0a802326819b336474b0aba6286
3
+ metadata.gz: ba0c5d40c89ffc0726e73b406a41fc79f100ad7a
4
+ data.tar.gz: 369e6ed48d31278fcaf49fd11bc40cce2f96027e
5
5
  SHA512:
6
- metadata.gz: eec0f68106e4805c6d7d3b1d80a853f55d33d2a58919e08439126e9feb91f9eccf087b516febae39007acec255b33b435f0cdf3c67b70f0a1e3220b923ac540a
7
- data.tar.gz: 8ba924b8fb78047dc31c5a387b6105dba538e111798ee9a44c57827ca747a7b515640d5bd0aa0dddb4b37363e0a4de2b6e0f034583774b88943c2d62c4fd90c3
6
+ metadata.gz: 1b8557cee568b35d237e4d4bd82827bba086dbec03ef4dabf08d4eb78146d4b8597fd152be053d26423e3c7d3598f6292f4c6a2f67f3cc0f7cfaba33b4ebd901
7
+ data.tar.gz: 1270146806a5201a20aaa6aa472be94df97216bccef69e4757d474940db2bb778a3b5d830e879979a93ff2590cde55c511a66b2ed16ec538fa53bf5f6364092b
@@ -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 search command takes exactly 2 arguments: a solr query and a parser file'
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}"
@@ -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 (Integer(json_response['count']) < Integer(count))
85
- count = json_response['count']
86
- end
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
- puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['search_time']} ms."
92
+ puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['searchTime']} ms."
89
93
 
90
- if html
91
- json_response['html']
92
- else
93
- json_response['docs']
94
- end
95
- =end
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
@@ -1,3 +1,3 @@
1
1
  module Slapshot
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.16'
3
3
  end
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.13
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-10 00:00:00.000000000 Z
11
+ date: 2013-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake