Sha256: 27cb005a826568e62640e933a269599546bc4895ff0b16278be0b890c0575966
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
require 'yaml' require 'active_support/inflector' class Provider def initialize config_file = "#{Ops::PROVIDERS_DIR}/#{self.class.name.underscore}.yml" begin config = YAML.load_file config_file rescue raise "Please, create '#{config_file}' file following gem instrunctions" end create_connection config end def create(config) raise "CREATE action not implemented" end def delete(host) raise "DELETE action not implemented" end def list_params raise "LIST PARAMS action not implemented" end private def create_connection(config) raise "PROVIDER connection should be created" end end Dir.glob("#{File.dirname(__FILE__)}/providers/*.rb").each { |r| load r } class ProviderFactory class << self def build(provider_name) provider_name.classify.constantize.new end def list_providers say Dir.glob("#{File.dirname(__FILE__)}/providers/*.rb"). select{|f| f.include? ".rb"}. map{|f| f.split("/").last.split(".")[0]}. join ", " end end end class Host def initialize(host_name) @host = host_name config_file = "#{Ops::HOSTS_DIR}/#{host_name}.yml" begin @config = YAML.load_file "#{config_file}" @config["name"]= host_name rescue raise "Please, create '#{config_file}' file with token value" end @provider = ProviderFactory.build @config["provider"] end def create @provider.create @config end def delete @provider.delete @host end end
Version data entries
9 entries across 9 versions & 1 rubygems