Class: CodewarsCli::SubmitKata

Inherits:
Object
  • Object
show all
Includes:
FileParserHelpers, GenericHelpers
Defined in:
lib/codewars_cli/submit_kata.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FileParserHelpers

#_fetch_info, #_kata_path, #_parse_description_file

Methods included from GenericHelpers

#check_for_api_key, #client, #error, #extend_object, included, #info, #presenter

Constructor Details

#initialize(kata_name, language) ⇒ SubmitKata

Returns a new instance of SubmitKata.



17
18
19
20
# File 'lib/codewars_cli/submit_kata.rb', line 17

def initialize(kata_name, language)
  @kata_name = kata_name
  @language = language || Configuration.language
end

Instance Attribute Details

#kata_nameObject (readonly)

Returns the value of attribute kata_name.



15
16
17
# File 'lib/codewars_cli/submit_kata.rb', line 15

def kata_name
  @kata_name
end

#languageObject (readonly)

Returns the value of attribute language.



15
16
17
# File 'lib/codewars_cli/submit_kata.rb', line 15

def language
  @language
end

Class Method Details

.find(kata_name, language) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/codewars_cli/submit_kata.rb', line 5

def self.find(kata_name, language)
  check_for_api_key
  if kata_name
    new(kata_name, language)
  else
    error("ERROR: You must provide the name of the kata")
    exit(1)
  end
end

Instance Method Details

#upload_kataObject



22
23
24
25
26
# File 'lib/codewars_cli/submit_kata.rb', line 22

def upload_kata
  code = _get_kata_solution_code(kata_name, language)
  response = client.attemp_solution(kata: _parse_description_file(kata_name, language), code: code)
  Deferred.new(kata_name, language, response, client)
end