Class: Selenium::WebDriver::Tor::Torrc
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Tor::Torrc
- Defined in:
- lib/tor/torrc.rb
Overview
Respresentation of a torrc file
Constant Summary collapse
- FIXED_CONFIG_KEYS =
%w[DataDirectory GeoIPFile GeoIPv6File SocksPort].freeze
- INVALID_OPTION_REGEX =
%r{\[warn\] Failed to parse/validate config: (.*).$}
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(data_dir) ⇒ Torrc
constructor
A new instance of Torrc.
- #write_to_config(hash) ⇒ Object
Constructor Details
#initialize(data_dir) ⇒ Torrc
Returns a new instance of Torrc.
16 17 18 19 20 21 |
# File 'lib/tor/torrc.rb', line 16 def initialize(data_dir) @data_dir = data_dir @torrc_file = File.new File.join(@data_dir, 'torrc'), 'w' @path = @torrc_file.path write_default_config end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/tor/torrc.rb', line 14 def path @path end |
Instance Method Details
#config ⇒ Object
23 24 25 |
# File 'lib/tor/torrc.rb', line 23 def config parse_config end |
#write_to_config(hash) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/tor/torrc.rb', line 27 def write_to_config(hash) raise ArgumentError, 'Torrc#write_to_config takes a hash as argument' unless hash.is_a? Hash hash @torrc_file.write hash_to_config_string(config.merge(hash).merge(fixed_config)) @torrc_file.rewind end |