Class: JSONCop::Command::Uninstall

Inherits:
JSONCop::Command show all
Defined in:
lib/jsoncop/command/uninstall.rb

Instance Method Summary collapse

Methods inherited from JSONCop::Command

options, run

Constructor Details

#initialize(argv) ⇒ Uninstall

Returns a new instance of Uninstall.



8
9
10
# File 'lib/jsoncop/command/uninstall.rb', line 8

def initialize(argv)
  super
end

Instance Method Details

#runObject



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

def run
  Dir.glob("**/*.swift").each do |file_path|
    jsoncop_generate_start = /jsoncop: generate\-start/
    jsoncop_generate_end = /jsoncop: generate\-end/
    content = File.read file_path
    if content.match(jsoncop_generate_start) && content.match(jsoncop_generate_end)
      content.gsub!(/\/\/ jsoncop: generate-start[^$]*jsoncop: generate\-end/, "")
    end
    File.write file_path, content
  end
end