class Ribose::CLI::RCFile
Constants
- FILE_NAME
Attributes
data[R]
path[R]
Public Class Methods
api_token()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 22 def self.api_token new.data[:api_token] end
new()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 10 def initialize @path = build_rcfile_path @data = load_configuration end
set(token:, email:)
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 30 def self.set(token:, email:) new.set(token: token, email: email) end
user_email()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 26 def self.user_email new.data[:user_email] end
Public Instance Methods
set(token:, email:)
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 15 def set(token:, email:) data[:api_token] = token data[:user_email] = email write_api_details_to_file end
Private Instance Methods
build_rcfile_path()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 36 def build_rcfile_path File.join(File.expand_path("~"), FILE_NAME) end
default_configuration()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 46 def default_configuration { api_token: nil, user_email: nil } end
load_configuration()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 40 def load_configuration YAML.load_file(path) rescue Errno::ENOENT default_configuration end
write_api_details_to_file()
click to toggle source
# File lib/ribose/cli/rcfile.rb, line 50 def write_api_details_to_file File.open(path, File::RDWR | File::TRUNC | File::CREAT, 0o0600) do |rc| rc.write(data.to_yaml) end end