5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/coderunner/heuristic_run_methods.rb', line 5
def run_heuristic_analysis
begin
puts Dir.pwd
raise CRMild.new("can't find input file") unless @rcp.input_file_extension
input_file = Dir.entries.find_all{|file| file =~ Regexp.new("^[^.].*"+Regexp.escape(rcp.input_file_extension) + "$")}[0]
raise CRMild.new("can't find input file") unless input_file
log(input_file)
input_file_text = File.read(input_file)
@run_name = File.basename(input_file, rcp.input_file_extension) if rcp.use_file_name_as_run_name
analyse_input_file_text(input_file_text)
log("Automatic analysis complete")
rescue CRMild => err
log(err)
input_file = Feedback.get_choice("Unable to find a code runner inputs file. If there is another input file please choose it from this list", Dir.entries(Dir.pwd).find_all{|file| not [".",".."].include? file and File.file? file} + ["not available"])
if input_file == "not available"
FileUtils.touch('.CODE_RUNNER_IGNORE_THIS_DIRECTORY')
raise CRError.new("run could be analysed, or folder does not contain a run")
end
input_file_text = File.read(input_file)
log(input_file_text)
analyse_input_file_text(input_file_text)
rcp.input_file_extension = File.extname(input_file)
@rcp.use_file_name_as_run_name = Feedback.get_boolean("Do you want to use the input file name (minus the extension) as a run name? (Your answer will apply to all directories with code runner inputs files).") if rcp.use_file_name_as_run_name.class == NilClass
@run_name = File.basename(input_file, rcp.input_file_extension) if rcp.use_file_name_as_run_name
end
end
|