Sha256: 6dd4c9ed793a4902554ff5202e2936e9cb76ba4da5978ec93729d98a3996f6a3

Contents?: true

Size: 919 Bytes

Versions: 20

Compression:

Stored size: 919 Bytes

Contents

module Diffy
  module Format
    # ANSI color output suitable for terminal output
    def color
      map do |line|
        case line          
        when /^(---|\+\+\+|\\\\)/
          "\033[90m#{line.chomp}\033[0m"
        when /^\+/
          "\033[32m#{line.chomp}\033[0m"
        when /^-/
          "\033[31m#{line.chomp}\033[0m"
        when /^@@/
          "\033[36m#{line.chomp}\033[0m"
        else
          line.chomp
        end
      end.join("\n") + "\n"
    end

    # Basic text output
    def text
      to_a.join
    end

    # Basic html output which does not attempt to highlight the changes
    # between lines, and is more performant.
    def html_simple
      HtmlFormatter.new(self, options).to_s
    end

    # Html output which does inline highlighting of changes between two lines.
    def html
      HtmlFormatter.new(self, options.merge(:highlight_words => true)).to_s
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
diffy-3.2.0 lib/diffy/format.rb
diffy-3.1.0 lib/diffy/format.rb
diffy-3.0.7 lib/diffy/format.rb
diffy-3.0.6 lib/diffy/format.rb
diffy-3.0.5 lib/diffy/format.rb
diffy-3.0.4 lib/diffy/format.rb
diffy-3.0.3 lib/diffy/format.rb
diffy-3.0.2 lib/diffy/format.rb
diffy-3.0.1 lib/diffy/format.rb
diffy-3.0.0 lib/diffy/format.rb
diffy-2.1.4 lib/diffy/format.rb
diffy-2.1.3 lib/diffy/format.rb
diffy-2.1.2 lib/diffy/format.rb
diffy-2.1.1 lib/diffy/format.rb
diffy-2.1.0 lib/diffy/format.rb
diffy-2.0.10 lib/diffy/format.rb
diffy-2.0.9 lib/diffy/format.rb
diffy-2.0.8 lib/diffy/format.rb
diffy-2.0.7 lib/diffy/format.rb
diffy-2.0.6 lib/diffy/format.rb