Class: Tastevin::Config
- Inherits:
-
Object
- Object
- Tastevin::Config
- Defined in:
- lib/tastevin/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(agent, host, port, username, password) ⇒ Object
- #exists?(agent) ⇒ Boolean
- #list ⇒ Object
- #remove(agent) ⇒ Object
- #save ⇒ Object
Class Method Details
.load ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/tastevin/config.rb', line 6 def self.load FileUtils.mkdir_p(path) filename = File.join(path, 'agents') inifile = IniFile.new(:filename => filename) Config.new(inifile) end |
.path ⇒ Object
15 16 17 |
# File 'lib/tastevin/config.rb', line 15 def self.path File.join(ENV['HOME'], '.tastevin') end |
Instance Method Details
#[](name) ⇒ Object
19 20 21 |
# File 'lib/tastevin/config.rb', line 19 def [](name) @inifile[name] end |
#add(agent, host, port, username, password) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/tastevin/config.rb', line 31 def add(agent, host, port, username, password) @inifile[agent] = { 'host' => host, 'port' => port, 'username' => username, 'password' => password } end |
#exists?(agent) ⇒ Boolean
23 24 25 |
# File 'lib/tastevin/config.rb', line 23 def exists?(agent) @inifile.has_section? agent end |
#list ⇒ Object
27 28 29 |
# File 'lib/tastevin/config.rb', line 27 def list @inifile.sections end |
#remove(agent) ⇒ Object
40 41 42 |
# File 'lib/tastevin/config.rb', line 40 def remove(agent) @inifile.delete_section agent end |
#save ⇒ Object
44 45 46 |
# File 'lib/tastevin/config.rb', line 44 def save @inifile.write end |