Class: BeLetItBe::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/be_let_it_be/converter.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Converter

Returns a new instance of Converter.



8
9
10
# File 'lib/be_let_it_be/converter.rb', line 8

def initialize(file)
  @file = file.respond_to?(:path) ? file.path : file
end

Instance Method Details

#try_conversion_single_let(let_info, output_file, exam) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/be_let_it_be/converter.rb', line 12

def try_conversion_single_let(let_info, output_file, exam)
  source = File.read(@file)

  File.write(output_file, apply_single_conversion(let_info, source))

  passed = exam.call
  unless passed
    File.write(output_file, source) # revert changes
  end
  passed
end