Module: CodewarsCli::GenericHelpers

Included in:
Configuration, Deferred, FileCreator, Finalize, Kata, Presenter, SubmitKata, User
Defined in:
lib/codewars_cli/generic_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/codewars_cli/generic_helpers.rb', line 4

def self.included(base)
  base.extend(self)
end

Instance Method Details

#check_for_api_keyObject



8
9
10
# File 'lib/codewars_cli/generic_helpers.rb', line 8

def check_for_api_key
  fail Thor::Error ,"ERROR: You must config the api_key\nSOLUTION: Set up with `config api_key KEY`" if Configuration.api_key.empty?
end

#clientObject



12
13
14
# File 'lib/codewars_cli/generic_helpers.rb', line 12

def client
  @client ||= Client.connection
end

#error(msg) ⇒ Object



25
26
27
# File 'lib/codewars_cli/generic_helpers.rb', line 25

def error(msg)
  presenter.error(msg)
end

#extend_object(object) ⇒ Object



16
17
18
19
# File 'lib/codewars_cli/generic_helpers.rb', line 16

def extend_object(object)
  object.extend(Concerns::AttributesMethods)
  object
end

#info(msg, color = :green) ⇒ Object



21
22
23
# File 'lib/codewars_cli/generic_helpers.rb', line 21

def info(msg, color=:green)
  presenter.info(msg, color)
end

#presenterObject



29
30
31
# File 'lib/codewars_cli/generic_helpers.rb', line 29

def presenter
  @presenter ||= Presenter.new
end