Module: HwCheker::HomeWorkChecker::TestRun

Included in:
RubyTestRun
Defined in:
lib/hw_cheker/test_run.rb,
lib/hw_cheker/ruby_test_run.rb,
lib/hw_cheker/python_test_run.rb

Defined Under Namespace

Classes: PythonTestRun, RubyTestRun

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detect_language(path) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/hw_cheker/test_run.rb', line 4

def self.detect_language(path)
  raise "Subdirectory 'test' don't exist in folder #{path}" unless Dir::exist?("#{path}/test")
  Dir::foreach("#{path}/test") do |p|
    if File::file?("#{path}/test/#{p}") && LANGUAGE_TYPES.include?(File::extname p)
      return File::extname p
    end
  end
  raise "Any .rb/.py file doesn't exist"
end

Instance Method Details

#generate_xml(path, hash) ⇒ Object



14
15
16
17
18
# File 'lib/hw_cheker/test_run.rb', line 14

def generate_xml(path, hash)
  File.open("#{path}.xml", 'w') do |file| 
    file.write hash.to_xml
  end
end