Sha256: da4bded46fcec34a496c680aedb9849f3f275911dc8efa8ea9195772cfb24124

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

require 'yaml'

module Cas
  class Config

    def initialize(filename: nil)
      @filename = filename
    end

    def uploads
      uploads = config["uploads"] || {}

      {
        cache_directory_prefix: uploads["cache_directory_prefix"] || "cache",
        store_directory_prefix: uploads["store_directory_prefix"] || "store"
      }
    end

    private

    def read_file
      @file ||= YAML.load_file(filename)
    end

    def filename
      @filename ||= begin
                      if File.exists?("cas.yml")
                        "cas.yml"
                      elsif ENV['RAILS_ENV'] == 'test'
                        "spec/fixtures/cas.yml"
                      else
                        raise "cas.yml file is not defined."
                      end
      end
    end

    def config
      read_file["config"] || {}
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cas-cms-0.1.3 lib/cas/config.rb
cas-cms-0.1.2 lib/cas/config.rb
cas-cms-0.1.1 lib/cas/config.rb
cas-cms-0.1.0 lib/cas/config.rb