Class: Octoauth::ConfigFile
- Inherits:
-
Object
- Object
- Octoauth::ConfigFile
- Defined in:
- lib/octoauth/configfile.rb
Overview
Configuration object
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ ConfigFile
constructor
Create new Config object, either ephemerally or from a file.
- #write ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ ConfigFile
Create new Config object, either ephemerally or from a file
20 21 22 23 24 25 |
# File 'lib/octoauth/configfile.rb', line 20 def initialize(params = {}) @file = params[:file] == :default ? DEFAULT_FILE : params[:file] @file = File.(@file) if @file @note = params[:note] || raise(ArgumentError, 'A note must be provided') @token = parse end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
15 16 17 |
# File 'lib/octoauth/configfile.rb', line 15 def file @file end |
#token ⇒ Object
Returns the value of attribute token.
16 17 18 |
# File 'lib/octoauth/configfile.rb', line 16 def token @token end |
Instance Method Details
#write ⇒ Object
27 28 29 30 31 |
# File 'lib/octoauth/configfile.rb', line 27 def write new = get new[@note] = @token File.open(@file, 'w', 0o0600) { |fh| fh.write new.to_yaml } end |