Class: SeeingIsBelieving::EvaluateByMovingFiles
- Inherits:
-
Object
- Object
- SeeingIsBelieving::EvaluateByMovingFiles
- Defined in:
- lib/seeing_is_believing/evaluate_by_moving_files.rb
Instance Attribute Summary collapse
-
#error_stream ⇒ Object
Returns the value of attribute error_stream.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#input_stream ⇒ Object
Returns the value of attribute input_stream.
-
#matrix_filename ⇒ Object
Returns the value of attribute matrix_filename.
-
#program ⇒ Object
Returns the value of attribute program.
Instance Method Summary collapse
- #call ⇒ Object
- #file_directory ⇒ Object
-
#initialize(program, filename, options = {}) ⇒ EvaluateByMovingFiles
constructor
A new instance of EvaluateByMovingFiles.
- #temp_filename ⇒ Object
Constructor Details
#initialize(program, filename, options = {}) ⇒ EvaluateByMovingFiles
Returns a new instance of EvaluateByMovingFiles.
25 26 27 28 29 30 31 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 25 def initialize(program, filename, ={}) self.program = program self.filename = filename self.error_stream = .fetch :error_stream, $stderr # hmm, not really liking the global here self.input_stream = .fetch :input_stream, StringIO.new('') self.matrix_filename = [:matrix_filename] || 'seeing_is_believing/the_matrix' end |
Instance Attribute Details
#error_stream ⇒ Object
Returns the value of attribute error_stream.
23 24 25 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 23 def error_stream @error_stream end |
#filename ⇒ Object
Returns the value of attribute filename.
23 24 25 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 23 def filename @filename end |
#input_stream ⇒ Object
Returns the value of attribute input_stream.
23 24 25 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 23 def input_stream @input_stream end |
#matrix_filename ⇒ Object
Returns the value of attribute matrix_filename.
23 24 25 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 23 def matrix_filename @matrix_filename end |
#program ⇒ Object
Returns the value of attribute program.
23 24 25 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 23 def program @program end |
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 33 def call @result ||= HardCoreEnsure.call \ code: -> { dont_overwrite_existing_tempfile! move_file_to_tempfile write_program_to_file begin evaluate_file fail unless exitstatus.success? deserialize_result rescue Exception record_error raise $! end }, ensure: -> { restore_backup } end |
#file_directory ⇒ Object
53 54 55 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 53 def file_directory File.dirname filename end |
#temp_filename ⇒ Object
57 58 59 |
# File 'lib/seeing_is_believing/evaluate_by_moving_files.rb', line 57 def temp_filename File.join file_directory, "seeing_is_believing_backup.#{File.basename filename}" end |