Class: LookbookVisualTester::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lookbook_visual_tester/configuration.rb

Constant Summary collapse

DEFAULT_THREADS =
4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/lookbook_visual_tester/configuration.rb', line 12

def initialize
  root_path = if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
                Rails.root
              else
                Pathname.new(Dir.pwd)
              end
  @base_path = root_path.join('coverage/screenshots')
  @baseline_dir = @base_path.join('baseline')
  @current_dir = @base_path.join('current_run')
  @diff_dir = @base_path.join('diff')
  @history_dir = @base_path.join('history')
  @threads = ENV.fetch('LOOKBOOK_THREADS', DEFAULT_THREADS).to_i
  @history_keep_last_n = 5
  @copy_to_clipboard = false
  @components_folder = 'app/components'
  @automatic_run = ENV.fetch('LOOKBOOK_AUTOMATIC_RUN', 'false') == 'true'
  @mask_selectors = []
  @driver_adapter = :ferrum
  @preview_checker_setup = nil
  @wait_time = 0.5
  @tolerance = 0.0
  @logger = if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
              Rails.logger
            else
              require 'logger'
              Logger.new($stdout).tap { |l| l.level = Logger::INFO }
            end

  @lookbook_host = ENV.fetch('LOOKBOOK_HOST', 'http://localhost:5000')
  # Browser (Ferrum/Chrome) configuration. Defaults target modern Chrome's
  # `--headless=new` mode; the old `--headless` flag is rejected by current
  # Chrome builds ("Multiple targets are not supported in headless mode").
  @browser_path = ENV['LOOKBOOK_BROWSER_PATH'] || LookbookVisualTester::BrowserDiscovery.find_binary
  @browser_options = { 'headless' => 'new' }
  @browser_timeout = ENV.fetch('LOOKBOOK_BROWSER_TIMEOUT', '10').to_i
  @process_timeout = ENV.fetch('LOOKBOOK_PROCESS_TIMEOUT', '10').to_i
end

Instance Attribute Details

#automatic_runObject

Returns the value of attribute automatic_run.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def automatic_run
  @automatic_run
end

#base_pathObject

Returns the value of attribute base_path.



3
4
5
# File 'lib/lookbook_visual_tester/configuration.rb', line 3

def base_path
  @base_path
end

#baseline_dirObject

Returns the value of attribute baseline_dir.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def baseline_dir
  @baseline_dir
end

#browser_optionsObject

Returns the value of attribute browser_options.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def browser_options
  @browser_options
end

#browser_pathObject

Returns the value of attribute browser_path.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def browser_path
  @browser_path
end

#browser_timeoutObject

Returns the value of attribute browser_timeout.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def browser_timeout
  @browser_timeout
end

#components_folderObject

Returns the value of attribute components_folder.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def components_folder
  @components_folder
end

#copy_to_clipboardObject

Returns the value of attribute copy_to_clipboard.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def copy_to_clipboard
  @copy_to_clipboard
end

#current_dirObject

Returns the value of attribute current_dir.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def current_dir
  @current_dir
end

#diff_dirObject

Returns the value of attribute diff_dir.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def diff_dir
  @diff_dir
end

#driver_adapterObject

Returns the value of attribute driver_adapter.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def driver_adapter
  @driver_adapter
end

#history_dirObject

Returns the value of attribute history_dir.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def history_dir
  @history_dir
end

#history_keep_last_nObject

Returns the value of attribute history_keep_last_n.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def history_keep_last_n
  @history_keep_last_n
end

#loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def logger
  @logger
end

#lookbook_hostObject

Returns the value of attribute lookbook_host.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def lookbook_host
  @lookbook_host
end

#mask_selectorsObject

Returns the value of attribute mask_selectors.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def mask_selectors
  @mask_selectors
end

#preview_checker_setupObject

Returns the value of attribute preview_checker_setup.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def preview_checker_setup
  @preview_checker_setup
end

#process_timeoutObject

Returns the value of attribute process_timeout.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def process_timeout
  @process_timeout
end

#threadsObject

Returns the value of attribute threads.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def threads
  @threads
end

#toleranceObject

Returns the value of attribute tolerance.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def tolerance
  @tolerance
end

#ui_comparisonObject

Returns the value of attribute ui_comparison.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def ui_comparison
  @ui_comparison
end

#wait_timeObject

Returns the value of attribute wait_time.



4
5
6
# File 'lib/lookbook_visual_tester/configuration.rb', line 4

def wait_time
  @wait_time
end

Class Method Details

.configObject



59
60
61
# File 'lib/lookbook_visual_tester/configuration.rb', line 59

def config
  @config ||= new
end

.configure {|config| ... } ⇒ Object

Yields:



63
64
65
# File 'lib/lookbook_visual_tester/configuration.rb', line 63

def configure
  yield(config)
end