Class: SmarterMeter::Interfaces::CLI
- Inherits:
-
Object
- Object
- SmarterMeter::Interfaces::CLI
- Defined in:
- lib/smartermeter/interfaces/cli.rb
Instance Method Summary collapse
-
#log ⇒ Object
Returns a logger like interface to log errors and warnings to.
-
#setup {|config| ... } ⇒ Object
Public: Called when ~/.smartermeter needs to be configured.
Instance Method Details
#log ⇒ Object
Returns a logger like interface to log errors and warnings to.
7 8 9 10 11 12 |
# File 'lib/smartermeter/interfaces/cli.rb', line 7 def log return @logger if @logger @logger = Logger.new STDOUT @logger.level = Logger::INFO @logger end |
#setup {|config| ... } ⇒ Object
Public: Called when ~/.smartermeter needs to be configured. Yields a hash containing the configuration by the user.
Returns nothing
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/smartermeter/interfaces/cli.rb', line 18 def setup puts puts "SmarterMeter: Initial Configuration" puts "--------------------------------------------------------------------------------" puts "This program stores your PG&E account username and password on disk. The" puts "password is encrypted but could be retrieved fairly easily. If this makes you" puts "uncomfortable quit now (use ctrl-c)." puts "--------------------------------------------------------------------------------" config = {} print "PG&E account username: " config[:username] = gets.strip print "PG&E account password: " config[:password] = gets.strip puts "Configuration finished" yield config end |