Class: EM::Redfinger::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/em-redfinger/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, uri_template = nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
# File 'lib/em-redfinger/client.rb', line 10

def initialize(email, uri_template = nil)
  self.          = normalize(email)
  self.domain           = .split('@').last
  self.xrd_timeout      = 10
  self.xrd_open_timeout = 5
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



8
9
10
# File 'lib/em-redfinger/client.rb', line 8

def 
  @account
end

#domainObject

Returns the value of attribute domain.



8
9
10
# File 'lib/em-redfinger/client.rb', line 8

def domain
  @domain
end

#uri_templateObject

Returns the value of attribute uri_template.



8
9
10
# File 'lib/em-redfinger/client.rb', line 8

def uri_template
  @uri_template
end

#xrd_open_timeoutObject

Returns the value of attribute xrd_open_timeout.



8
9
10
# File 'lib/em-redfinger/client.rb', line 8

def xrd_open_timeout
  @xrd_open_timeout
end

#xrd_timeoutObject

Returns the value of attribute xrd_timeout.



8
9
10
# File 'lib/em-redfinger/client.rb', line 8

def xrd_timeout
  @xrd_timeout
end

Instance Method Details

#fingerObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/em-redfinger/client.rb', line 17

def finger
  retrieve_template_from_xrd do
    url   = swizzle
    tries = 0
    begin
      tries += 1
      http = EM::HttpRequest.new(url).get
      http.callback {
        raise Redfinger::ResourceNotFound if http.response_header.status == 404
        yield Finger.new self., http.response
      }
    rescue Redfinger::ResourceNotFound
      url = swizzle()
      retry if tries < 2
      raise Redfinger::ResourceNotFound
    end
  end
end

#xrd_url(ssl = true) ⇒ Object



36
37
38
# File 'lib/em-redfinger/client.rb', line 36

def xrd_url(ssl = true)
  "http#{ 's' if ssl }://#{ domain }/.well-known/host-meta"
end