Class: Adminix::Config
- Inherits:
-
Object
- Object
- Adminix::Config
- Includes:
- Singleton
- Defined in:
- lib/adminix/config.rb
Constant Summary collapse
- DEFAULT_HOST =
'http://api.adminix.io'.freeze
- DEFAULT_SETUP_SERVER_PORT =
'8080'
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#daemon ⇒ Object
Returns the value of attribute daemon.
-
#host ⇒ Object
Returns the value of attribute host.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
-
#service_id ⇒ Object
Returns the value of attribute service_id.
-
#setup_server_port ⇒ Object
Returns the value of attribute setup_server_port.
Instance Method Summary collapse
- #credentials_defined? ⇒ Boolean
- #creds_file_exists? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #read_creds_file ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
13 14 15 16 17 |
# File 'lib/adminix/config.rb', line 13 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 |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def commands @commands end |
#daemon ⇒ Object
Returns the value of attribute daemon.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def daemon @daemon end |
#host ⇒ Object
Returns the value of attribute host.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def host @host end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def secret_key @secret_key end |
#service_id ⇒ Object
Returns the value of attribute service_id.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def service_id @service_id end |
#setup_server_port ⇒ Object
Returns the value of attribute setup_server_port.
11 12 13 |
# File 'lib/adminix/config.rb', line 11 def setup_server_port @setup_server_port end |
Instance Method Details
#credentials_defined? ⇒ Boolean
35 36 37 |
# File 'lib/adminix/config.rb', line 35 def credentials_defined? !service_id.nil? && !secret_key.nil? end |
#creds_file_exists? ⇒ Boolean
31 32 33 |
# File 'lib/adminix/config.rb', line 31 def creds_file_exists? File.exists?("#{ENV['HOME']}/.adminix") end |
#read_creds_file ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/adminix/config.rb', line 19 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 |