Class: Pacproxy::Config
- Inherits:
-
Object
- Object
- Pacproxy::Config
- Includes:
- Singleton
- Defined in:
- lib/pacproxy/config.rb
Overview
Pacproxy::Config represent configuration for Pacproxy
Constant Summary collapse
- DEFAULT_CONFIG =
{ 'daemonize' => false, 'port' => 3128, 'pac_file' => { 'location' => nil }, 'general_log' => { 'location' => 'pacproxy.log' } }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #read_config(yaml_file) ⇒ Object
- #update(yaml_file = 'pacproxy.yml') ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
17 18 19 20 |
# File 'lib/pacproxy/config.rb', line 17 def initialize @config = DEFAULT_CONFIG self end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/pacproxy/config.rb', line 15 def config @config end |
Instance Method Details
#read_config(yaml_file) ⇒ Object
27 28 29 30 31 |
# File 'lib/pacproxy/config.rb', line 27 def read_config(yaml_file) return {} unless yaml_file return {} unless File.exist?(yaml_file) YAML.load(File.read(yaml_file)) end |
#update(yaml_file = 'pacproxy.yml') ⇒ Object
22 23 24 25 |
# File 'lib/pacproxy/config.rb', line 22 def update(yaml_file = 'pacproxy.yml') @config.merge!(read_config(yaml_file)) self end |