Class: Ribose::CLI::RCFile
- Inherits:
-
Object
- Object
- Ribose::CLI::RCFile
- Defined in:
- lib/ribose/cli/rcfile.rb
Constant Summary collapse
- FILE_NAME =
".riboserc".freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .api_host ⇒ Object
- .api_token ⇒ Object
- .set(email:, password:, token: nil, api_host: nil) ⇒ Object
- .user_email ⇒ Object
- .user_password ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ RCFile
constructor
A new instance of RCFile.
- #set(email:, password:, token: nil, api_host: nil) ⇒ Object
Constructor Details
#initialize ⇒ RCFile
Returns a new instance of RCFile.
10 11 12 13 |
# File 'lib/ribose/cli/rcfile.rb', line 10 def initialize @path = build_rcfile_path @data = load_configuration end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/ribose/cli/rcfile.rb', line 7 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/ribose/cli/rcfile.rb', line 7 def path @path end |
Class Method Details
.api_host ⇒ Object
36 37 38 |
# File 'lib/ribose/cli/rcfile.rb', line 36 def self.api_host ENV.fetch("RIBOSE_API_HOST", new.data[:api_host]) end |
.api_token ⇒ Object
24 25 26 |
# File 'lib/ribose/cli/rcfile.rb', line 24 def self.api_token new.data[:api_token] end |
.set(email:, password:, token: nil, api_host: nil) ⇒ Object
40 41 42 |
# File 'lib/ribose/cli/rcfile.rb', line 40 def self.set(email:, password:, token: nil, api_host: nil) new.set(token: token, email: email, password: password, api_host: api_host) end |
.user_email ⇒ Object
28 29 30 |
# File 'lib/ribose/cli/rcfile.rb', line 28 def self.user_email new.data[:user_email] end |
.user_password ⇒ Object
32 33 34 |
# File 'lib/ribose/cli/rcfile.rb', line 32 def self.user_password new.data[:user_password] end |
Instance Method Details
#set(email:, password:, token: nil, api_host: nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/ribose/cli/rcfile.rb', line 15 def set(email:, password:, token: nil, api_host: nil) data[:api_token] = token data[:user_email] = email data[:user_password] = password data[:api_host] = api_host write_api_details_to_file end |