Browse Source

move to a generic config

Chris Mague 7 years ago
parent
commit
3d8bc080d1
3 changed files with 24 additions and 20 deletions
  1. 1 0
      lib/neoinfra.rb
  2. 1 20
      lib/neoinfra/accounts.rb
  3. 22 0
      lib/neoinfra/config.rb

+ 1 - 0
lib/neoinfra.rb

@@ -2,5 +2,6 @@
 
 # The supplies all of the various neoinfra info
 module NeoInfra
+  require 'neoinfra/config'
   require 'neoinfra/accounts'
 end

+ 1 - 20
lib/neoinfra/accounts.rb

@@ -2,30 +2,11 @@
 
 require 'yaml'
 require 'fog'
-require 'neo4j'
+require 'neoinfra/config'
 
 # NeoInfra Account information
 module NeoInfra
-  models_dir = File.join(
-    File.dirname(File.expand_path(__FILE__)), '..', 'models'
-  )
-
-  $LOAD_PATH.unshift(models_dir) unless
-    $LOAD_PATH.include?(models_dir) || $LOAD_PATH.include?(models_dir)
-
   # Provide informations about the accounts available
   class Accounts
-    attr_reader :accounts
-
-    def initialize(cfg = 'config.yaml')
-      @accounts = YAML.load_file(
-        File.join(File.dirname(File.expand_path(__FILE__)),
-                  '..', '..', cfg)
-      )
-    end
-
-    def list
-      accounts['accounts']
-    end
   end
 end

+ 22 - 0
lib/neoinfra/config.rb

@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require 'yaml'
+
+# NeoInfra Account information
+module NeoInfra
+  # load the config
+  class Config
+    attr_reader :config
+
+    def initialize(cfg = 'config.yaml')
+      @config = YAML.load_file(
+        File.join(File.dirname(File.expand_path(__FILE__)),
+                  '..', '..', cfg)
+      )
+    end
+
+    def accounts
+      @config['accounts']
+    end
+  end
+end