class Taeval::Plagium::Runner

Public Class Methods

new(config, output, reporter) click to toggle source
# File lib/taeval/plagium/runner.rb, line 9
def initialize(config, output, reporter)
  @config   = Config.new(config)
  @output   = output
  @reporter = reporter
end

Public Instance Methods

run() click to toggle source
# File lib/taeval/plagium/runner.rb, line 15
def run
  moss = MossRuby.new(@config.id)

  # Set options  -- the options will already have these default values
  moss.options[:max_matches]          = @config.max_matches 
  moss.options[:show_num_matches]     = @config.show_num_matches
  moss.options[:comment]              = @config.comment
  moss.options[:language]             = @config.language

  @output.print "checking similarity"
  to_check = MossRuby.empty_file_hash

  solutions = Dir.glob("#{@config.solutions}/**/*.#{@config.language}")
                 .reject { |file| @config.reject.any? { |pattern| file.include?(pattern) } }

  solutions.each do |file|
    MossRuby.add_file(to_check, file)
  end

  # Get server to process files
  url = moss.check(to_check)
  @output.print "url: #{url}"

  @config.output.puts(@config.comment)
  @config.output.puts(url)
end