Sha256: 6984843dd42f481a4b2fdc6fb81fe1db596595b3f859968e1313ec257a0f9de1

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

require 'rack/test'

module Sinatra
  module AssetPack
    def self.registered(app)
      app.helpers Helpers
    end

    # Returns a list of formats that can be served.
    # Anything not in this list will be rejected.
    def self.supported_formats
      @supported_formats ||= %w(css js png jpg gif svg otf eot ttf woff htc)
    end

    # Returns a map of what MIME format each Tilt type returns.
    def self.tilt_formats
      @formats ||= begin
        hash = Hash.new
        Tilt.mappings.each do |format, (engine, _)|
          case engine.default_mime_type
          when 'text/css' then hash[format] = 'css'
          when 'application/javascript' then hash[format] = 'js'
          end
        end

        hash
      end
    end

    # Returns the inverse of tilt_formats.
    def self.tilt_formats_reverse
      re = Hash.new { |h, k| h[k] = Array.new }
      formats.each { |tilt, out| re[out] << tilt }
      out
    end

    PREFIX = File.dirname(__FILE__)

    autoload :ClassMethods,  "#{PREFIX}/assetpack/class_methods"
    autoload :Options,       "#{PREFIX}/assetpack/options"
    autoload :Helpers,       "#{PREFIX}/assetpack/helpers"
    autoload :HtmlHelpers,   "#{PREFIX}/assetpack/html_helpers"
    autoload :BusterHelpers, "#{PREFIX}/assetpack/buster_helpers"
    autoload :Engine,        "#{PREFIX}/assetpack/engine"
    autoload :Package,       "#{PREFIX}/assetpack/package"
    autoload :Compressor,    "#{PREFIX}/assetpack/compressor"
    autoload :Image,         "#{PREFIX}/assetpack/image"
    autoload :Css,           "#{PREFIX}/assetpack/css"
    autoload :Configurator,  "#{PREFIX}/assetpack/configurator"
    autoload :HashArray,     "#{PREFIX}/assetpack/hasharray"

    include ClassMethods

    Error = Class.new(StandardError)

    require "#{PREFIX}/assetpack/version"
  end

  # Autoload in Sinatra classic mode
  register AssetPack
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
sinatra-assetpack-0.1.2 lib/sinatra/assetpack.rb
sinatra-assetpack-0.1.1 lib/sinatra/assetpack.rb
sinatra-assetpack-0.1.0 lib/sinatra/assetpack.rb
sinatra-assetpack-flexible-compression-0.0.1 lib/sinatra/assetpack.rb
sundawg-sinatra-assetpack-fork-0.0.12.pre1 lib/sinatra/assetpack.rb
sinatra-assetpack-0.0.12.pre1 lib/sinatra/assetpack.rb
sinatra-assetpack-0.0.11 lib/sinatra/assetpack.rb