Sha256: 2cd4bc0da27062242669427a4da9d76c59741e5aacb4624fd6c22da189cb21ae

Contents?: true

Size: 919 Bytes

Versions: 21

Compression:

Stored size: 919 Bytes

Contents

require 'yaml'

module Torpedo
  module Config

    @@configs=nil

    def self.load_configs
      return @@configs if not @@configs.nil?

      config_file=ENV['TORPEDO_CONFIG_FILE']
      if config_file.nil? then

        config_file=ENV['HOME']+File::SEPARATOR+".torpedo.conf"
        if not File.exists?(config_file) then
          config_file="/etc/torpedo.conf"
        end

      end

      if File.exists?(config_file) then
        configs = YAML.load_file(config_file) || {}
        @@configs = configs
      else
        raise "Failed to load torpedo config file. Please configure /etc/torpedo.conf or create a .torpedo.conf config file in your HOME directory."
      end

      @@configs

    end

    def self.raise_if_nil_or_empty(options, key)
      if not options or options[key].nil? or options[key].empty? then
        raise "Please specify a valid #{key.to_s} parameter."
      end
    end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
torpedo-2.1.0 lib/torpedo/config.rb
torpedo-1.0.19 lib/torpedo/config.rb
torpedo-1.0.18 lib/torpedo/config.rb
torpedo-1.0.17 lib/torpedo/config.rb
torpedo-1.0.16 lib/torpedo/config.rb
torpedo-1.0.15 lib/torpedo/config.rb
torpedo-1.0.14 lib/torpedo/config.rb
torpedo-1.0.13 lib/torpedo/config.rb
torpedo-1.0.12 lib/torpedo/config.rb
torpedo-1.0.11 lib/torpedo/config.rb
torpedo-1.0.10 lib/torpedo/config.rb
torpedo-1.0.9 lib/torpedo/config.rb
torpedo-1.0.8 lib/torpedo/config.rb
torpedo-1.0.7 lib/torpedo/config.rb
torpedo-1.0.6 lib/torpedo/config.rb
torpedo-1.0.5 lib/torpedo/config.rb
torpedo-1.0.4 lib/torpedo/config.rb
torpedo-1.0.3 lib/torpedo/config.rb
torpedo-1.0.2 lib/torpedo/config.rb
torpedo-1.0.1 lib/torpedo/config.rb