Class: ButterflyNet::FileWriter
- Inherits:
-
Object
- Object
- ButterflyNet::FileWriter
- Defined in:
- lib/butterfly_net/file_writer.rb
Instance Attribute Summary collapse
-
#end_index ⇒ Object
Returns the value of attribute end_index.
-
#start_index ⇒ Object
readonly
Returns the value of attribute start_index.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(file_name, start_index) ⇒ FileWriter
constructor
A new instance of FileWriter.
- #new_assertion_set ⇒ Object
Constructor Details
#initialize(file_name, start_index) ⇒ FileWriter
Returns a new instance of FileWriter.
7 8 9 10 |
# File 'lib/butterfly_net/file_writer.rb', line 7 def initialize(file_name, start_index) @file_name = file_name @start_index = start_index end |
Instance Attribute Details
#end_index ⇒ Object
Returns the value of attribute end_index.
4 5 6 |
# File 'lib/butterfly_net/file_writer.rb', line 4 def end_index @end_index end |
#start_index ⇒ Object (readonly)
Returns the value of attribute start_index.
5 6 7 |
# File 'lib/butterfly_net/file_writer.rb', line 5 def start_index @start_index end |
Instance Method Details
#close ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/butterfly_net/file_writer.rb', line 17 def close lines = Readline::HISTORY.to_a @end_index ||= Readline::HISTORY.size - 3 # in case of no call to 'bn_close' if @end_index < 0 || lines[@start_index..@end_index].empty? puts "butterfly_net: #{@file_name} closed, no file written to disk" false else adapter = TestUnitAdapter.new lines[@start_index..@end_index].each do |line| adapter.add_command(line) end adapter.create_file(@file_name) puts "butterfly_net: #{@file_name} closed after Readline::HISTORY ##{@end_index}" true end rescue Exception => msg puts "butterfly_net: Error generating tests: #{msg}" false end |
#new_assertion_set ⇒ Object
12 13 14 |
# File 'lib/butterfly_net/file_writer.rb', line 12 def new_assertion_set end |