lib/daddy/cucumber/diff.rb in daddy-0.0.21 vs lib/daddy/cucumber/diff.rb in daddy-0.0.22

- old
+ new

@@ -8,11 +8,11 @@ git = Daddy::Git.new a = File.read(file).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;') b = git.show_previous(file, true).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;') diff = format_diff(Differ.diff(a, b)) - puts file + show_filename(file, options) puts "<pre>#{diff}</pre>" end def git_diff_name(*includes) git = Daddy::Git.new @@ -26,15 +26,23 @@ puts file_a puts "<pre>#{diff}</pre>" end - def show(file) - puts file + def show(file, options = {}) + show_filename(file, options) puts "<pre>#{File.read(file).gsub(/[<>]/, '<' => '&lt;', '>' => '&gt;')}</pre>" end private + + def show_filename(filename, options = {}) + if options[:as] == 'new' + puts "<span class=\"new\">[新規作成] #{filename}</span>" + else + puts filename + end + end def format_diff(diff) lines = [] diff_lines = diff.to_s.split("\n")