Sha256: ad57c863081e38568af794f13b90b7e1ee4f83f2341009f3e2a5ce6c2a55c94c

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

# frozen_string_literal: true

module Acclir
  module Command
    # Generate files for the contest
    class New < Thor::Group
      include Thor::Actions

      BASE_NAME = "main"

      argument :contest_id

      attr_accessor :contest, :config

      def self.source_root
        File.dirname(__FILE__)
      end

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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acclir-0.2.0 lib/acclir/command/new.rb
acclir-0.1.0 lib/acclir/command/new.rb