Sha256: c83ca238dbef9ee72ae04f10dc184ba1f4997731a95f7528766b60db0e50543c

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 Bytes

Contents

module Differ
  module Format
    module Patch
      class << self
        def format(change)
          (change.change? && as_change(change)) ||
          (change.delete? && as_delete(change)) ||
          (change.insert? && as_insert(change)) ||
          ''
        end

      private

        def as_insert(change)
          "\033[32m+ #{change.insert}\033[0m"
        end

        def as_delete(change)
          "\033[31m- #{change.delete}\033[0m"
        end

        def as_change(change)
          [as_delete(change), as_insert(change)].join("\n")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ninja-differ-1.0.0 lib/differ/format/patch.rb