Class: Confinicky::Controllers::Exports
- 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
Instance Method Summary collapse
-
#clean! ⇒ Object
Finds duplicate export statements and replaces them with the actual value from the environment.
-
#initialize ⇒ Exports
constructor
A new instance of Exports.
-
#save! ⇒ Object
Updates the actual shell file on disk.
Methods inherited from Commands
#backup!, #duplicates, #find, #inspect, #length, #remove!, #set!, #to_table
Constructor Details
#initialize ⇒ Exports
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 |