Class: Ninny::UserConfig
- Inherits:
-
Object
- Object
- Ninny::UserConfig
- Defined in:
- lib/ninny/user_config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #gitlab_private_token ⇒ Object
-
#initialize ⇒ UserConfig
constructor
A new instance of UserConfig.
- #read ⇒ Object
- #set(*args) ⇒ Object
- #with_read ⇒ Object
- #write(*args) ⇒ Object
Constructor Details
#initialize ⇒ UserConfig
Returns a new instance of UserConfig.
7 8 9 10 11 12 13 |
# File 'lib/ninny/user_config.rb', line 7 def initialize @config = TTY::Config.new @config.filename = '.ninny' @config.extname = '.yml' @config.prepend_path Dir.home @read = false end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/ninny/user_config.rb', line 5 def config @config end |
Class Method Details
.config ⇒ Object
41 42 43 |
# File 'lib/ninny/user_config.rb', line 41 def self.config new end |
Instance Method Details
#gitlab_private_token ⇒ Object
23 24 25 26 27 |
# File 'lib/ninny/user_config.rb', line 23 def gitlab_private_token with_read do config.fetch(:gitlab_private_token) end end |
#read ⇒ Object
29 30 31 32 33 |
# File 'lib/ninny/user_config.rb', line 29 def read config.read unless @read rescue TTY::Config::ReadError raise MissingUserConfig, 'User config not found, run `ninny setup`' end |
#set(*args) ⇒ Object
19 20 21 |
# File 'lib/ninny/user_config.rb', line 19 def set(*args) config.set(*args) end |
#with_read ⇒ Object
35 36 37 38 39 |
# File 'lib/ninny/user_config.rb', line 35 def with_read read @read = true yield end |
#write(*args) ⇒ Object
15 16 17 |
# File 'lib/ninny/user_config.rb', line 15 def write(*args) config.write(*args) end |