influxdb 0.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +18 -0
- data/influxdb.gemspec +27 -0
- data/lib/influxdb.rb +2 -0
- data/lib/influxdb/client.rb +42 -0
- data/lib/influxdb/version.rb +3 -0
- data/spec/influxdb/client_spec.rb +58 -0
- data/spec/influxdb_spec.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 58b0db6ce261ae007787243e7c6654c11a40929f
|
4
|
+
data.tar.gz: dc6b9173f6a0575257db3430649ce298eda0eb4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ac32c6cf939ff9844ea91f969391d46f21d4c632ee2241519abde1e5de9c5169c50b08bb92f87dcc9fd7ca89eda8b5c15249f1938cc97b203c6b6986b84ddb1
|
7
|
+
data.tar.gz: 7842ff9fa324ccb25172cdb2bd377c47e1da1835b2c50e407b47677d4d7b705e1ec9547aa3bfb8b9dcc845124876a8f6bd545ccd5db38a03d9d2d68bf4eccbe3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
influxdb (0.0.1)
|
5
|
+
json
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.5)
|
11
|
+
crack (0.4.1)
|
12
|
+
safe_yaml (~> 0.9.0)
|
13
|
+
diff-lcs (1.2.4)
|
14
|
+
json (1.8.1)
|
15
|
+
rake (10.1.0)
|
16
|
+
rspec (2.14.1)
|
17
|
+
rspec-core (~> 2.14.0)
|
18
|
+
rspec-expectations (~> 2.14.0)
|
19
|
+
rspec-mocks (~> 2.14.0)
|
20
|
+
rspec-core (2.14.6)
|
21
|
+
rspec-expectations (2.14.3)
|
22
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
+
rspec-mocks (2.14.4)
|
24
|
+
safe_yaml (0.9.7)
|
25
|
+
webmock (1.15.0)
|
26
|
+
addressable (>= 2.2.7)
|
27
|
+
crack (>= 0.3.2)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.3)
|
34
|
+
influxdb!
|
35
|
+
rake
|
36
|
+
rspec
|
37
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Todd Persen
|
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.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
targeted_files = ARGV.drop(1)
|
4
|
+
file_pattern = targeted_files.empty? ? 'spec/**/*_spec.rb' : targeted_files
|
5
|
+
|
6
|
+
require 'rspec/core'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.pattern = FileList[file_pattern]
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.color_enabled = true
|
15
|
+
config.formatter = :documentation
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :spec
|
data/influxdb.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'influxdb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "influxdb"
|
8
|
+
spec.version = InfluxDB::VERSION
|
9
|
+
spec.authors = ["Todd Persen"]
|
10
|
+
spec.email = ["influxdb@googlegroups.com"]
|
11
|
+
spec.description = %q{This is the official Ruby library for InfluxDB.}
|
12
|
+
spec.summary = %q{Ruby library for InfluxDB.}
|
13
|
+
spec.homepage = "http://influxdb.org"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "json"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "webmock"
|
27
|
+
end
|
data/lib/influxdb.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module InfluxDB
|
4
|
+
class Client
|
5
|
+
def initialize(host, port, username, password, database)
|
6
|
+
@host = host
|
7
|
+
@port = port
|
8
|
+
@username = username
|
9
|
+
@password = password
|
10
|
+
@database = database
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_database(name)
|
14
|
+
http = Net::HTTP.new(@host, @port)
|
15
|
+
url = "/db?u=#{@username}&p=#{@password}"
|
16
|
+
data = JSON.generate({:name => name})
|
17
|
+
response = http.request(Net::HTTP::Post.new(url), data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_database(name)
|
21
|
+
http = Net::HTTP.new(@host, @port)
|
22
|
+
url = "/db/#{name}?u=#{@username}&p=#{@password}"
|
23
|
+
response = http.request(Net::HTTP::Delete.new(url))
|
24
|
+
end
|
25
|
+
|
26
|
+
def write_point(name, data)
|
27
|
+
http = Net::HTTP.new(@host, @port)
|
28
|
+
url = "/db/#{@database}/series?u=#{@username}&p=#{@password}"
|
29
|
+
payload = {:name => name, :points => [], :columns => []}
|
30
|
+
|
31
|
+
point = []
|
32
|
+
data.each_pair do |k,v|
|
33
|
+
payload[:columns].push k.to_s
|
34
|
+
point.push v
|
35
|
+
end
|
36
|
+
|
37
|
+
payload[:points].push point
|
38
|
+
data = JSON.generate(payload)
|
39
|
+
response = http.request(Net::HTTP::Post.new(url), data)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe InfluxDB::Client do
|
5
|
+
before do
|
6
|
+
@influxdb = InfluxDB::Client.new("influxdb.test", 9999, "username", "password", "database")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#new" do
|
10
|
+
it "should instantiate a new InfluxDB client" do
|
11
|
+
@influxdb = InfluxDB::Client.new("host", "port", "username", "password", "database")
|
12
|
+
|
13
|
+
@influxdb.should be_a(InfluxDB::Client)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#create_database" do
|
18
|
+
it "should POST to create a new database" do
|
19
|
+
stub_request(:post, "http://influxdb.test:9999/db").with(
|
20
|
+
:query => {:u => "username", :p => "password"},
|
21
|
+
:body => JSON.generate({:name => "foo"})
|
22
|
+
)
|
23
|
+
|
24
|
+
@influxdb.create_database("foo").should be_a(Net::HTTPOK)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#delete_database" do
|
29
|
+
it "should DELETE to remove a database" do
|
30
|
+
stub_request(:delete, "http://influxdb.test:9999/db/foo").with(
|
31
|
+
:query => {:u => "username", :p => "password"}
|
32
|
+
)
|
33
|
+
|
34
|
+
@influxdb.delete_database("foo").should be_a(Net::HTTPOK)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
describe "#write_point" do
|
40
|
+
it "should POST to add points" do
|
41
|
+
body = {
|
42
|
+
:name => "seriez",
|
43
|
+
:points => [["juan", 87]],
|
44
|
+
:columns => ["name", "age"]
|
45
|
+
}
|
46
|
+
|
47
|
+
stub_request(:post, "http://influxdb.test:9999/db/database/series").with(
|
48
|
+
:query => {:u => "username", :p => "password"},
|
49
|
+
:body => JSON.generate(body)
|
50
|
+
)
|
51
|
+
|
52
|
+
# data = [{:name => "juan", :age => 87}, {:name => "pablo", :age => 64}]
|
53
|
+
data = {:name => "juan", :age => 87}
|
54
|
+
|
55
|
+
@influxdb.write_point("seriez", data).should be_a(Net::HTTPOK)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: influxdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Todd Persen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: webmock
|
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
|
+
description: This is the official Ruby library for InfluxDB.
|
84
|
+
email:
|
85
|
+
- influxdb@googlegroups.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .travis.yml
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- influxdb.gemspec
|
98
|
+
- lib/influxdb.rb
|
99
|
+
- lib/influxdb/client.rb
|
100
|
+
- lib/influxdb/version.rb
|
101
|
+
- spec/influxdb/client_spec.rb
|
102
|
+
- spec/influxdb_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: http://influxdb.org
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.0.3
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Ruby library for InfluxDB.
|
128
|
+
test_files:
|
129
|
+
- spec/influxdb/client_spec.rb
|
130
|
+
- spec/influxdb_spec.rb
|
131
|
+
- spec/spec_helper.rb
|