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.
5 6 7 8 9 10 11 |
# File 'lib/ninny/user_config.rb', line 5 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.
3 4 5 |
# File 'lib/ninny/user_config.rb', line 3 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
21 22 23 24 25 |
# File 'lib/ninny/user_config.rb', line 21 def gitlab_private_token with_read do config.fetch(:gitlab_private_token) end end |
#read ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ninny/user_config.rb', line 27 def read begin config.read unless @read rescue TTY::Config::ReadError raise MissingUserConfig.new("User config not found, run `ninny setup`") end end |
#set(*args) ⇒ Object
17 18 19 |
# File 'lib/ninny/user_config.rb', line 17 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
13 14 15 |
# File 'lib/ninny/user_config.rb', line 13 def write(*args) config.write(*args) end |