class Koboldy::Conf

Attributes

config[R]

Public Class Methods

new() click to toggle source

see github.com/yahoo/blink-diff if you would like to know setting more.

# File lib/koboldy/conf.rb, line 12
def initialize
  @config = OpenStruct.new
end

Public Instance Methods

add_block_out(x, y, width, height) click to toggle source

@param [Integer] x Base x-coordinate @param [Integer] y Base y-coordinate @param [Integer] width Width of blockOut @param [Integer] height Height of blockOut @return [OpenStruct]

# File lib/koboldy/conf.rb, line 68
def add_block_out(x, y, width, height)
  param = OpenStruct.new
  param.x = x.to_i
  param.y = y.to_i
  param.width = width.to_i
  param.height = height.to_i

  @config.blockOut = [] if @config.blockOut.nil?
  @config.blockOut.push param.to_h
  self
end
add_block_out_alpha(value) click to toggle source

@param [Integer] value Alpha intensity for the block-out in the output file (default: 255) @return [OpenStruct]

# File lib/koboldy/conf.rb, line 106
def add_block_out_alpha(value)
  @config.blockOutAlpha = value.to_i
  self
end
add_block_out_blue(value) click to toggle source

@param [Integer] value Blue intensity for the block-out in the output file (default: 0)

This color will only be visible in the result when debug-mode is turned on.

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 99
def add_block_out_blue(value)
  @config.blockOutBlue = color_value(value)
  self
end
add_block_out_debug(boolean) click to toggle source

@param [Boolean] boolean You can set true/false. Only for blockOut config @return [OpenStruct]

# File lib/koboldy/conf.rb, line 144
def add_block_out_debug(boolean)
  @config.debug = boolean
  self
end
add_block_out_green(value) click to toggle source

@param [Integer] value Green intensity for the block-out in the output file (default: 0)

This color will only be visible in the result when debug-mode is turned on.

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 91
def add_block_out_green(value)
  @config.blockOutGreen = color_value(value)
  self
end
add_block_out_opacity(value) click to toggle source

@param [Integer] value Opacity of the pixel for the block-out in the output file (default: 1.0) @return [OpenStruct]

# File lib/koboldy/conf.rb, line 113
def add_block_out_opacity(value)
  @config.blockOutOpacity = value.to_f
  self
end
add_block_out_red(value) click to toggle source

@param [Integer] value Red intensity for the block-out in the output file (default: 0)

This color will only be visible in the result when debug-mode is turned on.

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 83
def add_block_out_red(value)
  @config.blockOutRed = color_value(value)
  self
end
add_compose_left_to_right(boolean = true) click to toggle source

@param [Boolean] boolean Creates comparison-composition from left to right, otherwise it lets decide the app on what is best @return [OpenStruct]

# File lib/koboldy/conf.rb, line 158
def add_compose_left_to_right(boolean = true)
  @config.composeLeftToRight = boolean
  self
end
add_compose_top_to_bottom(boolean = true) click to toggle source

@param [Boolean] boolean Creates comparison-composition from top to bottom, otherwise it lets decide the app on what is best @return [OpenStruct]

# File lib/koboldy/conf.rb, line 165
def add_compose_top_to_bottom(boolean = true)
  @config.composeTopToBottom = boolean
  self
end
add_composition(boolean = true) click to toggle source

@param [Boolean] boolean Creates as output a composition of all three images (approved, highlight, and build) (default: true) @return [OpenStruct]

# File lib/koboldy/conf.rb, line 151
def add_composition(boolean = true)
  @config.composition = boolean
  self
end
add_copy_image_a_to_output(boolean = true) click to toggle source

@param [Integer] boolean Copies the first image to the output image before the comparison begins.

This will make sure that the output image will highlight the differences on the first image. (default)

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 121
def add_copy_image_a_to_output(boolean = true)
  @config.copyImageAToOutput = boolean
  self
end
add_copy_image_b_to_output(boolean = false) click to toggle source

@param [Integer] boolean Copies the second image to the output image before the comparison begins.

This will make sure that the output image will highlight the differences on the second image.

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 129
def add_copy_image_b_to_output(boolean = false)
  @config.copyImageBToOutput = boolean
  self
end
add_crop_image_a(x, y, width, height) click to toggle source

cropImageA Cropping for first image (default: no cropping) - Format: { x:, y:, width:, height: } @param [Integer] x Base x-coordinate @param [Integer] y Base y-coordinate @param [Integer] width Width of blockOut @param [Integer] height Height of blockOut @return [OpenStruct]

# File lib/koboldy/conf.rb, line 197
def add_crop_image_a(x, y, width, height)
  param = OpenStruct.new
  param.x = x.to_i
  param.y = y.to_i
  param.width = width.to_i
  param.height = height.to_i
  @config.cropImageA.push param.to_h
  self
end
add_crop_image_b(x, y, width, height) click to toggle source

cropImageB Cropping for second image (default: no cropping) - Format: { x:, y:, width:, height: } @param [Integer] x Base x-coordinate @param [Integer] y Base y-coordinate @param [Integer] width Width of blockOut @param [Integer] height Height of blockOut @return [OpenStruct]

# File lib/koboldy/conf.rb, line 213
def add_crop_image_b(x, y, width, height)
  param = OpenStruct.new
  param.x = x.to_i
  param.y = y.to_i
  param.width = width.to_i
  param.height = height.to_i
  @config.cropImageB.push param.to_h
  self
end
add_delta(value) click to toggle source

@param [Integer] value You can set value from 0 to 255 @return [OpenStruct]

# File lib/koboldy/conf.rb, line 261
def add_delta(value)
  @config.delta = value.to_i
  self
end
add_filter(filter_set) click to toggle source

@param [String] filter_set Filters that will be applied before the comparison.

Available filters are: blur, grayScale, lightness, luma, luminosity, sepia

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 137
def add_filter(filter_set)
  @config.filter = filter_set
  self
end
add_gamma(value) click to toggle source

@param [Float] value gamma Gamma correction for all colors (will be used as base) (default: none)

- Any value here will turn the perceptual comparison mode on

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 233
def add_gamma(value)
  @config.gamma = value.to_f
  self
end
add_gamma_b(value) click to toggle source

@param [Float] value gammaB Gamma correction for blue - Any value here will turn the perceptual comparison mode on @return [OpenStruct]

# File lib/koboldy/conf.rb, line 254
def add_gamma_b(value)
  @config.gammaB = value.to_f
  self
end
add_gamma_g(value) click to toggle source

@param [Float] value gammaG Gamma correction for green - Any value here will turn the perceptual comparison mode on @return [OpenStruct]

# File lib/koboldy/conf.rb, line 247
def add_gamma_g(value)
  @config.gammaG = value.to_f
  self
end
add_gamma_r(value) click to toggle source

@param [Float] value gammaR Gamma correction for red - Any value here will turn the perceptual comparison mode on @return [OpenStruct]

# File lib/koboldy/conf.rb, line 240
def add_gamma_r(value)
  @config.gammaR = value.to_f
  self
end
add_h_shift(value = 2) click to toggle source

@param [Integer] value hShift Horizontal shift for possible antialiasing (default: 2) Set to 0 to turn this off. @return [OpenStruct]

# File lib/koboldy/conf.rb, line 172
def add_h_shift(value = 2)
  @config.hShift = value.to_i
  self
end
add_hide_shift(boolean) click to toggle source

@param [Boolean] boolean You can set true/false @return [OpenStruct]

# File lib/koboldy/conf.rb, line 186
def add_hide_shift(boolean)
  @config.hideShift = boolean
  self
end
add_image_a_path(path) click to toggle source

@param [String] path Defines the path to the second image that should be compared @return [OpenStruct]

# File lib/koboldy/conf.rb, line 18
def add_image_a_path(path)
  @config.imageAPath = path
  self
end
add_image_b_path(path) click to toggle source

@param [String] path Defines the path to the first image that should be compared @return [OpenStruct]

# File lib/koboldy/conf.rb, line 25
def add_image_b_path(path)
  @config.imageBPath = path
  self
end
add_image_output_limit(difference) click to toggle source

@param [String] difference imageOutputLimit Defines when an image output should be created.

This can be for different images("different"),
similar or different images("similar"),
or all comparisons. (default: all)

@return [OpenStruct]

# File lib/koboldy/conf.rb, line 42
def add_image_output_limit(difference)
  @config.imageOutputLimit = begin
    case difference
    when "different"
      "BlinkDiff.OUTPUT_DIFFERENT"
    when "similar"
      "BlinkDiff.OUTPUT_SIMILAR"
    else
      "BlinkDiff.OUTPUT_ALL"
    end
  end
  self
end
add_image_output_path(path) click to toggle source

@param [String] path imageOutputPath Defines the path to the output-file. If you leaves this one off, then this feature is turned-off. @return [OpenStruct]

# File lib/koboldy/conf.rb, line 32
def add_image_output_path(path)
  @config.imageOutputPath = path
  self
end
add_perceptual(boolean = true) click to toggle source

@param [Boolean] boolean Turn the perceptual comparison mode on. See below for more information. @return [OpenStruct]

# File lib/koboldy/conf.rb, line 225
def add_perceptual(boolean = true)
  @config.perceptual = boolean
  self
end
add_v_shift(value = 2) click to toggle source

@param [Integer] value vShift Vertical shift for possible antialiasing (default: 2) Set to 0 to turn this off. @return [OpenStruct]

# File lib/koboldy/conf.rb, line 179
def add_v_shift(value = 2)
  @config.vShift = value.to_i
  self
end
add_verbose(boolean = false) click to toggle source

@param [Boolean] boolean Verbose output (default: false) @return [OpenStruct]

# File lib/koboldy/conf.rb, line 58
def add_verbose(boolean = false)
  @config.verbose = boolean
  self
end
clear_config() click to toggle source

clear @config instance.

# File lib/koboldy/conf.rb, line 273
def clear_config
  @config = OpenStruct.new
  self
end
generate_into(file_path) click to toggle source
# File lib/koboldy/conf.rb, line 266
def generate_into(file_path)
  File.open(file_path, "w") do |file|
    file.puts JSON.pretty_generate(@config.to_h)
  end
end

Private Instance Methods

color_value(value) click to toggle source
# File lib/koboldy/conf.rb, line 280
def color_value(value)
  if value.to_i < 0
    0
  elsif value.to_i > 255
    255
  else
    value.to_i
  end
end