Class: Awestruct::HandlerChains

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/handler_chains.rb

Constant Summary collapse

DEFAULTS =
[
  HandlerChain.new( /\.md$/, 
    Awestruct::Handlers::FileHandler,
    Awestruct::Handlers::FrontMatterHandler,
    Awestruct::Handlers::InterpolationHandler,
    Awestruct::Handlers::MarkdownHandler,
    Awestruct::Handlers::LayoutHandler
  ),
  HandlerChain.new( /\.textile$/,
    Awestruct::Handlers::FileHandler,
    Awestruct::Handlers::FrontMatterHandler,
    Awestruct::Handlers::InterpolationHandler,
    Awestruct::Handlers::TextileHandler,
    Awestruct::Handlers::LayoutHandler
  ),
  HandlerChain.new( /\.haml$/, 
    Awestruct::Handlers::FileHandler,
    Awestruct::Handlers::FrontMatterHandler,
    Awestruct::Handlers::HamlHandler,
    Awestruct::Handlers::LayoutHandler
  ),
  HandlerChain.new( /\.sass$/,
    Awestruct::Handlers::FileHandler,
    Awestruct::Handlers::SassHandler
  ),
  HandlerChain.new( /\.scss$/,
    Awestruct::Handlers::FileHandler,
    Awestruct::Handlers::ScssHandler
  ),
  HandlerChain.new( /.*/, Awestruct::Handlers::FileHandler )
]

Instance Method Summary collapse

Constructor Details

#initialize(include_defaults = true) ⇒ HandlerChains

Returns a new instance of HandlerChains.



50
51
52
53
# File 'lib/awestruct/handler_chains.rb', line 50

def initialize(include_defaults=true)
  @chains = []
  self << :defaults if include_defaults
end

Instance Method Details

#<<(chain) ⇒ Object



59
60
61
62
# File 'lib/awestruct/handler_chains.rb', line 59

def <<(chain)
  @chains += DEFAULTS and return if ( chain == :defaults )
  @chains << chain
end

#[](path) ⇒ Object



55
56
57
# File 'lib/awestruct/handler_chains.rb', line 55

def[](path)
  @chains.detect{|e| e.matches?( path.to_s ) }
end