Module: Acmaker::Utils::Helper

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

Instance Method Summary collapse

Instance Method Details

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



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

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)


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

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