Module: FeatureGateCleaner

Defined in:
lib/feature_gate_cleaner.rb

Class Method Summary collapse

Class Method Details

.clean(gate_name) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/feature_gate_cleaner.rb', line 2

def self.clean(gate_name)
  matching_string = "(FeatureGate::Manager.gate(\s|\\()[\\\"\\']#{gate_name}[\\\"\\'])|(<%\s*end\s*#\s*#{gate_name}\s*%>)"

  `grep -r -l -E "#{matching_string}" #{Dir.pwd}/app/views/ | while IFS= read -r file; do grep -v -E "#{matching_string}" "$file" > "$file".cleaned; mv "$file"{.cleaned,}; done`

  matching_string = "FeatureGate::Manager.gate_page(\s|\\()[\\\"\\']#{gate_name}[\\\"\\']"

  `grep -r -l -E "#{matching_string}" #{Dir.pwd}/app/controllers/ | while IFS= read -r file; do grep -v -E "#{matching_string}" "$file" > "$file".cleaned; mv "$file"{.cleaned,}; done`

  puts "#{gate_name} cleaned!"
end