lib/tw/conf.rb in tw-0.0.1 vs lib/tw/conf.rb in tw-0.0.2
- old
+ new
@@ -2,12 +2,15 @@
module Tw
class Conf
def self.default
{
+ 'version' => Tw::VERSION,
'consumer_key' => 'AYhhkOC8H2yTZyelz3uw',
- 'consumer_secret' => '28Ba8YyFDSPgoCYAmH5ANqOmT6qVS8gIhKnUiDbIpU'
+ 'consumer_secret' => '28Ba8YyFDSPgoCYAmH5ANqOmT6qVS8gIhKnUiDbIpU',
+ 'default_user' => nil,
+ 'users' => {}
}
end
def self.[](key)
ENV[key] || conf[key]
@@ -16,11 +19,11 @@
def self.[]=(key,value)
conf[key] = value
end
def self.conf_file
- "#{ENV['HOME']}/.tw.conf"
+ "#{ENV['HOME']}/.tw.yml"
end
def self.conf
@@conf ||= (
res = default
@@ -36,19 +39,25 @@
end
res
)
end
+ def self.to_yaml
+ self.conf.to_yaml
+ end
+
+ def self.save
+ open_conf_file('w+') do |f|
+ f.write conf.to_yaml
+ end
+ end
+
+ private
def self.open_conf_file(opt=nil, &block)
if block_given?
yield open(self.conf_file, opt)
else
return open(self.conf_file, opt)
end
end
-
- def self.to_yaml
- self.conf.to_yaml
- end
-
end
end