Class: Client

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

Defined Under Namespace

Classes: Base

Constant Summary collapse

VERSION =
'0.0.6'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



83
84
85
# File 'lib/client.rb', line 83

def logger
  @logger
end

Class Method Details

.clientsObject



89
90
91
# File 'lib/client.rb', line 89

def clients
  @clients ||= {}
end

.generate_clientsObject



109
110
111
112
113
114
115
116
117
# File 'lib/client.rb', line 109

def generate_clients
  clients.each do |name, info|
    Class.new(Base) do
      self.endpoint = info.fetch('endpoint')
    end.tap do |client_class|
      const_set(name.camelize, client_class)
    end
  end
end

.load_clients(path = "#{Dir.pwd}/client.yml") ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/client.rb', line 93

def load_clients(path = "#{Dir.pwd}/client.yml")
  begin
    clients.merge! YAML.load_file(path)
  rescue
    warn '''Check that you have an client.env file in your project with
  the following entry.
  gitlab:
    endpoint: http://gitlab.com/api/v3/
  other_server:
    endpoint: other_endpoint.com
    '''
    {}
  end
  generate_clients
end