Sha256: bd472ffc790ac446ce5c9ccd463eb4bc01b27554d9e4dd63dfd5da2249f7ff32

Contents?: true

Size: 773 Bytes

Versions: 9

Compression:

Stored size: 773 Bytes

Contents

require 'dassets/engine'

module Dassets; end
class Dassets::Source

  attr_reader :path, :engines

  def initialize(path)
    @path = path.to_s
    @filter = proc{ |paths| paths }
    @engines = Hash.new{ |h,k| Dassets::NullEngine.new }
  end

  def filter(&block)
    block.nil? ? @filter : @filter = block
  end

  def engine(input_ext, engine_class, registered_opts=nil)
    default_opts = { 'source_path' => @path }
    engine_opts = default_opts.merge(registered_opts || {})
    @engines[input_ext.to_s] = engine_class.new(engine_opts)
  end

  def files
    apply_filter(glob_files || []).sort
  end

  private

  def glob_files
    Dir.glob(File.join(@path, "**/*")).reject!{ |p| !File.file?(p) }
  end

  def apply_filter(files)
    @filter.call(files)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dassets-0.13.0 lib/dassets/source.rb
dassets-0.12.0 lib/dassets/source.rb
dassets-0.11.0 lib/dassets/source.rb
dassets-0.10.1 lib/dassets/source.rb
dassets-0.10.0 lib/dassets/source.rb
dassets-0.9.0 lib/dassets/source.rb
dassets-0.8.0 lib/dassets/source.rb
dassets-0.7.0 lib/dassets/source.rb
dassets-0.6.2 lib/dassets/source.rb