Sha256: b518d19b903bc97d4a8a53758af6e78db57c7d66a477da25be6148d4b885592a

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

require 'json'
require 'diffy'
require 'coderay'

module Rezept
  class Utils

    def self.diff(converter, hash1, hash2, color=false)
      diff = Diffy::Diff.new(
        converter.to_dsl(hash1),
        converter.to_dsl(hash2),
        :diff => '-u'
      )
      color ? diff.to_s(:color) : diff.to_s
    end

    def self.print_ruby(ruby, color=false)
      if color
        puts CodeRay.scan(ruby, :ruby).terminal
      else
        puts ruby
      end
    end

    def self.print_json(json, color=false)
      if color
        puts CodeRay.scan(json, :json).terminal
      else
        puts json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rezept-0.4.2 lib/rezept/utils.rb
rezept-0.4.1 lib/rezept/utils.rb