Class: Deployed::Config
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- Deployed::Config
- Defined in:
- app/models/deployed/config.rb
Overview
Provides a model to track the current values in ./config/deploy.yml
Class Method Summary collapse
Class Method Details
.init!(yaml_file = './config/deploy.yml', dot_env_file = '.env') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/deployed/config.rb', line 10 def self.init!(yaml_file = './config/deploy.yml', dot_env_file = '.env') self.requires_init = File.exist?(yaml_file) ? false : true unless requires_init yaml_data = YAML.load_file(yaml_file) self.service = yaml_data['service'] self.image = yaml_data['image'] self.servers = yaml_data['servers'] self.ssh = yaml_data['ssh'] self.volumes = yaml_data['volumes'] self.registry = yaml_data['registry'] self.env = yaml_data['env'] || {} self.traefik = yaml_data['traefik'] end if File.exist?(dot_env_file) self.env_values = {} File.open(dot_env_file, 'r') do |file| file.each_line do |line| key, value = line.strip.split('=') self.env_values[key] = value end end end requires_init end |