Sha256: 9160d273fca3edd263abd3ab8b85391664334e24975c42655b1eea0818f2902c

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

module Phase
  class Configuration

    attr_accessor :use_bastions,
                  :bastion_role,
                  :bastion_user,

                  :aws_region

    def initialize
      @use_bastions = false
      @bastion_role = nil
      @bastion_user = nil

      @aws_region   = "us-east-1"

      ::SSHKit.config.backend = SSH::Backend

      configure_from_yml if defined?(::Rails) && yml_present?
    end

    def configure_from_yml
      yml_config = ::YAML.load_file(yml_path) || {}

      @use_bastions = yml_config[:use_bastions] if yml_config.has_key(:use_bastions)
      @bastion_role = yml_config[:bastion_role] if yml_config.has_key(:bastion_role)
      @bastion_user = yml_config[:bastion_user] if yml_config.has_key(:bastion_user)

      @aws_region = yml_config[:aws_region] if yml_config.has_key(:aws_region)
    end

    def yml_present?
      File.exists?(yml_path)
    end

    def yml_path
      # ::Rails.root.join("config", "phase.yml")
      ""
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phase-0.0.2 lib/phase/configuration.rb
phase-0.0.1 lib/phase/configuration.rb