slapshot 0.0.4 → 0.0.5

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.
data/bin/slapshot CHANGED
@@ -6,7 +6,7 @@ include GLI::App
6
6
 
7
7
  program_desc 'A command line interface to the Appshot API'
8
8
 
9
- version Slapshot::VERSION
9
+ #version Slapshot::VERSION
10
10
 
11
11
  desc 'Your Appshot url'
12
12
  flag [:url]
@@ -0,0 +1,53 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+ require 'formatador'
4
+ require 'spreadsheet'
5
+
6
+ class SlapshotConnection
7
+
8
+ def initialize(url, instance, username, password)
9
+ @app = "Portfolio"
10
+ @instance = instance
11
+ @api = RestClient::Resource.new url, :user => username, :password => password, :timeout => -1
12
+ end
13
+
14
+ def set_app(app)
15
+ @app = app
16
+ end
17
+
18
+ def search(query, count)
19
+
20
+ response = @api["search"].get :params => { :i => @instance, :app => @app, :q => query, :c => count }, :content_type => :json, :accept => :json
21
+
22
+ json_response = JSON.parse(response.body)
23
+ puts "Found #{json_response['count']} total results, retrieving #{count} results in #{json_response['search_time']} ms."
24
+
25
+ json_response['docs']
26
+ end
27
+
28
+ def to_table(result)
29
+ Formatador.display_table(result)
30
+ end
31
+
32
+ def to_xls(result, out)
33
+
34
+ book = Spreadsheet::Workbook.new
35
+ sheet1 = book.create_worksheet :name => 'Search Results'
36
+
37
+ columns = ['name', 'entity_type', 'highlight']
38
+
39
+ rownum = 0
40
+ for column in columns
41
+ sheet1.row(rownum).push column
42
+ end
43
+ for row in result
44
+ rownum += 1
45
+ for column in columns
46
+ sheet1.row(rownum).push row[column].nil? ? 'N/A' : row[column]
47
+ end
48
+ end
49
+ book.write(out)
50
+
51
+ end
52
+
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Slapshot
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
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.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -153,6 +153,7 @@ extra_rdoc_files:
153
153
  files:
154
154
  - bin/slapshot
155
155
  - lib/slapshot/version.rb
156
+ - lib/slapshot/main.rb
156
157
  - lib/slapshot.rb
157
158
  - README.rdoc
158
159
  - slapshot.rdoc