Sha256: be82ead07ba834ebf68fbaab208029a2922c75b7cd6c0a118c55235917c649f5

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'public_suffix'
require 'glare/version'
require 'glare/credentials'
require 'glare/client'
require 'glare/domain'
require 'glare/api_response'
require 'glare/dns_record'
require 'glare/cf_dns_records'
require 'glare/errors'

module Glare
  class << self
    def register(fqdn, destination, type)
      client = build_client
      Domain.new(client).register(fqdn, destination, type)
    end

    def resolve(fqdn, type)
      client = build_client
      Domain.new(client).resolve(fqdn, type)
    end

    def deregister(fqdn, type)
      client = build_client
      Domain.new(client).deregister(fqdn, type)
    end

    private

    CF_EMAIL = 'CF_EMAIL'.freeze
    CF_AUTH_KEY = 'CF_AUTH_KEY'.freeze

    def client(credentials)
      Glare::Client.new(credentials.email, credentials.auth_key)
    end

    def default_credentials
      email = ENV[CF_EMAIL]
      auth_key = ENV[CF_AUTH_KEY]
      Credentials.new(email, auth_key)
    end

    def build_client
      credentials = default_credentials
      client(credentials)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glare-0.4.0 lib/glare.rb
glare-0.2.2 lib/glare.rb
glare-0.2.1 lib/glare.rb
glare-0.2.0 lib/glare.rb