Class: Capybara::Apparition::Configuration

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/capybara/apparition/configuration.rb', line 32

def initialize
  @allowed_urls = []
  @blocked_urls = []
  @block_unknown_urls = false
  @debug = false
  @ignore_ssl_errors = false
  @proxy = nil
  @skip_image_loading = false
  @stderr = $stderr
  @timeout = -1
  @raise_javascript_errors = false
end

Instance Attribute Details

#allowed_urlsObject

Returns the value of attribute allowed_urls.



21
22
23
# File 'lib/capybara/apparition/configuration.rb', line 21

def allowed_urls
  @allowed_urls
end

#block_unknown_urlsObject



53
54
55
# File 'lib/capybara/apparition/configuration.rb', line 53

def block_unknown_urls
  @block_unknown_urls = true
end

#blocked_urlsObject

Returns the value of attribute blocked_urls.



23
24
25
# File 'lib/capybara/apparition/configuration.rb', line 23

def blocked_urls
  @blocked_urls
end

#debugObject

Returns the value of attribute debug.



24
25
26
# File 'lib/capybara/apparition/configuration.rb', line 24

def debug
  @debug
end

#ignore_ssl_errorsObject



65
66
67
# File 'lib/capybara/apparition/configuration.rb', line 65

def ignore_ssl_errors
  @ignore_ssl_errors = true
end

#proxyObject

Returns the value of attribute proxy.



26
27
28
# File 'lib/capybara/apparition/configuration.rb', line 26

def proxy
  @proxy
end

#raise_javascript_errorsObject

Returns the value of attribute raise_javascript_errors.



30
31
32
# File 'lib/capybara/apparition/configuration.rb', line 30

def raise_javascript_errors
  @raise_javascript_errors
end

#skip_image_loadingObject



73
74
75
# File 'lib/capybara/apparition/configuration.rb', line 73

def skip_image_loading
  @skip_image_loading = true
end

#stderrObject

Returns the value of attribute stderr.



27
28
29
# File 'lib/capybara/apparition/configuration.rb', line 27

def stderr
  @stderr
end

#timeoutObject

Returns the value of attribute timeout.



28
29
30
# File 'lib/capybara/apparition/configuration.rb', line 28

def timeout
  @timeout
end

Class Method Details

.modifyObject



17
18
19
# File 'lib/capybara/apparition/configuration.rb', line 17

def self.modify
  raise 'All configuration must take place before the driver starts' if instance.frozen?
end

.to_hashObject



13
14
15
# File 'lib/capybara/apparition/configuration.rb', line 13

def self.to_hash
  instance.freeze.to_hash
end

Instance Method Details

#allow_unknown_urlsObject



61
62
63
# File 'lib/capybara/apparition/configuration.rb', line 61

def allow_unknown_urls
  allow_url('*')
end

#allow_url(url) ⇒ Object



45
46
47
# File 'lib/capybara/apparition/configuration.rb', line 45

def allow_url(url)
  @allowed_urls << url
end

#block_unknown_urls?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/capybara/apparition/configuration.rb', line 57

def block_unknown_urls?
  @block_unknown_urls
end

#block_url(url) ⇒ Object



49
50
51
# File 'lib/capybara/apparition/configuration.rb', line 49

def block_url(url)
  @blocked_urls << url
end

#ignore_ssl_errors?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/capybara/apparition/configuration.rb', line 69

def ignore_ssl_errors?
  @ignore_ssl_errors
end

#skip_image_loading?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/capybara/apparition/configuration.rb', line 77

def skip_image_loading?
  @skip_image_loading
end

#to_hashObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/capybara/apparition/configuration.rb', line 85

def to_hash
  {
    url_whitelist: allowed_urls,
    block_unknown_urls: block_unknown_urls?,
    url_blacklist: blocked_urls,
    debug: debug,
    ignore_ssl_errors: ignore_ssl_errors?,
    proxy: proxy,
    skip_image_loading: skip_image_loading?,
    stderr: stderr,
    timeout: timeout,
    js_errors: raise_javascript_errors
  }
end

#use_proxy(proxy) ⇒ Object



81
82
83
# File 'lib/capybara/apparition/configuration.rb', line 81

def use_proxy(proxy)
  @proxy = proxy
end