Class: Taeval::Plagium::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/taeval/plagium/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, output, reporter) ⇒ Runner

Returns a new instance of Runner.



9
10
11
12
13
# File 'lib/taeval/plagium/runner.rb', line 9

def initialize(config, output, reporter)
  @config   = Config.new(config)
  @output   = output
  @reporter = reporter
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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