Sha256: 24a041a52c336fd4825afc73532c2e4c91bb0c27125be317deb04864fe8e6f20

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'awestruct/handler_chain'
require 'awestruct/handlers/file_handler'
require 'awestruct/handlers/markdown_handler'
require 'awestruct/handlers/orgmode_handler'
require 'awestruct/handlers/asciidoc_handler'
require 'awestruct/handlers/restructuredtext_handler'
require 'awestruct/handlers/textile_handler'
require 'awestruct/handlers/erb_handler'
require 'awestruct/handlers/haml_handler'
require 'awestruct/handlers/mustache_handler'
require 'awestruct/handlers/sass_handler'
require 'awestruct/handlers/scss_handler'
require 'awestruct/handlers/less_handler'
require 'awestruct/handlers/javascript_handler'
require 'awestruct/handlers/coffeescript_handler'
require 'awestruct/handlers/redirect_handler'

module Awestruct

  class HandlerChains

    DEFAULTS = [
      Awestruct::Handlers::MarkdownHandler::CHAIN,
      Awestruct::Handlers::TextileHandler::CHAIN,
      Awestruct::Handlers::ErbHandler::CHAIN,
      Awestruct::Handlers::OrgmodeHandler::CHAIN,
      Awestruct::Handlers::AsciidocHandler::CHAIN,
      Awestruct::Handlers::RestructuredtextHandler::CHAIN,
      Awestruct::Handlers::HamlHandler::CHAIN,
      Awestruct::Handlers::MustacheHandler::CHAIN,      
      Awestruct::Handlers::SassHandler::CHAIN,
      Awestruct::Handlers::ScssHandler::CHAIN,
      Awestruct::Handlers::LessHandler::CHAIN,
      Awestruct::Handlers::JavascriptHandler::CHAIN,
      Awestruct::Handlers::CoffeescriptHandler::CHAIN,
      Awestruct::Handlers::RedirectHandler::CHAIN,
      HandlerChain.new( /.*/, Awestruct::Handlers::FileHandler )
    ]

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

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

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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awestruct-0.4.8 lib/awestruct/handler_chains.rb