Class: Rescuetime::Config
- Inherits:
-
Object
- Object
- Rescuetime::Config
- Includes:
- Debug
- Defined in:
- lib/rescuetime/config.rb
Constant Summary collapse
- DEFAULT_PATH =
File.join(Dir.home, ".ruby-rescuetime")
- DEFAULT_FILE =
"config.yml"
- DEFAULT_CONFIG =
{ :email => "[email protected]", :password => "" }
Instance Method Summary collapse
- #email ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
Constructor.
- #location ⇒ Object
- #password ⇒ Object
-
#path ⇒ Object
Path where to store data.
-
#update ⇒ Object
Write current config to disc.
Methods included from Debug
Constructor Details
#initialize(options = {}) ⇒ Config
Constructor
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rescuetime/config.rb', line 16 def initialize( = {}) = { :debug => false, :email => nil, :password => nil, :config => File.join(DEFAULT_PATH, DEFAULT_FILE), :path => nil }.merge() debug! if [:debug] @config_path = [:config] || File.join([:path] || DEFAULT_PATH, DEFAULT_FILE) config = read_config(@config_path) @config = { :email => [:email] || config[:email], :password => [:password] || config[:password], :path => DEFAULT_PATH || config[:path] } update if @config != config end |
Instance Method Details
#email ⇒ Object
39 40 41 |
# File 'lib/rescuetime/config.rb', line 39 def email @config[:email] end |
#location ⇒ Object
52 53 54 |
# File 'lib/rescuetime/config.rb', line 52 def location @config_path end |
#password ⇒ Object
43 44 45 |
# File 'lib/rescuetime/config.rb', line 43 def password @config[:password] end |
#path ⇒ Object
Path where to store data
48 49 50 |
# File 'lib/rescuetime/config.rb', line 48 def path @config[:path] end |
#update ⇒ Object
Write current config to disc
57 58 59 |
# File 'lib/rescuetime/config.rb', line 57 def update update_config(@config, @config_path) end |