Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/rscm/line_editor.rb

Class Method Summary collapse

Class Method Details

.comment_out(path, line_regex, comment_template) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rscm/line_editor.rb', line 35

def File.comment_out(path, line_regex, comment_template)
  temp_file = Tempfile.new(File.basename(path))
  temp_file_path = temp_file.path
  original = File.new(path)
  RSCM::LineEditor.comment_out(original, line_regex, comment_template, temp_file)

  temp_file.close
  original.close

  File.copy(temp_file_path, path)
end