Module: Sinatra::AssetPack

Includes:
ClassMethods
Defined in:
lib/sinatra/assetpack.rb,
lib/sinatra/assetpack/css.rb,
lib/sinatra/assetpack/image.rb,
lib/sinatra/assetpack/engine.rb,
lib/sinatra/assetpack/builder.rb,
lib/sinatra/assetpack/helpers.rb,
lib/sinatra/assetpack/options.rb,
lib/sinatra/assetpack/package.rb,
lib/sinatra/assetpack/version.rb,
lib/sinatra/assetpack/compressor.rb,
lib/sinatra/assetpack/engines/yui.rb,
lib/sinatra/assetpack/configurator.rb,
lib/sinatra/assetpack/engines/less.rb,
lib/sinatra/assetpack/engines/none.rb,
lib/sinatra/assetpack/engines/sass.rb,
lib/sinatra/assetpack/html_helpers.rb,
lib/sinatra/assetpack/class_methods.rb,
lib/sinatra/assetpack/engines/jsmin.rb,
lib/sinatra/assetpack/buster_helpers.rb,
lib/sinatra/assetpack/engines/simple.rb,
lib/sinatra/assetpack/engines/sqwish.rb,
lib/sinatra/assetpack/engines/uglify.rb,
lib/sinatra/assetpack/engines/closure.rb

Defined Under Namespace

Modules: Builder, BusterHelpers, ClassMethods, Compressor, Configurator, Css, Helpers, HtmlHelpers Classes: ClosureEngine, Engine, Image, JsminEngine, LessEngine, NoneEngine, Options, Package, SassEngine, SimpleEngine, SqwishEngine, UglifyEngine, YuiEngine

Constant Summary collapse

PREFIX =
File.dirname(__FILE__)
Error =
Class.new(StandardError)
VERSION =
"0.3.5"

Class Method Summary collapse

Methods included from ClassMethods

#add_compressed_routes!, #add_individual_routes!, #assets, #assets_initialize!

Class Method Details

.clear_tilt_cache!(cache, app) ⇒ Object

Clear Tilt::Cache (used primarily for tests)



42
43
44
45
# File 'lib/sinatra/assetpack.rb', line 42

def self.clear_tilt_cache!(cache, app)
  cache.clear
  #app.clear_tilt_cache = false  # Maybe it can be an option on app we can enable/disable?
end

.registered(app) ⇒ Object



6
7
8
# File 'lib/sinatra/assetpack.rb', line 6

def self.registered(app)
  app.helpers Helpers
end

.supported_formatsObject

Returns a list of formats that can be served. Anything not in this list will be rejected.



12
13
14
# File 'lib/sinatra/assetpack.rb', line 12

def self.supported_formats
  @supported_formats ||= %w(css js png jpg gif svg otf eot ttf woff woff2 htc ico)
end

.tilt_formatsObject

Returns a map of what MIME format each Tilt type returns.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sinatra/assetpack.rb', line 17

def self.tilt_formats
  @formats ||= begin
    hash = Hash.new
    Tilt.mappings.each do |format, (engine, _)|
      # @todo Remove when fix is merged in tilt
      # https://github.com/rtomayko/tilt/pull/206
      next if engine.nil? 
      case engine.default_mime_type
      when 'text/css' then hash[format] = 'css'
      when 'application/javascript' then hash[format] = 'js'
      end
    end

    hash
  end
end

.tilt_formats_reverseObject

Returns the inverse of tilt_formats.



35
36
37
38
39
# File 'lib/sinatra/assetpack.rb', line 35

def self.tilt_formats_reverse
  re = Hash.new { |h, k| h[k] = Array.new }
  formats.each { |tilt, out| re[out] << tilt }
  out
end

.versionObject

Deprecated.

Please use AssetPack::VERSION instead



6
7
8
# File 'lib/sinatra/assetpack/version.rb', line 6

def self.version
  VERSION
end