Class: Awestruct::HandlerChains

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

Constant Summary collapse

DEFAULTS =
[
  Awestruct::Handlers::CssTiltHandler::CHAIN,
  Awestruct::Handlers::RedirectHandler::CHAIN,
  Awestruct::Handlers::JavascriptHandler::CHAIN,
  Awestruct::Handlers::AsciidoctorHandler::CHAIN,
  Awestruct::Handlers::TiltHandler::NON_INTERPOLATION_CHAIN,
  Awestruct::Handlers::TiltHandler::INTERPOLATION_CHAIN,
  HandlerChain.new( /.*/, Awestruct::Handlers::VerbatimFileHandler )
]

Instance Method Summary collapse

Constructor Details

#initialize(include_defaults = true) ⇒ HandlerChains

Returns a new instance of HandlerChains.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/awestruct/handler_chains.rb', line 23

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

  # Register our sassc templates
  begin
    if require('sassc') || defined?(::Sassc)
      require 'awestruct/handlers/template/sassc'
      ::Tilt.register ::Awestruct::Tilt::SassSasscTemplate,'sass'
      ::Tilt.register ::Awestruct::Tilt::ScssSasscTemplate,'scss'
    end
  rescue LoadError
    # doesn't matter if we can't load it
  end
end

Instance Method Details

#<<(chain) ⇒ Object



43
44
45
46
# File 'lib/awestruct/handler_chains.rb', line 43

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

#[](path) ⇒ Object



39
40
41
# File 'lib/awestruct/handler_chains.rb', line 39

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