lib/daddy/cucumber/diff.rb in daddy-0.1.18 vs lib/daddy/cucumber/diff.rb in daddy-0.1.20
- old
+ new
@@ -3,15 +3,29 @@
module Daddy
module Cucumber
module Diff
def git_diff(file, options = {})
- options[:as] ||= 'edit'
+ options[:as] = 'edit' unless options.has_key?(:as)
+ remote = options.has_key?(:remote) ? options[:remote] : true
git = Daddy::Git.new
- a = File.read(file).gsub(/[<>]/, '<' => '<', '>' => '>')
- b = git.show_previous(file, true).gsub(/[<>]/, '<' => '<', '>' => '>')
+
+ if options[:between]
+ a = git.show_previous(file, :commit => options[:between], :remote => remote)
+ else
+ a = File.read(file)
+ end
+ a = a.gsub(/[<>]/, '<' => '<', '>' => '>')
+
+ if options[:and]
+ b = git.show_previous(file, :commit => options[:and], :remote => remote)
+ else
+ b = git.show_previous(file, :remote => remote)
+ end
+ b = b.gsub(/[<>]/, '<' => '<', '>' => '>')
+
diff = format_diff(Differ.diff(a, b), options)
show_filename(file, options)
puts "<pre>#{diff}</pre>"
end
@@ -20,11 +34,11 @@
git = Daddy::Git.new
puts '<pre>' + git.git_diff_name(*includes) + '</pre>'
end
def diff(file_a, file_b, options = {})
- a = File.read(file_a)
- b = File.read(file_b)
+ a = File.read(file_a).gsub(/[<>]/, '<' => '<', '>' => '>')
+ b = File.read(file_b).gsub(/[<>]/, '<' => '<', '>' => '>')
diff = format_diff(Differ.diff(a, b))
show_filename(file_a, options)
puts "<pre>#{diff}</pre>"
end