Class: CheatingDetection
- Inherits:
-
Object
- Object
- CheatingDetection
- Defined in:
- lib/cheating_detection.rb
Constant Summary collapse
- MOSS_LOGGER_CALLBACK =
->(=""){puts }
- TEMP_DIR =
'brown_noser_cheat_detection'
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(user, repo, moss_options = {}) ⇒ CheatingDetection
constructor
A new instance of CheatingDetection.
Constructor Details
#initialize(user, repo, moss_options = {}) ⇒ CheatingDetection
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cheating_detection.rb', line 9 def initialize(user, repo, ={}) @user = user @repo = repo @moss_id = .fetch(:moss_id, 000000000) # Create the MossRuby object @moss ||= MossRuby.new(@moss_id) #replace 000000000 with your user id # Set options -- the options will already have these default values @moss.[:max_matches] = .fetch(:max_matches, 10) @moss.[:directory_submission] = .fetch(:directory_submission, false) @moss.[:show_num_matches] = .fetch(:show_num_matches, 250) @moss.[:experimental_server] = .fetch(:experimental_server, false) @moss.[:comment] = .fetch(:comment, '') @moss.[:language] = .fetch(:comment, 'cc') end |
Instance Method Details
#detect ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cheating_detection.rb', line 26 def detect pull_details = PullBranchLister.new(@user, @repo).list extractor = PullBranchFileExtractor.new(TEMP_DIR, pull_details) extractor.extract # Create a file hash, with the files to be processed to_check = MossRuby.empty_file_hash files_to_check = Dir.glob("#{TEMP_DIR}/**/*").select { |f| f =~ /\.(h|cpp)$/ } MossRuby.add_file(to_check, files_to_check) # Get server to process files url = @moss.check to_check, MOSS_LOGGER_CALLBACK IO.write "brown_noser.html", "<div><h3>Cheat Detection Results</h3><br/><a href='#{url}'>#{url}</a></div>" extractor.cleanup # Get results results = @moss.extract_results url end |