Class: Koboldy::Conf

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/koboldy/conf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConf

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



12
13
14
# File 'lib/koboldy/conf.rb', line 12

def initialize
  @config = OpenStruct.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/koboldy/conf.rb', line 9

def config
  @config
end

Instance Method Details

#add_block_out(x, y, width, height) ⇒ OpenStruct

Parameters:

  • x (Integer)

    Base x-coordinate

  • y (Integer)

    Base y-coordinate

  • width (Integer)

    Width of blockOut

  • height (Integer)

    Height of blockOut

Returns:

  • (OpenStruct)


68
69
70
71
72
73
74
75
76
77
78
# 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) ⇒ OpenStruct

Parameters:

  • value (Integer)

    Alpha intensity for the block-out in the output file (default: 255)

Returns:

  • (OpenStruct)


106
107
108
109
# 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) ⇒ OpenStruct

Parameters:

  • value (Integer)

    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.

Returns:

  • (OpenStruct)


99
100
101
102
# 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) ⇒ OpenStruct

Parameters:

  • boolean (Boolean)

    You can set true/false. Only for blockOut config

Returns:

  • (OpenStruct)


144
145
146
147
# File 'lib/koboldy/conf.rb', line 144

def add_block_out_debug(boolean)
  @config.debug = boolean
  self
end

#add_block_out_green(value) ⇒ OpenStruct

Parameters:

  • value (Integer)

    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.

Returns:

  • (OpenStruct)


91
92
93
94
# 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) ⇒ OpenStruct

Parameters:

  • value (Integer)

    Opacity of the pixel for the block-out in the output file (default: 1.0)

Returns:

  • (OpenStruct)


113
114
115
116
# 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) ⇒ OpenStruct

Parameters:

  • value (Integer)

    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.

Returns:

  • (OpenStruct)


83
84
85
86
# 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) ⇒ OpenStruct

Parameters:

  • boolean (Boolean) (defaults to: true)

    Creates comparison-composition from left to right, otherwise it lets decide the app on what is best

Returns:

  • (OpenStruct)


158
159
160
161
# 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) ⇒ OpenStruct

Parameters:

  • boolean (Boolean) (defaults to: true)

    Creates comparison-composition from top to bottom, otherwise it lets decide the app on what is best

Returns:

  • (OpenStruct)


165
166
167
168
# File 'lib/koboldy/conf.rb', line 165

def add_compose_top_to_bottom(boolean = true)
  @config.composeTopToBottom = boolean
  self
end

#add_composition(boolean = true) ⇒ OpenStruct

Parameters:

  • boolean (Boolean) (defaults to: true)

    Creates as output a composition of all three images (approved, highlight, and build) (default: true)

Returns:

  • (OpenStruct)


151
152
153
154
# 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) ⇒ OpenStruct

Parameters:

  • boolean (Integer) (defaults to: true)

    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)

Returns:

  • (OpenStruct)


121
122
123
124
# 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) ⇒ OpenStruct

Parameters:

  • boolean (Integer) (defaults to: false)

    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.

Returns:

  • (OpenStruct)


129
130
131
132
# 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) ⇒ OpenStruct

cropImageA Cropping for first image (default: no cropping) - Format: { x:, y:, width:, height: }

Parameters:

  • x (Integer)

    Base x-coordinate

  • y (Integer)

    Base y-coordinate

  • width (Integer)

    Width of blockOut

  • height (Integer)

    Height of blockOut

Returns:

  • (OpenStruct)


197
198
199
200
201
202
203
204
205
# 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) ⇒ OpenStruct

cropImageB Cropping for second image (default: no cropping) - Format: { x:, y:, width:, height: }

Parameters:

  • x (Integer)

    Base x-coordinate

  • y (Integer)

    Base y-coordinate

  • width (Integer)

    Width of blockOut

  • height (Integer)

    Height of blockOut

Returns:

  • (OpenStruct)


213
214
215
216
217
218
219
220
221
# 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) ⇒ OpenStruct

Parameters:

  • value (Integer)

    You can set value from 0 to 255

Returns:

  • (OpenStruct)


261
262
263
264
# File 'lib/koboldy/conf.rb', line 261

def add_delta(value)
  @config.delta = value.to_i
  self
end

#add_filter(filter_set) ⇒ OpenStruct

Parameters:

  • filter_set (String)

    Filters that will be applied before the comparison. Available filters are: blur, grayScale, lightness, luma, luminosity, sepia

Returns:

  • (OpenStruct)


137
138
139
140
# File 'lib/koboldy/conf.rb', line 137

def add_filter(filter_set)
  @config.filter = filter_set
  self
end

#add_gamma(value) ⇒ OpenStruct

Parameters:

  • value (Float)

    gamma Gamma correction for all colors (will be used as base) (default: none)

    • Any value here will turn the perceptual comparison mode on

Returns:

  • (OpenStruct)


233
234
235
236
# File 'lib/koboldy/conf.rb', line 233

def add_gamma(value)
  @config.gamma = value.to_f
  self
end

#add_gamma_b(value) ⇒ OpenStruct

Parameters:

  • value (Float)

    gammaB Gamma correction for blue - Any value here will turn the perceptual comparison mode on

Returns:

  • (OpenStruct)


254
255
256
257
# File 'lib/koboldy/conf.rb', line 254

def add_gamma_b(value)
  @config.gammaB = value.to_f
  self
end

#add_gamma_g(value) ⇒ OpenStruct

Parameters:

  • value (Float)

    gammaG Gamma correction for green - Any value here will turn the perceptual comparison mode on

Returns:

  • (OpenStruct)


247
248
249
250
# File 'lib/koboldy/conf.rb', line 247

def add_gamma_g(value)
  @config.gammaG = value.to_f
  self
end

#add_gamma_r(value) ⇒ OpenStruct

Parameters:

  • value (Float)

    gammaR Gamma correction for red - Any value here will turn the perceptual comparison mode on

Returns:

  • (OpenStruct)


240
241
242
243
# File 'lib/koboldy/conf.rb', line 240

def add_gamma_r(value)
  @config.gammaR = value.to_f
  self
end

#add_h_shift(value = 2) ⇒ OpenStruct

Parameters:

  • value (Integer) (defaults to: 2)

    hShift Horizontal shift for possible antialiasing (default: 2) Set to 0 to turn this off.

Returns:

  • (OpenStruct)


172
173
174
175
# File 'lib/koboldy/conf.rb', line 172

def add_h_shift(value = 2)
  @config.hShift = value.to_i
  self
end

#add_hide_shift(boolean) ⇒ OpenStruct

Parameters:

  • boolean (Boolean)

    You can set true/false

Returns:

  • (OpenStruct)


186
187
188
189
# File 'lib/koboldy/conf.rb', line 186

def add_hide_shift(boolean)
  @config.hideShift = boolean
  self
end

#add_image_a_path(path) ⇒ OpenStruct

Parameters:

  • path (String)

    Defines the path to the second image that should be compared

Returns:

  • (OpenStruct)


18
19
20
21
# File 'lib/koboldy/conf.rb', line 18

def add_image_a_path(path)
  @config.imageAPath = path
  self
end

#add_image_b_path(path) ⇒ OpenStruct

Parameters:

  • path (String)

    Defines the path to the first image that should be compared

Returns:

  • (OpenStruct)


25
26
27
28
# File 'lib/koboldy/conf.rb', line 25

def add_image_b_path(path)
  @config.imageBPath = path
  self
end

#add_image_output_limit(difference) ⇒ OpenStruct

Parameters:

  • difference (String)

    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)

Returns:

  • (OpenStruct)


42
43
44
45
46
47
48
49
50
51
52
53
54
# 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) ⇒ OpenStruct

Parameters:

  • path (String)

    imageOutputPath Defines the path to the output-file. If you leaves this one off, then this feature is turned-off.

Returns:

  • (OpenStruct)


32
33
34
35
# File 'lib/koboldy/conf.rb', line 32

def add_image_output_path(path)
  @config.imageOutputPath = path
  self
end

#add_perceptual(boolean = true) ⇒ OpenStruct

Parameters:

  • boolean (Boolean) (defaults to: true)

    Turn the perceptual comparison mode on. See below for more information.

Returns:

  • (OpenStruct)


225
226
227
228
# File 'lib/koboldy/conf.rb', line 225

def add_perceptual(boolean = true)
  @config.perceptual = boolean
  self
end

#add_v_shift(value = 2) ⇒ OpenStruct

Parameters:

  • value (Integer) (defaults to: 2)

    vShift Vertical shift for possible antialiasing (default: 2) Set to 0 to turn this off.

Returns:

  • (OpenStruct)


179
180
181
182
# File 'lib/koboldy/conf.rb', line 179

def add_v_shift(value = 2)
  @config.vShift = value.to_i
  self
end

#add_verbose(boolean = false) ⇒ OpenStruct

Parameters:

  • boolean (Boolean) (defaults to: false)

    Verbose output (default: false)

Returns:

  • (OpenStruct)


58
59
60
61
# File 'lib/koboldy/conf.rb', line 58

def add_verbose(boolean = false)
  @config.verbose = boolean
  self
end

#clear_configObject

clear @config instance.



273
274
275
276
# File 'lib/koboldy/conf.rb', line 273

def clear_config
  @config = OpenStruct.new
  self
end

#generate_into(file_path) ⇒ Object



266
267
268
269
270
# 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