Class: Ribose::CLI::RCFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ribose/cli/rcfile.rb

Constant Summary collapse

FILE_NAME =
".riboserc".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRCFile

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

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/ribose/cli/rcfile.rb', line 7

def data
  @data
end

#pathObject (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_hostObject



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_tokenObject



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_emailObject



28
29
30
# File 'lib/ribose/cli/rcfile.rb', line 28

def self.user_email
  new.data[:user_email]
end

.user_passwordObject



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