class Shelter::Configuration

Read and manage configuration

Attributes

ansible_directory[RW]
inventory_directory[RW]
inventory_script[RW]
plugin_directory[RW]
project_root[R]
resource_directory[RW]
secure_root[RW]
stack_directory[RW]

Public Class Methods

new() click to toggle source
   # File lib/configuration.rb
16 def initialize
17   @ansible_directory = 'ansible'
18   @stack_directory = 'stacks'
19   @resource_directory = 'resources'
20   @secure_root = ENV.fetch('SECURE', 'secure')
21   @inventory_script = File.join(
22     File.dirname($PROGRAM_NAME),
23     'shelter-inventory'
24   )
25   @inventory_directory = 'inventory'
26   @plugin_directory = 'plugin'
27 end

Public Instance Methods

inventory() click to toggle source
   # File lib/configuration.rb
33 def inventory
34   path = File.join(@inventory_directory, '*')
35   Dir.glob(path)
36 end
load_shelterfile() click to toggle source
   # File lib/configuration.rb
29 def load_shelterfile
30   load shelterfile if @shelterfile.nil?
31 end

Private Instance Methods

find_project_root() click to toggle source
   # File lib/configuration.rb
44 def find_project_root
45   @project_root unless @project_root.nil?
46 
47   dir = Dir.pwd
48   loop do
49     break if File.exist?('Shelterfile.rb')
50     raise 'No Shelterfile.rb found' if Dir.pwd == '/'
51     Dir.chdir('..')
52   end
53   @project_root = Dir.pwd
54   Dir.chdir dir
55   @project_root
56 end
shelterfile() click to toggle source
   # File lib/configuration.rb
40 def shelterfile
41   @shelterfile ||= File.join(find_project_root, 'Shelterfile.rb')
42 end