Class: DNSimple::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dnsimple/client.rb

Class Method Summary collapse

Class Method Details

.base_uriObject



32
33
34
# File 'lib/dnsimple/client.rb', line 32

def self.base_uri
  @@base_uri ||= "https://dnsimple.com"
end

.base_uri=(base_uri) ⇒ Object



36
37
38
# File 'lib/dnsimple/client.rb', line 36

def self.base_uri=(base_uri)
  @@base_uri = base_uri.gsub(/\/$/, '')
end

.credentialsObject



28
29
30
# File 'lib/dnsimple/client.rb', line 28

def self.credentials
  {:username => self.username, :password => self.password}
end

.debug=(debug) ⇒ Object



6
7
8
# File 'lib/dnsimple/client.rb', line 6

def self.debug=(debug)
  @debug = debug
end

.debug?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/dnsimple/client.rb', line 3

def self.debug?
  @debug
end

.load_credentials(path = '~/.dnsimple') ⇒ Object



40
41
42
43
44
45
# File 'lib/dnsimple/client.rb', line 40

def self.load_credentials(path='~/.dnsimple')
  credentials = YAML.load(File.new(File.expand_path(path)))
  self.username = credentials['username']
  self.password = credentials['password']
  "Credentials loaded from #{path}" 
end

.passwordObject

Raises:

  • (RuntimeError)


19
20
21
22
# File 'lib/dnsimple/client.rb', line 19

def self.password
  raise RuntimeError, "You must set your password first: DNSimple::Client.password = 'password'" unless defined?(@@password)
  @@password
end

.password=(password) ⇒ Object



24
25
26
# File 'lib/dnsimple/client.rb', line 24

def self.password=(password)
  @@password = password
end

.standard_optionsObject



47
48
49
# File 'lib/dnsimple/client.rb', line 47

def self.standard_options
  {:basic_auth => credentials, :format => :json, :headers => {'Accept' => 'application/json'}}
end

.usernameObject

Raises:

  • (RuntimeError)


10
11
12
13
# File 'lib/dnsimple/client.rb', line 10

def self.username
  raise RuntimeError, "You must set your username first: DNSimple::Client.username = 'username'" unless defined?(@@username)
  @@username
end

.username=(username) ⇒ Object



15
16
17
# File 'lib/dnsimple/client.rb', line 15

def self.username=(username)
  @@username = username
end