Class: WatchDoge::Configuration

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

Defined Under Namespace

Classes: Hooks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/watchdoge/configuration.rb', line 53

def initialize
  # base_dir is where WatchDoge stuff operating include installation or configuration
  @base_dir =
    if defined? Rails
      Rails.root.to_s
    else
      Dir.pwd
    end

  # webdrivers binaries installation directory
  @web_drivers_dir = @base_dir + "/.webdrivers"


  # framwork that Worker used, default to selenium
  @engine = Watir::Browser

  # options for worker
  @default_worker_options = {
    # default window-size of worker
    width: 1280,
    height: 768,

    # using Firfox as default browser
    browser: :firefox,

    # default to headless
    headless: true,

    # connection timeout threshold(seconds)
    timeout: 120
  }

  @worker_options = {}

  # where all cookie saved (as yaml)
  @cookie_pool = @base_dir + '/.doge_cookie'

  # map of notification sources
  #   key: must be stringify of its class name
  #   value: hash struct, will passed to constructor while push message
  @notifications = {
    # slack_webhook: {
    #   incoming_url: SLACK_WEBHOOK
    # }

    # mattermost: {
    #   host: HOST,
    #   channel_id: CHANNEL_ID,
    #   auth_token: AUTH_TOKEN
    # }
  }

  # host for relative URL in regression test.
  @host = ''

  # regression directory contains reference images and scenario scripts
  @regression_dir =
    if defined?(Rails)
      @base_dir + "/test/watchdoge"
    else
      @base_dir + "/watchdoge"
    end

  @hooks = WatchDoge::Configuration::Hooks.new

  # Proc for #sign_in_as(resource) in regression scenario
  #   worker: WatchDoge instance that executing scnario
  #   resource: passed whatever you want
  @sign_in_proc = -> (worker, resource) {}
  @sign_out_proc = -> (worker, resource) {}

  # specific webdriver version, default to latest if nil
  @chrome_version = nil
  @firefox_version = nil
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir


31
32
33
# File 'lib/watchdoge/configuration.rb', line 31

def base_dir
  @base_dir
end

#chrome_versionObject

Returns the value of attribute chrome_version


50
51
52
# File 'lib/watchdoge/configuration.rb', line 50

def chrome_version
  @chrome_version
end

Returns the value of attribute cookie_pool


36
37
38
# File 'lib/watchdoge/configuration.rb', line 36

def cookie_pool
  @cookie_pool
end

#default_worker_optionsObject (readonly)

Returns the value of attribute default_worker_options


38
39
40
# File 'lib/watchdoge/configuration.rb', line 38

def default_worker_options
  @default_worker_options
end

#engineObject

Returns the value of attribute engine


35
36
37
# File 'lib/watchdoge/configuration.rb', line 35

def engine
  @engine
end

#firefox_versionObject

Returns the value of attribute firefox_version


51
52
53
# File 'lib/watchdoge/configuration.rb', line 51

def firefox_version
  @firefox_version
end

#hooksObject

Returns the value of attribute hooks


46
47
48
# File 'lib/watchdoge/configuration.rb', line 46

def hooks
  @hooks
end

#hostObject

Returns the value of attribute host


43
44
45
# File 'lib/watchdoge/configuration.rb', line 43

def host
  @host
end

#notificationsObject

Returns the value of attribute notifications


41
42
43
# File 'lib/watchdoge/configuration.rb', line 41

def notifications
  @notifications
end

#regression_dirObject

Returns the value of attribute regression_dir


44
45
46
# File 'lib/watchdoge/configuration.rb', line 44

def regression_dir
  @regression_dir
end

#sign_in_procObject

Returns the value of attribute sign_in_proc


47
48
49
# File 'lib/watchdoge/configuration.rb', line 47

def 
  @sign_in_proc
end

#sign_out_procObject

Returns the value of attribute sign_out_proc


48
49
50
# File 'lib/watchdoge/configuration.rb', line 48

def sign_out_proc
  @sign_out_proc
end

#web_drivers_dirObject

Returns the value of attribute web_drivers_dir


33
34
35
# File 'lib/watchdoge/configuration.rb', line 33

def web_drivers_dir
  @web_drivers_dir
end

#worker_optionsObject

Returns the value of attribute worker_options


39
40
41
# File 'lib/watchdoge/configuration.rb', line 39

def worker_options
  @worker_options
end