Class: Jtest::Commands::New

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



16
17
18
# File 'lib/jtest/commands/new.rb', line 16

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#create_workspaceObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jtest/commands/new.rb', line 31

def create_workspace
  say_status :working, "Creating workspace for #{@problem.title}", :yellow

  empty_directory @problem.dirname

  @problem.samples.each_with_index do |sample, index|
    create_file "#{@problem.dirname}/sample#{index+1}.dat", sample[0]
    create_file "#{@problem.dirname}/sample#{index+1}.out", sample[1]
  end

  template "../templates/main.tt", "#{@problem.dirname}/main.cc"
  template "../templates/Makefile.tt", "#{@problem.dirname}/Makefile"
end

#get_problem_infoObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/jtest/commands/new.rb', line 20

def get_problem_info
  @problem = Problem.new(id, options)

  say_status :connecting, "Getting info about problem #{@problem.id}...", :yellow
  @problem.retrieve_info
  
  raise "Problem #{@problem.id} not found :(" unless @problem.exists?
  
  say_status :found, @problem.title, :green
end