Class: Acclir::Command::New

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/acclir/command/new.rb

Overview

Generate files for the contest

Constant Summary collapse

BASE_NAME =
"main"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



13
14
15
# File 'lib/acclir/command/new.rb', line 13

def config
  @config
end

#contestObject

Returns the value of attribute contest.



13
14
15
# File 'lib/acclir/command/new.rb', line 13

def contest
  @contest
end

Class Method Details

.source_rootObject



15
16
17
# File 'lib/acclir/command/new.rb', line 15

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#create_contest_filesObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/acclir/command/new.rb', line 23

def create_contest_files
  contest.tasks.each do |task|
    dir = "#{contest.id}/#{task.id}/"
    file_path = "./#{dir}/#{BASE_NAME}.rb"
    test_file_path = "./#{dir}/#{BASE_NAME}_test.rb"

    create_file file_path

    template(
      "../templates/new/#{BASE_NAME}_test.rb.tt", test_file_path,
      { file_path: file_path, task: task }
    )
  end
end

#prepareObject



19
20
21
# File 'lib/acclir/command/new.rb', line 19

def prepare
  self.contest = AtCoder::Contest.new(contest_id)
end