class Sitefull::Cloud::Provider

Constants

PROVIDERS

Attributes

options[R]
type[R]

Public Class Methods

all_required_options() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 18
def all_required_options
  PROVIDERS.map { |type| required_options_for(type) }.flatten
end
new(type, options = {}) click to toggle source
# File lib/sitefull-cloud/provider.rb, line 11
def initialize(type, options = {})
  @type = type || 'base'
  extend(provider_module)
  @options = respond_to?(:process) ? process(options) : options
end
provider_class(type) click to toggle source
# File lib/sitefull-cloud/provider.rb, line 26
def provider_class(type)
  require "sitefull-cloud/provider/#{type}"
  Kernel.const_get "Sitefull::Provider::#{type.capitalize}"
end
required_options_for(type) click to toggle source
# File lib/sitefull-cloud/provider.rb, line 22
def required_options_for(type)
  provider_class(type).const_get(:REQUIRED_OPTIONS)
end

Public Instance Methods

auth() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 32
def auth
  @auth ||= Sitefull::Cloud::Auth.new(type, options)
end

Protected Instance Methods

credentials() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 38
def credentials
  @credentials ||= auth.credentials
end
key_data() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 42
def key_data
  @key_data ||= generate_key_data
end

Private Instance Methods

generate_key_data() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 53
def generate_key_data
  key = OpenSSL::PKey::RSA.new 2048
  { public_key: [ key.to_blob ].pack('m0'), private_key: key.to_s }
end
provider_module() click to toggle source
# File lib/sitefull-cloud/provider.rb, line 48
def provider_module
  return self.class.provider_class(:mock) if mocked?
  @provider_module ||= self.class.provider_class(type)
end