influxer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/.travis.yml +21 -0
- data/Gemfile +16 -0
- data/MIT-LICENSE +20 -0
- data/README.md +15 -0
- data/Rakefile +6 -0
- data/gemfiles/rails40.gemfile +7 -0
- data/gemfiles/rails41.gemfile +7 -0
- data/influxer.gemspec +27 -0
- data/lib/influxer/client.rb +9 -0
- data/lib/influxer/config.rb +47 -0
- data/lib/influxer/engine.rb +12 -0
- data/lib/influxer/metrics/metrics.rb +95 -0
- data/lib/influxer/metrics/relation.rb +143 -0
- data/lib/influxer/model.rb +33 -0
- data/lib/influxer/version.rb +3 -0
- data/lib/influxer.rb +31 -0
- data/lib/tasks/influxer_tasks.rake +4 -0
- data/spec/client_spec.rb +14 -0
- data/spec/config_spec.rb +18 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/metrics/testo_metrics.rb +3 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/testo.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +83 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/influxdb.yml +5 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +25 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20140730133818_add_testos.rb +11 -0
- data/spec/dummy/db/migrate/20140731162044_add_column_to_testos.rb +5 -0
- data/spec/dummy/db/schema.rb +22 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/metrics/metrics_spec.rb +133 -0
- data/spec/metrics/relation_spec.rb +78 -0
- data/spec/model/testo_spec.rb +18 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/dummy_metrics.rb +7 -0
- metadata +205 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f441918c927f139e08eaa0e07e66171c130b5f35
|
4
|
+
data.tar.gz: c26b9d64e124409ae490d391457010497b6dcea9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 942b9ff9c5960df2ee79188431373b24575d0cf5965136631fc993edbfbe7635adc6f321a15464a6a3904eed169f843bb4480af7d15e8ee3aecd9774144b69af
|
7
|
+
data.tar.gz: 63662390624e4c40b3c6cb14ee103157a6b30f27c15a1c7de6bc4354c7f0dd045b27386998d6a27510de02cd730fca1d4b4726d83071ffd879740d9995e335b9
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Numerous always-ignore extensions
|
2
|
+
*.diff
|
3
|
+
*.err
|
4
|
+
*.orig
|
5
|
+
*.log
|
6
|
+
*.rej
|
7
|
+
*.swo
|
8
|
+
*.swp
|
9
|
+
*.vi
|
10
|
+
*~
|
11
|
+
*.sass-cache
|
12
|
+
*.iml
|
13
|
+
.idea/
|
14
|
+
|
15
|
+
# Sublime
|
16
|
+
*.sublime-project
|
17
|
+
*.sublime-workspace
|
18
|
+
|
19
|
+
# OS or Editor folders
|
20
|
+
.DS_Store
|
21
|
+
.cache
|
22
|
+
.project
|
23
|
+
.settings
|
24
|
+
.tmproj
|
25
|
+
Thumbs.db
|
26
|
+
|
27
|
+
.bundle/
|
28
|
+
log/*.log
|
29
|
+
pkg/
|
30
|
+
spec/dummy/db/*.sqlite3
|
31
|
+
spec/dummy/db/*.sqlite3-journal
|
32
|
+
spec/dummy/tmp/
|
33
|
+
|
34
|
+
Gemfile.lock
|
35
|
+
.rspec
|
36
|
+
|
37
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 2.1
|
5
|
+
|
6
|
+
gemfile:
|
7
|
+
- Gemfile
|
8
|
+
|
9
|
+
matrix:
|
10
|
+
include:
|
11
|
+
- rvm: 2.0.0
|
12
|
+
gemfile: gemfiles/rails40.gemfile
|
13
|
+
|
14
|
+
- rvm: 2.1
|
15
|
+
gemfile: gemfiles/rails40.gemfile
|
16
|
+
|
17
|
+
- rvm: 2.0.0
|
18
|
+
gemfile: gemfiles/rails41.gemfile
|
19
|
+
|
20
|
+
- rvm: 2.1
|
21
|
+
gemfile: gemfiles/rails41.gemfile
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in influxer.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gem 'sqlite3'
|
7
|
+
gem 'pry-byebug'
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
# Declare any dependencies that are still in development here instead of in
|
11
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
12
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
13
|
+
# your gem to rubygems.org.
|
14
|
+
|
15
|
+
# To use debugger
|
16
|
+
# gem 'debugger'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/palkan/influxer.svg?branch=master)](https://travis-ci.org/palkan/influxer)
|
2
|
+
|
3
|
+
## Influxer
|
4
|
+
|
5
|
+
Use InfluxDB in your Rails (>4.0) application.
|
6
|
+
|
7
|
+
### Basic support
|
8
|
+
|
9
|
+
ToDo
|
10
|
+
|
11
|
+
### ActiveRecord
|
12
|
+
|
13
|
+
`has_metrics`
|
14
|
+
|
15
|
+
ToDo
|
data/Rakefile
ADDED
data/influxer.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "influxer/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "influxer"
|
9
|
+
s.version = Influxer::VERSION
|
10
|
+
s.authors = ["Vlad Dem"]
|
11
|
+
s.email = ["dementiev.vm@gmail.com"]
|
12
|
+
s.homepage = "http://github.com/palkan/influxer"
|
13
|
+
s.summary = "InfluxDB support for Rails"
|
14
|
+
s.description = "InfluxDB the Rails way"
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split($/)
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency "rails", '~> 4.0'
|
21
|
+
s.add_dependency "influxdb", "~> 0.1.0", ">= 0.1.8"
|
22
|
+
|
23
|
+
s.add_development_dependency "timecop"
|
24
|
+
s.add_development_dependency "simplecov", ">= 0.3.8"
|
25
|
+
s.add_development_dependency "rspec", "~> 3.0.0"
|
26
|
+
s.add_development_dependency "rspec-rails", "~> 3.0.0"
|
27
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Influxer
|
2
|
+
class Config
|
3
|
+
attr_accessor :database,
|
4
|
+
:host,
|
5
|
+
:port,
|
6
|
+
:username,
|
7
|
+
:password,
|
8
|
+
:use_ssl,
|
9
|
+
:async,
|
10
|
+
:retry,
|
11
|
+
:time_precision,
|
12
|
+
:initial_delay,
|
13
|
+
:max_delay,
|
14
|
+
:read_timeout,
|
15
|
+
:write_timeout
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@database = 'db'
|
19
|
+
@host = 'localhost'
|
20
|
+
@port = 8083
|
21
|
+
@use_ssl = false
|
22
|
+
@async = true
|
23
|
+
@retry = false
|
24
|
+
@time_precision = 's'
|
25
|
+
@max_delay = 30
|
26
|
+
@initial_delay = 0.01
|
27
|
+
@read_timeout = 30
|
28
|
+
@write_timeout = 5
|
29
|
+
|
30
|
+
config_path = Rails.root.join("config","influxdb.yml")
|
31
|
+
|
32
|
+
config = {}
|
33
|
+
|
34
|
+
if File.file? config_path
|
35
|
+
config = YAML.load_file(config_path)[Rails.env] || {}
|
36
|
+
end
|
37
|
+
|
38
|
+
unless Rails.application.try(:secrets).nil?
|
39
|
+
config.merge! Rails.application.secrets.influxdb
|
40
|
+
end
|
41
|
+
|
42
|
+
config.each do |key, val|
|
43
|
+
self.send("#{key}=",val)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'influxer'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module Influxer
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
initializer "extend ActiveRecord with influxer" do |app|
|
7
|
+
ActiveSupport.on_load(:active_record) do
|
8
|
+
ActiveRecord::Base.send :include, Influxer::Model
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Influxer
|
2
|
+
class MetricsError < StandardError; end
|
3
|
+
class MetricsInvalid < MetricsError; end
|
4
|
+
|
5
|
+
class Metrics
|
6
|
+
include ActiveModel::Model
|
7
|
+
include ActiveModel::Validations
|
8
|
+
extend ActiveModel::Callbacks
|
9
|
+
|
10
|
+
define_model_callbacks :write
|
11
|
+
|
12
|
+
class << self
|
13
|
+
delegate :select, :where, :group, :limit, :delete_all, to: :all
|
14
|
+
|
15
|
+
def attributes(*attrs)
|
16
|
+
attrs.each do |name|
|
17
|
+
define_method("#{name}=") do |val|
|
18
|
+
@attributes[name] = val
|
19
|
+
end
|
20
|
+
|
21
|
+
define_method("#{name}") do
|
22
|
+
@attributes[name]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def inherited(subclass)
|
28
|
+
subclass.set_series
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_series(*args)
|
32
|
+
if args.empty?
|
33
|
+
matches = self.to_s.match(/^(.*)Metrics$/)
|
34
|
+
if matches.nil?
|
35
|
+
@series = self.to_s.underscore
|
36
|
+
else
|
37
|
+
@series = matches[1].split("::").join("_").underscore
|
38
|
+
end
|
39
|
+
elsif args.first.is_a?(Proc)
|
40
|
+
@series = args.first
|
41
|
+
else
|
42
|
+
@series = args.join(",")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def series
|
47
|
+
@series
|
48
|
+
end
|
49
|
+
|
50
|
+
def all
|
51
|
+
Relation.new self
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(attributes = {})
|
56
|
+
@attributes = {}
|
57
|
+
@persisted = false
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def write
|
62
|
+
raise MetricsError.new('Cannot write the same metrics twice') if self.persisted?
|
63
|
+
|
64
|
+
return false if self.invalid?
|
65
|
+
|
66
|
+
run_callbacks :write do
|
67
|
+
self.write_point
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def write!
|
72
|
+
raise MetricsInvalid.new('Validation failed') if self.invalid?
|
73
|
+
self.write
|
74
|
+
end
|
75
|
+
|
76
|
+
def write_point
|
77
|
+
client.write_point series, @attributes
|
78
|
+
@persisted = true
|
79
|
+
end
|
80
|
+
|
81
|
+
def persisted?
|
82
|
+
@persisted
|
83
|
+
end
|
84
|
+
|
85
|
+
def series
|
86
|
+
self.class.series.is_a?(Proc) ? self.class.series.call(self) : self.class.series
|
87
|
+
end
|
88
|
+
|
89
|
+
def client
|
90
|
+
Influxer.client
|
91
|
+
end
|
92
|
+
|
93
|
+
attributes :time
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module Influxer
|
2
|
+
class Relation
|
3
|
+
|
4
|
+
# Initialize new Relation for 'klass' (Class) metrics.
|
5
|
+
#
|
6
|
+
# Available params:
|
7
|
+
# :attributes - hash of attributes to be included to new Metrics object and where clause of Relation
|
8
|
+
#
|
9
|
+
def initialize(klass, params = {})
|
10
|
+
@instance = klass.new params[:attributes]
|
11
|
+
self.reset
|
12
|
+
self.where(params[:attributes]) if params[:attributes].present?
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def write(params = {})
|
18
|
+
build params
|
19
|
+
@instance.write
|
20
|
+
end
|
21
|
+
|
22
|
+
def build(params = {})
|
23
|
+
params.each do |key,val|
|
24
|
+
@instance.send("#{key}=", val) if @instance.respond_to?(key)
|
25
|
+
end
|
26
|
+
@instance
|
27
|
+
end
|
28
|
+
|
29
|
+
# accepts strings and symbols only
|
30
|
+
def select(*args)
|
31
|
+
return self if args.empty?
|
32
|
+
@select_values.concat args
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# accepts hash or strings conditions
|
37
|
+
# TODO: add sanitization and array support
|
38
|
+
|
39
|
+
def where(*args,**hargs)
|
40
|
+
@where_values.concat args.map{|str| "(#{str})"}
|
41
|
+
|
42
|
+
unless hargs.empty?
|
43
|
+
hargs.each do |key, val|
|
44
|
+
@where_values << "(#{key}=#{quoted(val)})"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
def group(*args)
|
51
|
+
return self if args.empty?
|
52
|
+
@group_values.concat args
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
def limit(val)
|
57
|
+
@limit = val
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_sql
|
62
|
+
sql = ["select"]
|
63
|
+
|
64
|
+
if @select_values.empty?
|
65
|
+
sql << "*"
|
66
|
+
else
|
67
|
+
sql << @select_values.join(",")
|
68
|
+
end
|
69
|
+
|
70
|
+
sql << "from #{@instance.series}"
|
71
|
+
|
72
|
+
unless @group_values.empty?
|
73
|
+
sql << "group by #{@group_values.join(",")}"
|
74
|
+
end
|
75
|
+
|
76
|
+
unless @where_values.empty?
|
77
|
+
sql << "where #{@where_values.join(" and ")}"
|
78
|
+
end
|
79
|
+
|
80
|
+
unless @limit.nil?
|
81
|
+
sql << "limit #{@limit}"
|
82
|
+
end
|
83
|
+
sql.join " "
|
84
|
+
end
|
85
|
+
|
86
|
+
def to_a
|
87
|
+
return @records if loaded?
|
88
|
+
load
|
89
|
+
@records
|
90
|
+
end
|
91
|
+
|
92
|
+
def inspect
|
93
|
+
entries = to_a.take(11).map!(&:inspect)
|
94
|
+
entries[10] = '...' if entries.size == 11
|
95
|
+
|
96
|
+
"#<#{self.class.name} [#{entries.join(', ')}]>"
|
97
|
+
end
|
98
|
+
|
99
|
+
def as_json
|
100
|
+
to_a.as_json
|
101
|
+
end
|
102
|
+
|
103
|
+
def delete_all
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
protected
|
108
|
+
def load
|
109
|
+
@records = @instance.client.query to_sql
|
110
|
+
@loaded = true
|
111
|
+
end
|
112
|
+
|
113
|
+
def loaded?
|
114
|
+
@loaded
|
115
|
+
end
|
116
|
+
|
117
|
+
def reset
|
118
|
+
@limit = nil
|
119
|
+
@select_values = []
|
120
|
+
@group_values = []
|
121
|
+
@where_values = []
|
122
|
+
@records = nil
|
123
|
+
@loaded = false
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
def reload
|
128
|
+
self.reset
|
129
|
+
self.load
|
130
|
+
self
|
131
|
+
end
|
132
|
+
|
133
|
+
def quoted(val)
|
134
|
+
if val.is_a?(String)
|
135
|
+
"'#{val}'"
|
136
|
+
elsif val.kind_of?(Time) or val.kind_of?(DateTime)
|
137
|
+
"#{val.to_i}s"
|
138
|
+
else
|
139
|
+
val.to_s
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module Influxer
|
4
|
+
module Model
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def has_metrics(*args, **params)
|
9
|
+
metrics_name = args.empty? ? "metrics" : args.first.to_s
|
10
|
+
|
11
|
+
klass = params[:class_name].present? ? params[:class_name] : "#{self}Metrics"
|
12
|
+
klass = klass.constantize
|
13
|
+
|
14
|
+
attrs = nil
|
15
|
+
|
16
|
+
if params[:inherits].present?
|
17
|
+
attrs = params[:inherits]
|
18
|
+
end
|
19
|
+
|
20
|
+
define_method(metrics_name) do
|
21
|
+
rel_attrs = {self.class.to_s.foreign_key => self.id}
|
22
|
+
|
23
|
+
unless attrs.nil?
|
24
|
+
attrs.each do |key|
|
25
|
+
rel_attrs[key] = self.send(key)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Relation.new klass, attributes: rel_attrs
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/influxer.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'influxer/version'
|
2
|
+
|
3
|
+
module Influxer
|
4
|
+
require 'influxer/config'
|
5
|
+
require 'influxer/client'
|
6
|
+
require 'influxer/metrics/metrics'
|
7
|
+
require 'influxer/metrics/relation'
|
8
|
+
|
9
|
+
module Model
|
10
|
+
require 'influxer/model'
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'influxer/engine'
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@config ||= Config.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.configure
|
20
|
+
yield(config) if block_given?
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.client
|
24
|
+
@client ||= Client.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.reset
|
28
|
+
@config = nil
|
29
|
+
@client = nil
|
30
|
+
end
|
31
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Influxer::Client do
|
4
|
+
|
5
|
+
let(:conf) { Influxer.config }
|
6
|
+
let(:client) { Influxer.client }
|
7
|
+
|
8
|
+
it "should have config params" do
|
9
|
+
expect(client.username).to eq conf.username
|
10
|
+
expect(client.port).to eq conf.port
|
11
|
+
expect(client.database).to eq conf.database
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Influxer::Config do
|
4
|
+
|
5
|
+
let(:conf) { Influxer.config }
|
6
|
+
|
7
|
+
it "should load config from file" do
|
8
|
+
expect(conf.retry).to eq 5
|
9
|
+
expect(conf.host).to eq "test.host"
|
10
|
+
end
|
11
|
+
|
12
|
+
unless Rails.application.try(:secrets).nil?
|
13
|
+
it "should load config from secrets" do
|
14
|
+
expect(conf.username).to eq "test"
|
15
|
+
expect(conf.password).to eq "test"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|