Sha256: cff606d9ff10d86da7298d58cb109a1ef5d181bb8c931a3c80c10f9065fb947b

Contents?: true

Size: 909 Bytes

Versions: 9

Compression:

Stored size: 909 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

9 entries across 9 versions & 3 rubygems

Version Path
diffy-3.4.3 lib/diffy/format.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/diffy-3.4.2/lib/diffy/format.rb
ydiffy-0.0.3 lib/diffy/format.rb
diffy-3.4.2 lib/diffy/format.rb
diffy-3.4.1 lib/diffy/format.rb
diffy-3.4.0 lib/diffy/format.rb
diffy-3.3.0 lib/diffy/format.rb
diffy-3.2.1 lib/diffy/format.rb
ydiffy-0.0.2 lib/diffy/format.rb