Sha256: 1432c03f4f5d4a4ea9fe36616e5a4b6260bc6a8a7cbfea0e2c573aa7f538f3a6

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'pathname'
require 'ns-options'
require 'dassets/cache'
require 'dassets/file_store'
require 'dassets/source'

module Dassets

  class Config
    include NsOptions::Proxy

    option :file_store, FileStore, :default => proc{ FileStore::NullStore.new }
    option :cache, :default => proc{ Cache::NoCache.new }

    attr_reader :sources, :combinations

    def initialize
      super
      @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 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

2 entries across 2 versions & 1 rubygems

Version Path
dassets-0.12.0 lib/dassets/config.rb
dassets-0.11.0 lib/dassets/config.rb