lib/drg/tasks/gemfile.rb in drg-0.5.0 vs lib/drg/tasks/gemfile.rb in drg-0.5.1
- old
+ new
@@ -15,10 +15,11 @@
lines[gem] = gem.update version
write
end
def remove_version(gem)
+ saved_lines << lines.clone!
lines[gem] = gem.remove_version
write
end
def find_by_name(name)
@@ -34,9 +35,19 @@
File.open file, 'wb' do |f|
lines.each do |line|
f << line
end
end
+ end
+
+ def rollback
+ return if saved_lines.empty?
+ lines.replace saved_lines.pop
+ write
+ end
+
+ def saved_lines
+ @saved_lines ||= []
end
def lines
@lines ||= File.readlines file
end