slapshot 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/bin/slapshot CHANGED
@@ -19,8 +19,13 @@ desc 'Search your instance of Appshot'
19
19
  arg_name 'Pass in the query'
20
20
  command :search do |c|
21
21
 
22
- c.desc 'Limit the search to this application or group'
23
- c.flag [:a, :app]
22
+ c.desc 'Get all results'
23
+ c.default_value false
24
+ c.switch [:a, :all]
25
+
26
+ c.desc 'Return all fields of the results, including code snippets'
27
+ c.default_value false
28
+ c.switch [:f, :full]
24
29
 
25
30
  c.desc 'Export the results to an Excel file with the given name'
26
31
  c.flag [:x, :xls]
@@ -31,20 +36,22 @@ command :search do |c|
31
36
 
32
37
  c.action do |global_options,options,args|
33
38
 
34
- if options[:a]
35
- @sc.set_app options[:a]
36
- end
37
-
38
39
  if args.length != 1
39
- raise 'The search command takes exactly one argument: the query'
40
+ raise "The search command takes exactly one argument: the query"
41
+ end
42
+
43
+ count = options[:c]
44
+ if options[:a]
45
+ count = 5000
40
46
  end
41
47
 
42
- r = @sc.search args[0], options[:c]
48
+ r = @sc.search args[0], count, options[:f]
43
49
 
44
50
  if options[:x]
45
51
  @sc.to_xls r, options[:x]
46
52
  puts "Exported search results to #{options[:x]}"
47
53
  else
54
+ puts
48
55
  puts @sc.to_table r
49
56
  end
50
57
  end
data/lib/slapshot/main.rb CHANGED
@@ -48,25 +48,23 @@ end
48
48
  class Appshot
49
49
 
50
50
  def initialize(url, token, instance)
51
- @app = "Portfolio"
52
51
  @instance = instance
53
-
54
52
  @api = RestClient::Resource.new url, :timeout => -1, :headers => {'Appshot-AuthToken' => token, 'Appshot-Instance' => instance}
55
53
  end
56
54
 
57
- def set_app(app)
58
- @app = app
59
- end
60
-
61
- def search(query, count)
55
+ def search(query, count, full)
62
56
 
63
- response = @api["v1/search"].get :params => { :i => @instance, :app => @app, :q => query, :c => count }, :content_type => :json, :accept => :json
57
+ response = @api["v1/search"].get :params => { :i => @instance, :q => query, :c => count, :f => full }, :content_type => :json, :accept => :json
64
58
 
65
59
  json_response = JSON.parse(response.body)
66
60
 
67
- puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['search_time']} ms."
61
+ if (Integer(json_response['count']) < Integer(count))
62
+ count = json_response['count']
63
+ end
68
64
 
65
+ puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['search_time']} ms."
69
66
  json_response['docs']
67
+
70
68
  end
71
69
 
72
70
  def to_table(result)
@@ -1,3 +1,3 @@
1
1
  module Slapshot
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: