Class: Stars::Config
- Inherits:
-
Object
- Object
- Stars::Config
- Defined in:
- lib/stars/config.rb
Instance Attribute Summary collapse
-
#keep ⇒ Object
Returns the value of attribute keep.
Instance Method Summary collapse
- #config_path ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #prompt_for_service ⇒ Object
- #prompt_for_username(service) ⇒ Object
- #username(service) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 |
# File 'lib/stars/config.rb', line 8 def initialize @keep = Keep.new(config_path) end |
Instance Attribute Details
#keep ⇒ Object
Returns the value of attribute keep.
4 5 6 |
# File 'lib/stars/config.rb', line 4 def keep @keep end |
Instance Method Details
#config_path ⇒ Object
12 13 14 |
# File 'lib/stars/config.rb', line 12 def config_path "#{File.('~')}/.stars.yml" end |
#prompt_for_service ⇒ Object
20 21 22 23 24 25 |
# File 'lib/stars/config.rb', line 20 def prompt_for_service puts "What service do you want to track?" puts "Your options: #{Stars.uninstalled_services.join(', ')}" service = $stdin.gets.chomp.downcase prompt_for_username(service) end |
#prompt_for_username(service) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stars/config.rb', line 27 def prompt_for_username(service) return @keep.get(service) if @keep.present?(service) if !Stars.uninstalled_services.empty? and !Stars.uninstalled_services.include?(service.downcase) puts("You need to pick something from: #{Stars.uninstalled_services.join(', ')}") return exit end puts "What's your username for #{service}?" username = $stdin.gets.chomp @keep.set(service,username) end |
#username(service) ⇒ Object
16 17 18 |
# File 'lib/stars/config.rb', line 16 def username(service) prompt_for_username(service) end |