Class: ProxyTester::CapybaraProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/proxy_tester/capybara_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/proxy_tester/capybara_proxy.rb', line 5

def host
  @host
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/proxy_tester/capybara_proxy.rb', line 6

def port
  @port
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/proxy_tester/capybara_proxy.rb', line 6

def type
  @type
end

#userObject

Returns the value of attribute user.



5
6
7
# File 'lib/proxy_tester/capybara_proxy.rb', line 5

def user
  @user
end

Instance Method Details

#as_phantomjs_argumentsObject



37
38
39
40
41
42
43
44
# File 'lib/proxy_tester/capybara_proxy.rb', line 37

def as_phantomjs_arguments
  result = []
  result << "--proxy=#{to_connect}" if host || port
  result << "--proxy-type=#{type}" if type
  result << "--proxy-auth=#{user.to_login(cleartext: true)}" if user

  result
end

#blank?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/proxy_tester/capybara_proxy.rb', line 46

def blank?
  host.blank? and port.blank?
end

#to_connectObject



50
51
52
# File 'lib/proxy_tester/capybara_proxy.rb', line 50

def to_connect
  "#{host}:#{port}".shellescape
end

#to_symObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/proxy_tester/capybara_proxy.rb', line 25

def to_sym
  return :no_proxy if host.blank? or port.blank?

  result = []

  result << host
  result << port
  result << user.name unless user.blank?

  result.join('_').to_sym
end