Class: Hexabat::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, params = {}) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
18
19
20
# File 'lib/hexabat/client.rb', line 12

def initialize(repository, params = {})
  @repository = repository
  @params = params
  @callbacks = {
    issue_retrieved:   ->(issue){},
    issue_count_known: ->(issue_count){},
    error: ->(repository, status, message) { STDERR.puts "#{repository} #{status} #{message}" }
  }
end

Instance Attribute Details

#callbacksObject (readonly)

Returns the value of attribute callbacks.



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

def callbacks
  @callbacks
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#repositoryObject (readonly)

Returns the value of attribute repository.



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

def repository
  @repository
end

Instance Method Details

#importObject



22
23
24
25
26
27
28
# File 'lib/hexabat/client.rb', line 22

def import
  if EM.reactor_running?
    start_importing
  else
    EM.run &method(:start_importing)
  end
end

#known_eventsObject



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

def known_events
  callbacks.keys
end

#on(event_callback) ⇒ Object



30
31
32
33
34
# File 'lib/hexabat/client.rb', line 30

def on(event_callback)
  event = event_callback.keys.first
  raise_unknown_event_error event unless known? event
  callbacks.merge! event_callback unless event_callback[event].nil?
end