Class: Pello::Config
- Inherits:
-
Object
- Object
- Pello::Config
- Defined in:
- lib/pello/config.rb
Constant Summary collapse
- CONFIG_FILE_PATH =
"#{ENV['HOME']}/.config/pello/pello.yaml".freeze
Instance Attribute Summary collapse
-
#board_url ⇒ Object
Returns the value of attribute board_url.
-
#developer_public_key ⇒ Object
Returns the value of attribute developer_public_key.
-
#error ⇒ Object
Returns the value of attribute error.
-
#list_name ⇒ Object
Returns the value of attribute list_name.
-
#member_token ⇒ Object
Returns the value of attribute member_token.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Config
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pello/config.rb', line 6 def initialize if File.exist?(CONFIG_FILE_PATH) config = YAML.safe_load File.open(CONFIG_FILE_PATH).read auth_config = config['auth'] @developer_public_key = auth_config['developer_public_key'] @member_token = auth_config['member_token'] pello_config = config['config'] @username = pello_config['username'] @board_url = pello_config['board_url'] @list_name = pello_config['list_name'] @error = false else @error = true end rescue => e @error = true puts "Error loading config: #{e.message}" end |
Instance Attribute Details
#board_url ⇒ Object
Returns the value of attribute board_url.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def board_url @board_url end |
#developer_public_key ⇒ Object
Returns the value of attribute developer_public_key.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def developer_public_key @developer_public_key end |
#error ⇒ Object
Returns the value of attribute error.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def error @error end |
#list_name ⇒ Object
Returns the value of attribute list_name.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def list_name @list_name end |
#member_token ⇒ Object
Returns the value of attribute member_token.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def member_token @member_token end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/pello/config.rb', line 4 def username @username end |
Class Method Details
.write_empty_config ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pello/config.rb', line 31 def self.write_empty_config system "mkdir -p #{File.dirname(CONFIG_FILE_PATH)}" File.open(CONFIG_FILE_PATH, 'w') do |file| file.puts 'auth:' file.puts ' developer_public_key: ""' file.puts ' member_token: ""' file.puts 'config:' file.puts ' board_url: ""' file.puts ' username: ""' file.puts ' list_name: "In progress"' end end |
Instance Method Details
#valid? ⇒ Boolean
27 28 29 |
# File 'lib/pello/config.rb', line 27 def valid? !error end |