Sha256: 505a96f5748b25a27a0b84d450cf497b78965e4d03a539ad22e1ed27d954a124

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

module S3Antivirus
  class Config
    include Logger

    attr_reader :data
    def initialize(path=nil)
      @data = load(path)
    end

    def load(path)
      YAML.load_file(lookup_path(path))
    end

    def lookup_path(path=nil)
      paths = [
        path,
        "./s3-antivirus.conf",
        "#{ENV['HOME']}/.s3-antivirus.conf",
        "/etc/s3-antivirus.conf"
      ].compact
      found = paths.find { |p| File.exist?(p) }
      unless found
        logger.fatal("FATAL: unable to find the s3-antivirus.conf file. Paths considered: #{paths}")
        exit 1
      end
      found
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
s3-antivirus-0.2.0 lib/s3_antivirus/config.rb
s3-antivirus-0.1.0 lib/s3_antivirus/config.rb