influx_orm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +37 -2
- data/Gemfile +1 -2
- data/README.md +2 -0
- data/gemfiles/activesupport-4.0 +7 -0
- data/gemfiles/activesupport-4.1 +7 -0
- data/gemfiles/activesupport-4.2 +7 -0
- data/gemfiles/activesupport-5.0 +7 -0
- data/gemfiles/activesupport-5.1 +7 -0
- data/influx_orm.gemspec +1 -1
- data/lib/influx_orm/model.rb +3 -1
- data/lib/influx_orm/version.rb +1 -1
- data/lib/influx_orm.rb +1 -0
- metadata +8 -4
- data/lib/influx_orm/:noh +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7cfd03c923d45d9cac1d1aee1300767b044173e
|
4
|
+
data.tar.gz: eb5b2c4f5b3a429dd6f212ecc2e9fdd6220b7efa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00300c22851953445452d9cfbae58559e0e3e26faa521c88c1b8f9c1b4d63af0721537dd9e9bef321a28648b4341d5c6a5999f4e6efac31e42e91affa28b9fd7
|
7
|
+
data.tar.gz: 77616be8dbfb53fd1e55213a652cc97572123f6bcbbb05e67bd71a802c3a735a580e6acccc1bace96e9c853c20cc33a44da1254f4f3eb9d9b6ad3ce3284b8a80
|
data/.travis.yml
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
-
sudo:
|
1
|
+
sudo: enable
|
2
|
+
dist: trusty
|
2
3
|
language: ruby
|
4
|
+
|
5
|
+
cache: bundler
|
6
|
+
|
3
7
|
rvm:
|
8
|
+
- 2.1.10
|
9
|
+
- 2.2.7
|
10
|
+
- 2.3.4
|
4
11
|
- 2.4.1
|
5
|
-
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/activesupport-4.0
|
15
|
+
- gemfiles/activesupport-4.1
|
16
|
+
- gemfiles/activesupport-4.2
|
17
|
+
- gemfiles/activesupport-5.0
|
18
|
+
- gemfiles/activesupport-5.1
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
exclude:
|
22
|
+
- {rvm: '2.1.10', gemfile: 'gemfiles/activesupport-5.0'}
|
23
|
+
- {rvm: '2.1.10', gemfile: 'gemfiles/activesupport-5.1'}
|
24
|
+
- {rvm: '2.4.1', gemfile: 'gemfiles/activesupport-4.0'}
|
25
|
+
- {rvm: '2.4.1', gemfile: 'gemfiles/activesupport-4.1'}
|
26
|
+
|
27
|
+
addons:
|
28
|
+
apt:
|
29
|
+
sources:
|
30
|
+
- sourceline: 'deb https://repos.influxdata.com/ubuntu trusty stable'
|
31
|
+
key_url: 'https://repos.influxdata.com/influxdb.key'
|
32
|
+
|
33
|
+
packages:
|
34
|
+
influxdb
|
35
|
+
|
36
|
+
before_install:
|
37
|
+
- sudo service influxdb start
|
38
|
+
- gem install bundler --no-doc
|
39
|
+
|
40
|
+
script: bundle exec rspec
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A simple influxdb orm for ruby, base [influxdb-ruby](https://github.com/influxdata/influxdb-ruby)
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/xiejiangzhi/influx_orm.svg?branch=master)](https://travis-ci.org/xiejiangzhi/influx_orm)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
data/influx_orm.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "influxdb", "~> 0.3.14"
|
25
|
-
spec.add_dependency "activesupport", ">=
|
25
|
+
spec.add_dependency "activesupport", ">= 4.0"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.14"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/influx_orm/model.rb
CHANGED
@@ -30,7 +30,9 @@ module InfluxORM::Model
|
|
30
30
|
# dependent class method: attrs_to_point
|
31
31
|
def import(points_attrs)
|
32
32
|
points = points_attrs.map do |point_attrs|
|
33
|
-
attrs_to_point(point_attrs)
|
33
|
+
r = attrs_to_point(point_attrs)
|
34
|
+
r[:series] ||= table_name
|
35
|
+
r
|
34
36
|
end
|
35
37
|
connection.import(points)
|
36
38
|
end
|
data/lib/influx_orm/version.rb
CHANGED
data/lib/influx_orm.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influx_orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhi.xie
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,9 +112,13 @@ files:
|
|
112
112
|
- bin/setup
|
113
113
|
- examples/model.rb
|
114
114
|
- examples/multiple_config.rb
|
115
|
+
- gemfiles/activesupport-4.0
|
116
|
+
- gemfiles/activesupport-4.1
|
117
|
+
- gemfiles/activesupport-4.2
|
118
|
+
- gemfiles/activesupport-5.0
|
119
|
+
- gemfiles/activesupport-5.1
|
115
120
|
- influx_orm.gemspec
|
116
121
|
- lib/influx_orm.rb
|
117
|
-
- lib/influx_orm/:noh
|
118
122
|
- lib/influx_orm/attributes.rb
|
119
123
|
- lib/influx_orm/configuration.rb
|
120
124
|
- lib/influx_orm/connection.rb
|
data/lib/influx_orm/:noh
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module InfluxORM
|
2
|
-
class Connection
|
3
|
-
attr_reader :config, :database, :client_config, :configuration
|
4
|
-
|
5
|
-
def initialize(options, configuration)
|
6
|
-
@config = options.with_indifferent_access
|
7
|
-
@configuration = configuration
|
8
|
-
end
|
9
|
-
|
10
|
-
def db
|
11
|
-
@db ||= InfluxDB::Client.new(config)
|
12
|
-
end
|
13
|
-
|
14
|
-
def query(sql)
|
15
|
-
log(sql) { db.query(sql) }
|
16
|
-
end
|
17
|
-
|
18
|
-
def insert(table_name, point)
|
19
|
-
log("INSERT to #{table_name}: #{point.to_sql}") { db.write_point(table_name, point) }
|
20
|
-
end
|
21
|
-
|
22
|
-
def import(data)
|
23
|
-
db.write_points(data)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def log(log, &block)
|
29
|
-
t = Time.now
|
30
|
-
block.call
|
31
|
-
ensure
|
32
|
-
c = (Time.now - t) * 1000
|
33
|
-
configuration.logger.info("[InfluxORM] (%.3f ms) %s" % [c, log])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|