Class: ElderDocs::Config
- Inherits:
-
Object
- Object
- ElderDocs::Config
- Defined in:
- lib/elder_docs/config.rb
Instance Attribute Summary collapse
-
#admin_password ⇒ Object
Returns the value of attribute admin_password.
-
#api_server ⇒ Object
Returns the value of attribute api_server.
-
#api_servers ⇒ Object
readonly
Returns the value of attribute api_servers.
-
#auth_types ⇒ Object
Returns the value of attribute auth_types.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#ui_config ⇒ Object
Returns the value of attribute ui_config.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_config_file ⇒ Object
Constructor Details
#initialize ⇒ Config
9 10 11 12 13 14 15 16 |
# File 'lib/elder_docs/config.rb', line 9 def initialize @mount_path = nil @api_server = nil @auth_types = ['bearer', 'api_key', 'basic', 'oauth2'] @ui_config = {} @admin_password = nil load_config_file end |
Instance Attribute Details
#admin_password ⇒ Object
Returns the value of attribute admin_password.
7 8 9 |
# File 'lib/elder_docs/config.rb', line 7 def admin_password @admin_password end |
#api_server ⇒ Object
Returns the value of attribute api_server.
7 8 9 |
# File 'lib/elder_docs/config.rb', line 7 def api_server @api_server end |
#api_servers ⇒ Object (readonly)
Returns the value of attribute api_servers.
44 45 46 |
# File 'lib/elder_docs/config.rb', line 44 def api_servers @api_servers end |
#auth_types ⇒ Object
Returns the value of attribute auth_types.
7 8 9 |
# File 'lib/elder_docs/config.rb', line 7 def auth_types @auth_types end |
#mount_path ⇒ Object
Returns the value of attribute mount_path.
7 8 9 |
# File 'lib/elder_docs/config.rb', line 7 def mount_path @mount_path end |
#ui_config ⇒ Object
Returns the value of attribute ui_config.
7 8 9 |
# File 'lib/elder_docs/config.rb', line 7 def ui_config @ui_config end |
Class Method Details
.instance ⇒ Object
46 47 48 |
# File 'lib/elder_docs/config.rb', line 46 def self.instance @instance ||= new end |
Instance Method Details
#load_config_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/elder_docs/config.rb', line 18 def load_config_file # Try to find config file in Rails root or current directory config_paths = [] if defined?(Rails) && Rails.root config_paths << Rails.root.join('elderdocs.yml').to_s end config_paths << File.join(Dir.pwd, 'elderdocs.yml') config_path = config_paths.find { |path| File.exist?(path) } return unless config_path begin config = YAML.load_file(config_path) @mount_path = config['mount_path'] if config['mount_path'] @api_server = config['api_server'] if config['api_server'] @api_servers = config['api_servers'] if config['api_servers'] @auth_types = config['auth_types'] if config['auth_types'] @ui_config = config['ui'] if config['ui'] # YAML uses 'ui' key, but we store as ui_config @admin_password = config['admin_password'] if config['admin_password'] rescue => e warn "Warning: Could not load elderdocs.yml: #{e.}" end end |