Class: InfluxdbSetup::Config
- Inherits:
-
Object
- Object
- InfluxdbSetup::Config
- Defined in:
- lib/influxdb_setup/config.rb
Class Attribute Summary collapse
Instance Method Summary collapse
- #build_client(database = "", options = {}) ⇒ Object
- #db_name ⇒ Object
- #enabled? ⇒ Boolean
- #env ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #password ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
14 15 16 |
# File 'lib/influxdb_setup/config.rb', line 14 def initialize @config = self.class.config end |
Class Attribute Details
.config ⇒ Object
10 11 12 |
# File 'lib/influxdb_setup/config.rb', line 10 def self.config @config ||= YAML.load(ERB.new(File.read("config/influxdb.yml")).result)[env] end |
Instance Method Details
#build_client(database = "", options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/influxdb_setup/config.rb', line 38 def build_client(database = "", = {}) InfluxDB::Client.new(database, { username: "root", password: "root", hosts: @config["hosts"], port: @config.fetch("port", 8086), async: false, use_ssl: @config.fetch("use_ssl", false), retry: false, }.merge()) end |
#db_name ⇒ Object
22 23 24 |
# File 'lib/influxdb_setup/config.rb', line 22 def db_name @config['db_name'] end |
#enabled? ⇒ Boolean
26 27 28 |
# File 'lib/influxdb_setup/config.rb', line 26 def enabled? @config['enabled'] end |
#env ⇒ Object
18 19 20 |
# File 'lib/influxdb_setup/config.rb', line 18 def env defined?(Rails) ? Rails.env : ENV.fetch('RAILS_ENV', 'development') end |
#password ⇒ Object
34 35 36 |
# File 'lib/influxdb_setup/config.rb', line 34 def password @config['password'] end |
#username ⇒ Object
30 31 32 |
# File 'lib/influxdb_setup/config.rb', line 30 def username @config['username'] end |