app/models/effective/code_writer.rb in effective_developer-0.6.2 vs app/models/effective/code_writer.rb in effective_developer-0.6.3

- old
+ new

@@ -226,25 +226,31 @@ def gsub!(source, target) lines.each { |line| @changed = true if line.gsub!(source, target) } end + def remove(from:, to:) + raise('expected from to be less than to') unless from.present? && to.present? && (from < to) + @changed = true + (to - from).times { lines.delete_at(from) } + end + def replace(index, content) @changed = true lines[index].replace(content.to_s) end - private - def write! return false unless changed? File.open(filename, 'w') do |file| lines.each { |line| file.write(line) } end true end + + private def open?(content) stripped = ss(content) ['class ', 'module ', 'def ', 'if '].any? { |start_with| stripped.start_with?(start_with) } ||