Class: HR_Deploy::ConfigHandler
- Inherits:
-
Object
- Object
- HR_Deploy::ConfigHandler
- Defined in:
- lib/hr_deploy/config_handler.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
83 84 85 |
# File 'lib/hr_deploy/config_handler.rb', line 83 def error @error end |
#targets ⇒ Object
Returns the value of attribute targets.
84 85 86 |
# File 'lib/hr_deploy/config_handler.rb', line 84 def targets @targets end |
Class Method Details
.config_exists? ⇒ Boolean
92 93 94 |
# File 'lib/hr_deploy/config_handler.rb', line 92 def self.config_exists? File.exists?(CONFIG_FILE_NAME) end |
Instance Method Details
#attempt_to_load_targets ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/hr_deploy/config_handler.rb', line 113 def attempt_to_load_targets # If any of the checks fail, 'self.error' will be set # If no checks fail, 'self.targets' will be set if valid_format? if valid_structure? self.targets = load_targets end end end |
#generate_config ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/hr_deploy/config_handler.rb', line 96 def generate_config generate = true if self.class.config_exists? print 'Config file already exists. Overwrite? [Y/n] > ' answer = $stdin.gets.chomp.downcase generate = false unless answer == 'y' || answer == 'yes' end if generate File.open(CONFIG_FILE_NAME, 'w') { |file| file.write(EXAMPLE_CONFIG) } puts "Example config created at #{CONFIG_FILE_NAME}. Edit it to suit your needs" else puts 'Not overwriting config' end end |
#new ⇒ Object
86 87 88 89 90 |
# File 'lib/hr_deploy/config_handler.rb', line 86 def new @error = nil @raw_targets = nil @targets = [] end |