Class: Digicert::CLI::RCFile

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/digicert/cli/rcfile.rb

Constant Summary collapse

FILE_NAME =
".digicertrc".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRCFile

Returns a new instance of RCFile.



11
12
13
14
# File 'lib/digicert/cli/rcfile.rb', line 11

def initialize
  @path = File.join(File.expand_path("~"), FILE_NAME)
  @data = load_configuration
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/digicert/cli/rcfile.rb', line 8

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/digicert/cli/rcfile.rb', line 8

def path
  @path
end

Class Method Details

.api_keyObject



21
22
23
# File 'lib/digicert/cli/rcfile.rb', line 21

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

.set_key(api_key) ⇒ Object



25
26
27
# File 'lib/digicert/cli/rcfile.rb', line 25

def self.set_key(api_key)
  new.set_key(api_key)
end

Instance Method Details

#set_key(api_key) ⇒ Object



16
17
18
19
# File 'lib/digicert/cli/rcfile.rb', line 16

def set_key(api_key)
  data[:api_key] = api_key
  write_api_key_to_file
end