influxdb-cli 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24600246ece600a15975118e21f3f4b932b46979
4
+ data.tar.gz: 084bcd07c9437a1e469f3b48e527a8dd34b59e5a
5
+ SHA512:
6
+ metadata.gz: 657ccf3fff8a72ad3b26f6d1aa762f2e17068879a8659fd32094e6f58f3320597f38af4c43994f05aa2a3ed68a26020ee8d4f53f912eeb03c6697071411db9e7
7
+ data.tar.gz: 51b3e048151f427ebda5720a459b0ac74e94b6ae2d06b33865a3653ecae16e3ab611e10862da57a9f81b38364b97fe4ad73a9d740250b3454f674e1e2f6bc827
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format d
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Pablo Cantero
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,111 @@
1
+ InfluxDB-CLI
2
+ ============
3
+
4
+ Ruby CLI for InfluxDB is a simple Ruby console (empowered with [Pry](https://github.com/pry/pry)) connected to an InfluxDB server with supplied parameters. In order to connect to InfluxDB, it uses [influxdb-ruby](https://github.com/influxdb/influxdb-ruby), so you can access any avaiable method from influxdb-ruby in the console through the `db` variable i.e.: `db.write_point(name, data)`, `db.query('SELECT value FROM response_times')` etc.
5
+
6
+
7
+ ### Installation
8
+ ```shell
9
+ gem install influxdb-cli
10
+ ```
11
+
12
+ ### Options
13
+
14
+ ```shell
15
+ Usage:
16
+ influxdb-cli
17
+
18
+ Options:
19
+ -h, [--host=HOST] # Hostname
20
+ # Default: localhost
21
+ [--port=PORT] # Port
22
+ # Default: 8086
23
+ -u, [--username=USERNAME] # Username
24
+ # Default: root
25
+ -p, [--password=PASSWORD] # Password
26
+ # Default: root
27
+ -d, [--database=DATABASE] # Database
28
+ # Default: db
29
+ ```
30
+
31
+ ### Usage
32
+
33
+ ```shell
34
+ influxdb-cli
35
+ Connecting to {"host"=>"localhost", "port"=>8086, "username"=>"root", "password"=>"root", "database"=>"db"}
36
+ ✔ ready
37
+ 2.0.0 (main)> db.query('SELECT * FROM /./')
38
+ => {
39
+ "cap" => [
40
+ [ 0] {
41
+ "time" => "...",
42
+ "sequence_number" => "...",
43
+ "application" => "...",
44
+ "branch" => "...",
45
+ "latest_revision" => "...",
46
+ "previous_revision" => "...",
47
+ "stage" => "..."
48
+ },
49
+ 2.0.0 (main)> db.get_database_list
50
+ ```
51
+
52
+ ### Pry commands
53
+
54
+ As influxdb-cli is empowered with Pry, all Pry awesome commands are avaiable in the console.
55
+
56
+ ```shell
57
+ 2.0.0 (main)> show-source InfluxDB::Client#query
58
+
59
+ From: /Users/pablo/.gem/ruby/2.0.0/gems/influxdb-0.0.11/lib/influxdb/client.rb @ line 152:
60
+ Owner: InfluxDB::Client
61
+ Visibility: public
62
+ Number of lines: 17
63
+
64
+ def query(query)
65
+ url = full_url("db/#{@database}/series", "q=#{query}")
66
+ url = URI.encode url
67
+ response = @http.request(Net::HTTP::Get.new(url))
68
+ series = JSON.parse(response.body)
69
+
70
+ if block_given?
71
+ series.each { |s| yield s['name'], denormalize_series(s) }
72
+ else
73
+ series.reduce({}) do |col, s|
74
+ name = s['name']
75
+ denormalized_series = denormalize_series s
76
+ col[name] = denormalized_series
77
+ col
78
+ end
79
+ end
80
+ end
81
+
82
+ 2.0.0 (main)> show-doc InfluxDB::Client#initialize
83
+
84
+ From: /Users/pablo/.gem/ruby/2.0.0/gems/influxdb-0.0.11/lib/influxdb/client.rb @ line 13:
85
+ Owner: InfluxDB::Client
86
+ Visibility: private
87
+ Signature: initialize(*args)
88
+ Number of lines: 20
89
+
90
+ Initializes a new Influxdb client
91
+
92
+ === Examples:
93
+
94
+ Influxdb.new # connect to localhost using root/root
95
+ # as the credentials and doesn't connect to a db
96
+
97
+ Influxdb.new 'db' # connect to localhost using root/root
98
+ # as the credentials and 'db' as the db name
99
+
100
+ Influxdb.new :username => 'username' # override username, other defaults remain unchanged
101
+
102
+ Influxdb.new 'db', :username => 'username' # override username, use 'db' as the db name
103
+
104
+ === Valid options in hash
105
+
106
+ +:hostname+:: the hostname to connect to
107
+ +:port+:: the port to connect to
108
+ +:username+:: the username to use when executing commands
109
+ +:password+:: the password associated with the username
110
+ ```
111
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'influxdb'
5
+ require 'pry'
6
+ require 'thor'
7
+ require 'awesome_print'
8
+
9
+ Dir['../lib/**/*.rb'].each &method(:require)
10
+
11
+ class InfluxDBClientTasks < Thor
12
+ desc 'db', 'Connect to InfluxDB'
13
+ method_option :host, :default => 'localhost', :aliases => '-h', :desc => 'Hostname'
14
+ method_option :port, :default => 8086, :desc => 'Port'
15
+ method_option :username, :default => 'root', :aliases => '-u', :desc => 'Username'
16
+ method_option :password, :default => 'root', :aliases => '-p', :desc => 'Password'
17
+ method_option :database, :default => 'db', :aliases => '-d', :desc => 'Database'
18
+ def db
19
+ puts "Connecting to #{options.inspect}"
20
+ @@db ||= InfluxDB::Client.new options[:database],
21
+ { username: options[:username], password: options[:password], host: options[:host], port: options[:port] }
22
+ puts '✔ ready'
23
+ end
24
+
25
+ def self.db; @@db; end
26
+
27
+ default_task :db
28
+ end
29
+
30
+ def db; InfluxDBClientTasks.db; end
31
+
32
+ InfluxDBClientTasks.start
33
+
34
+ Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
35
+
36
+ pry
37
+
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[lib influxdb_client version]))
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'influxdb-cli'
7
+ gem.version = InfluxDBClient::VERSION
8
+ gem.authors = ['Pablo Cantero']
9
+ gem.email = ['pablo@pablocantero.com']
10
+ gem.description = %q{Ruby CLI for InfluxDB}
11
+ gem.summary = %q{Ruby CLI for InfluxDB}
12
+ gem.homepage = 'https://github.com/phstc/influxdb-cli'
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ['lib']
18
+
19
+ gem.add_dependency 'influxdb'
20
+ gem.add_dependency 'pry'
21
+ gem.add_dependency 'thor', '~> 0.18.1'
22
+ gem.add_dependency 'awesome_print'
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency "bundler"
26
+ gem.add_development_dependency "rake"
27
+ end
28
+
@@ -0,0 +1,3 @@
1
+ module InfluxDBClient
2
+ end
3
+
@@ -0,0 +1,3 @@
1
+ module InfluxDBClient
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'rspec'
2
+ require 'fileutils'
3
+ require 'tempfile'
4
+
5
+ Dir['../lib/**/*.rb'].each &method(:require)
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ config.formatter = 'progress'
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: influxdb-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Pablo Cantero
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: influxdb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.18.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.18.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby CLI for InfluxDB
112
+ email:
113
+ - pablo@pablocantero.com
114
+ executables:
115
+ - influxdb-cli
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .rspec
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/influxdb-cli
126
+ - influxdb-cli.gemspec
127
+ - lib/influxdb_client.rb
128
+ - lib/influxdb_client/version.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/phstc/influxdb-cli
131
+ licenses: []
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.0.14
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Ruby CLI for InfluxDB
153
+ test_files:
154
+ - spec/spec_helper.rb