Class: Dassets::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/dassets/source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Source

Returns a new instance of Source.



9
10
11
12
13
14
# File 'lib/dassets/source.rb', line 9

def initialize(path)
  @path             = path.to_s
  @filter           = proc{ |paths| paths }
  @engines          = Hash.new{ |hash, key| hash[key] = [] }
  @response_headers = Hash.new
end

Instance Attribute Details

#enginesObject (readonly)

Returns the value of attribute engines.



7
8
9
# File 'lib/dassets/source.rb', line 7

def engines
  @engines
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/dassets/source.rb', line 7

def path
  @path
end

#response_headersObject (readonly)

Returns the value of attribute response_headers.



7
8
9
# File 'lib/dassets/source.rb', line 7

def response_headers
  @response_headers
end

Instance Method Details

#engine(input_ext, engine_class, registered_opts = nil) ⇒ Object



20
21
22
23
24
# File 'lib/dassets/source.rb', line 20

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

#filesObject



26
27
28
# File 'lib/dassets/source.rb', line 26

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

#filter(&block) ⇒ Object



16
17
18
# File 'lib/dassets/source.rb', line 16

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