Class: InfluxdbSetup::Config
- Inherits:
-
Object
- Object
- InfluxdbSetup::Config
- Defined in:
- lib/influxdb_setup/config.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #build_client(database = "", options = {}) ⇒ Object
- #db_name ⇒ Object
- #enabled? ⇒ Boolean
- #env ⇒ Object
-
#initialize(config: self.class.config, logger: Logger.new(STDOUT)) ⇒ Config
constructor
A new instance of Config.
- #password ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(config: self.class.config, logger: Logger.new(STDOUT)) ⇒ Config
17 18 19 20 |
# File 'lib/influxdb_setup/config.rb', line 17 def initialize(config: self.class.config, logger: Logger.new(STDOUT)) @config = config @logger = logger end |
Class Attribute Details
.config ⇒ Object
11 12 13 |
# File 'lib/influxdb_setup/config.rb', line 11 def self.config @config ||= YAML.load(ERB.new(File.read("config/influxdb.yml")).result)[env] end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
15 16 17 |
# File 'lib/influxdb_setup/config.rb', line 15 def logger @logger end |
Instance Method Details
#build_client(database = "", options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/influxdb_setup/config.rb', line 42 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
26 27 28 |
# File 'lib/influxdb_setup/config.rb', line 26 def db_name @config['db_name'] end |
#enabled? ⇒ Boolean
30 31 32 |
# File 'lib/influxdb_setup/config.rb', line 30 def enabled? @config['enabled'] end |
#env ⇒ Object
22 23 24 |
# File 'lib/influxdb_setup/config.rb', line 22 def env defined?(Rails) ? Rails.env : ENV.fetch('RAILS_ENV', 'development') end |
#password ⇒ Object
38 39 40 |
# File 'lib/influxdb_setup/config.rb', line 38 def password @config['password'] end |
#username ⇒ Object
34 35 36 |
# File 'lib/influxdb_setup/config.rb', line 34 def username @config['username'] end |