Class: Confinicky::Controllers::Exports

Inherits:
Commands
  • Object
show all
Defined in:
lib/confinicky/controllers/exports.rb

Overview

A subclass of the command group controller specifically for managing export statements.

Instance Attribute Summary

Attributes inherited from Commands

#path

Instance Method Summary collapse

Methods inherited from Commands

#backup!, #duplicates, #find, #inspect, #length, #remove!, #set!, #to_table

Constructor Details

#initializeExports

Returns a new instance of Exports.



9
10
11
12
13
# File 'lib/confinicky/controllers/exports.rb', line 9

def initialize
  super(file_type_key: :env)
  @commands = @shell_file.exports
  @table_title = "Environment Variables"
end

Instance Method Details

#clean!Object

Finds duplicate export statements and replaces them with the actual value from the environment.



25
26
27
28
29
30
# File 'lib/confinicky/controllers/exports.rb', line 25

def clean!
  for duplicate in duplicates.map{|duplicate| duplicate[0]}
    @commands.delete_if{ |i| i[0] == duplicate}
    @commands << [duplicate, ENV[duplicate]]
  end
end

#save!Object

Updates the actual shell file on disk.



17
18
19
20
# File 'lib/confinicky/controllers/exports.rb', line 17

def save!
  @shell_file.exports = @commands
  @shell_file.write!
end