Sha256: 97d77917143ee5490b8142fc20736faf113c9ce9bda7be695fad67999a53e5af

Contents?: true

Size: 868 Bytes

Versions: 17

Compression:

Stored size: 868 Bytes

Contents

module SimplePerf
  class Config

    attr_accessor :config

    def initialize(args = {})
      load_config_file
    end

    def environments
      config['environments']
    end

    def environment(name)
      raise "Environment not found" unless environments.include? name
      environments[name]
    end

    def notifications
      config['notifications']
    end

    def region(name)
      environment(name)['region']
    end

    private

    def load_config_file
      config_file = "#{ENV['HOME']}/.simple_deploy.yml"

      begin
        self.config = YAML::load( File.open( config_file ) )
      rescue Errno::ENOENT
        raise "#{config_file} not found"
      rescue Psych::SyntaxError => e
        raise "#{config_file} is corrupt"
      end
    end

    def env_home
      ENV['HOME']
    end

    def env_user
      ENV['USER']
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
simple_perf-0.0.18 lib/simple_perf/config.rb
simple_perf-0.0.17 lib/simple_perf/config.rb
simple_perf-0.0.15 lib/simple_perf/config.rb
simple_perf-0.0.14 lib/simple_perf/config.rb
simple_perf-0.0.13 lib/simple_perf/config.rb
simple_perf-0.0.12 lib/simple_perf/config.rb
simple_perf-0.0.11 lib/simple_perf/config.rb
simple_perf-0.0.10 lib/simple_perf/config.rb
simple_perf-0.0.9 lib/simple_perf/config.rb
simple_perf-0.0.8 lib/simple_perf/config.rb
simple_perf-0.0.7 lib/simple_perf/config.rb
simple_perf-0.0.6 lib/simple_perf/config.rb
simple_perf-0.0.5 lib/simple_perf/config.rb
simple_perf-0.0.4 lib/simple_perf/config.rb
simple_perf-0.0.3 lib/simple_perf/config.rb
simple_perf-0.0.2 lib/simple_perf/config.rb
simple_perf-0.0.1 lib/simple_perf/config.rb