Class: Terrestrial::Cli::Editor::BaseEditor

Inherits:
Object
  • Object
show all
Defined in:
lib/terrestrial/cli/editor/base_editor.rb

Direct Known Subclasses

AndroidXML, ObjC, Storyboard, Swift

Class Method Summary collapse

Class Method Details

.add_import(file) ⇒ Object



12
13
14
# File 'lib/terrestrial/cli/editor/base_editor.rb', line 12

def self.add_import(file)
  raise "Not implemented"
end

.edit_file(path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/terrestrial/cli/editor/base_editor.rb', line 16

def self.edit_file(path)
  temp_file = Tempfile.new(File.basename(path))
  begin
    line_number = 1
    File.open(path, 'r') do |file|
      file.each_line do |line|
        yield line, line_number, temp_file
        line_number += 1
      end
    end
    temp_file.close
    FileUtils.mv(temp_file.path, path)
  ensure
    temp_file.close
    temp_file.unlink
  end
end

.find_and_edit_line(string_entry) ⇒ Object



8
9
10
# File 'lib/terrestrial/cli/editor/base_editor.rb', line 8

def self.find_and_edit_line(string_entry)
  raise "Not implemented"
end