Abstract conf parsing to class

This commit is contained in:
Brian Cain 2015-10-01 23:32:17 -07:00
parent 9b176a7bd5
commit c738b0c566
2 changed files with 16 additions and 12 deletions

View file

@ -2,10 +2,10 @@
require 'rubygems'
require 'commander'
require 'yaml'
require 'vmfloaty/auth'
require 'vmfloaty/pooler'
require 'vmfloaty/version'
require 'vmfloaty/conf'
class Vmfloaty
include Commander::Methods
@ -14,7 +14,7 @@ class Vmfloaty
program :version, Version.get
program :description, 'A CLI helper tool for Puppet Labs vmpooler to help you stay afloat'
config = read_config
config = Conf.read_config
command :get do |c|
c.syntax = 'floaty get [hostname,...]'
@ -235,14 +235,4 @@ class Vmfloaty
run!
end
def read_config
conf = {}
begin
conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml")
rescue
STDERR.puts "WARNING: There was no config file at #{Dir.home}/.vmfloaty.yml"
end
conf
end
end

14
lib/vmfloaty/conf.rb Normal file
View file

@ -0,0 +1,14 @@
require 'yaml'
class Conf
def self.read_config
conf = {}
begin
conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml")
rescue
STDERR.puts "WARNING: There was no config file at #{Dir.home}/.vmfloaty.yml"
end
conf
end
end