Module: Repol::Utils::Helper

Included in:
Client, DSL::Converter, Driver, Exporter
Defined in:
lib/repol/utils.rb

Instance Method Summary collapse

Instance Method Details

#diff(obj1, obj2, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/repol/utils.rb', line 11

def diff(obj1, obj2, options = {})
  diffy = Diffy::Diff.new(
    obj1.pretty_inspect,
    obj2.pretty_inspect,
    :diff => '-u'
  )

  out = diffy.to_s(options[:color] ? :color : :text).gsub(/\s+\z/m, '')
  out.gsub!(/^/, options[:indent]) if options[:indent]
  out
end

#matched?(name) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
# File 'lib/repol/utils.rb', line 3

def matched?(name)
  if @options[:target]
    @options[:target] =~ name
  else
    true
  end
end