Sha256: d6abd6dcbbedf2646ec51cb99327c8497ee0356063fe3c5f63d83a849f784519
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
require 'singleton' require 'json' module Adminix class Config include Singleton DEFAULT_HOST = 'http://api.adminix.io'.freeze DEFAULT_SETUP_SERVER_PORT = '8080' attr_accessor :service_id, :secret_key, :host, :commands, :daemon, :setup_server_port def initialize self.host = ENV['ADMINIX_HOST'] || DEFAULT_HOST self.setup_server_port = ENV['ADMINIX_SETUP_SERVER_PORT'] || DEFAULT_SETUP_SERVER_PORT self.commands = [] end def read_creds_file file_content = IO.read("#{ENV['HOME']}/.adminix") data = JSON.parse(file_content) rescue nil unless data.nil? self.service_id ||= data['service_id'] self.secret_key ||= data['secret_key'] end true end def creds_file_exists? File.exists?("#{ENV['HOME']}/.adminix") end def credentials_defined? !service_id.nil? && !secret_key.nil? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
adminix-0.1.22 | lib/adminix/config.rb |
adminix-0.1.21 | lib/adminix/config.rb |