Sha256: 94ad18b039b195feea14363695a702163628b49db9bcb5e4d953d2b121bdcde3

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

require 'pathname'
require 'dassets/cache'
require 'dassets/file_store'
require 'dassets/source'

module Dassets

  class Config

    attr_reader :sources, :combinations

    def initialize
      super
      self.reset
      @content_cache     = Dassets::Cache::NoCache.new
      @fingerprint_cache = Dassets::Cache::NoCache.new
      @file_store        = FileStore::NullStore.new
    end

    def reset
      @sources      = []
      @combinations = Hash.new{ |h, k| [k] } # digest pass-thru if none defined
    end

    def base_url(value = nil)
      set_base_url(value) if !value.nil?
      @base_url
    end

    def set_base_url(value)
      @base_url = value
    end

    def file_store(value = nil)
      if !value.nil?
        @file_store = (value.kind_of?(FileStore) ? value : FileStore.new(value))
      end
      @file_store
    end

    def content_cache(cache = nil)
      @content_cache = cache if !cache.nil?
      @content_cache
    end

    def fingerprint_cache(cache = nil)
      @fingerprint_cache = cache if !cache.nil?
      @fingerprint_cache
    end

    def source(path, &block)
      @sources << Source.new(path).tap{ |s| block.call(s) if block }
    end

    def combination(key_digest_path, value_digest_paths)
      @combinations[key_digest_path.to_s] = [*value_digest_paths]
    end

    def combination?(key_digest_path)
      # a digest path is only considered a combination is it is not the default
      # pass-thru above
      @combinations[key_digest_path.to_s] != [key_digest_path]
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dassets-0.14.5 lib/dassets/config.rb
dassets-0.14.4 lib/dassets/config.rb
dassets-0.14.3 lib/dassets/config.rb
dassets-0.14.2 lib/dassets/config.rb