Class: DotDiff::CommandWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dotdiff/command_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/dotdiff/command_wrapper.rb', line 5

def message
  @message
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/dotdiff/command_wrapper.rb', line 31

def failed?
  @ran_checks && @failed
end

#passed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/dotdiff/command_wrapper.rb', line 27

def passed?
  !failed?
end

#ran_checksObject



35
36
37
# File 'lib/dotdiff/command_wrapper.rb', line 35

def ran_checks
  @ran_checks
end

#run(base_image, new_image, diff_image_path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dotdiff/command_wrapper.rb', line 7

def run(base_image, new_image, diff_image_path)
  output = run_command(base_image, new_image, diff_image_path)

  @ran_checks = true

  begin
    pixels = Float(output)

    if pixels && pixels <= DotDiff.pixel_threshold
      @failed = false
    else
      @failed = true
      @message = "Images are #{pixels} pixels different"
    end
  rescue ArgumentError => e
    @failed = true
    @message = output
  end
end