influxdb-cli 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24600246ece600a15975118e21f3f4b932b46979
4
- data.tar.gz: 084bcd07c9437a1e469f3b48e527a8dd34b59e5a
3
+ metadata.gz: 7666677d00e9a4dcc1c06b306998e0780a8494c8
4
+ data.tar.gz: 0616e96d6e8900499a1c52be38d66008b3220429
5
5
  SHA512:
6
- metadata.gz: 657ccf3fff8a72ad3b26f6d1aa762f2e17068879a8659fd32094e6f58f3320597f38af4c43994f05aa2a3ed68a26020ee8d4f53f912eeb03c6697071411db9e7
7
- data.tar.gz: 51b3e048151f427ebda5720a459b0ac74e94b6ae2d06b33865a3653ecae16e3ab611e10862da57a9f81b38364b97fe4ad73a9d740250b3454f674e1e2f6bc827
6
+ metadata.gz: 8e60dfecba7fd8940b9c3a94facab13d57c12c01e051d40ff4eb816687e972fe9eefd4e57f8a74f4a5e3f8e298097e172be80bd2da0e162ea964e66c81ca6011
7
+ data.tar.gz: 4c8ccfab14ab6d6c9bc1c07d159cd3ec346b65c1742fc8ac382604146f13060fa69f48f4a364d41e04cc64cc76246d4a3b4fbabb767760aaccea9fa932b5ad2c
data/README.md CHANGED
@@ -30,13 +30,33 @@ Options:
30
30
 
31
31
  ### Usage
32
32
 
33
+ [Tabularized](https://github.com/visionmedia/terminal-table) output:
34
+
33
35
  ```shell
34
36
  influxdb-cli
35
37
  Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"=>"root", "database"=>"db"}
36
38
  ✔ ready
37
- 2.0.0 (main)> db.query('SELECT * FROM /./')
39
+ 2.0.0 (main)> query('select * from cap limit 1')
40
+ +---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
41
+ | cap |
42
+ +---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
43
+ | time | sequence_number | application | branch | latest_revision | previous_revision | stage |
44
+ +---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
45
+ | ... | ... | ... | ... | ... | ... | ... |
46
+ +---------------+-----------------+-----------------+--------+-----------------+-------------------+----------+
47
+
48
+ => {
49
+ "cap.count" => 1
50
+ }
51
+ ```
52
+
53
+
54
+ Ruby Hash output ([awesome_print](https://github.com/michaeldv/awesome_print)):
55
+
56
+ ```shell
57
+ 2.0.0 (main)> db.query('SELECT * FROM deploys')
38
58
  => {
39
- "cap" => [
59
+ "deploys" => [
40
60
  [ 0] {
41
61
  "time" => "...",
42
62
  "sequence_number" => "...",
@@ -46,7 +66,18 @@ Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"
46
66
  "previous_revision" => "...",
47
67
  "stage" => "..."
48
68
  },
69
+ ```
70
+
71
+
72
+ ```shell
73
+ 2.0.0 (main)> db.write_point(name, data)
49
74
  2.0.0 (main)> db.get_database_list
75
+ 2.0.0 (main)> ls -q db
76
+ InfluxDB::Client#methods:
77
+ _write create_database database= delete_database_user get_database_user_list password port= queue= username
78
+ alter_database_privilege create_database_user delete_cluster_admin get_cluster_admin_list host password= query update_cluster_admin username=
79
+ create_cluster_admin database delete_database get_database_list host= port queue update_database_user write_point
80
+ instance variables: @database @host @http @password @port @queue @username
50
81
  ```
51
82
 
52
83
  ### Pry commands
@@ -78,6 +109,9 @@ def query(query)
78
109
  end
79
110
  end
80
111
  end
112
+ ```
113
+
114
+ ```shel
81
115
 
82
116
  2.0.0 (main)> show-doc InfluxDB::Client#initialize
83
117
 
@@ -5,6 +5,7 @@ require 'influxdb'
5
5
  require 'pry'
6
6
  require 'thor'
7
7
  require 'awesome_print'
8
+ require 'terminal-table'
8
9
 
9
10
  Dir['../lib/**/*.rb'].each &method(:require)
10
11
 
@@ -29,6 +30,22 @@ end
29
30
 
30
31
  def db; InfluxDBClientTasks.db; end
31
32
 
33
+ def query(query)
34
+ result = db.query(query)
35
+ count = {}
36
+ result.to_h.keys.each do |serie_name|
37
+ headings = result[serie_name].first.keys
38
+ rows = result[serie_name].collect(&:values)
39
+ table = Terminal::Table.new title: serie_name, headings: headings, rows: rows
40
+ puts table
41
+ # empty line
42
+ puts
43
+ # count total per serie
44
+ count["#{serie_name}.count"] = result[serie_name].size
45
+ end
46
+ count
47
+ end
48
+
32
49
  InfluxDBClientTasks.start
33
50
 
34
51
  Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'pry'
21
21
  gem.add_dependency 'thor', '~> 0.18.1'
22
22
  gem.add_dependency 'awesome_print'
23
+ gem.add_dependency 'terminal-table'
23
24
 
24
25
  gem.add_development_dependency 'rspec'
25
26
  gem.add_development_dependency "bundler"
@@ -1,3 +1,3 @@
1
1
  module InfluxDBClient
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: terminal-table
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement