Sha256: 61b180d1ec658f6509438f5c4da3a788c0b1785efbf774777653a224fdf47311
Contents?: true
Size: 1.58 KB
Versions: 4
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 # ensure these come first to avoid tilt warnings require 'compass' require 'sass' require 'coffee_script' # stdlib require 'base64' require 'escape_utils' require 'sinatra/base' require 'sprockets' # classy assets components require 'classy_assets/config' require 'classy_assets/errors/nil_asset_root' require 'classy_assets/sass/script/functions' require 'classy_assets/sprockets' require 'classy_assets/sprockets/sass_importer' require 'classy_assets/version' module ClassyAssets # singleton sprockets environment def self.sprockets ClassyAssets::Sprockets.instance.environment end # singleton configuration def self.config(&block) yield ClassyAssets::Config.instance if block_given? ClassyAssets::Config.instance end # utility methods def self.asset_url_for(asset) asset = sprockets[asset].send(determine_path_type) debug = (config.asset_debug) ? '?body=1' : '' "#{config.asset_host}/#{config.asset_prefix}/#{asset}#{debug}" end def self.asset_data_uri_for(asset) asset = sprockets[asset] base64 = Base64.encode64(asset.to_s).gsub(/\s+/, "") "data:#{asset.content_type};base64,#{EscapeUtils.escape_url(base64)}" end def self.asset_tag_from(sources, ext) sources = [sources] unless sources.is_a? Array sources.map do |source| source = "#{source}.#{ext}" unless source =~ /\.#{ext}$/ asset_url = (source =~ /\/|http/) ? source : asset_url_for(source) yield(asset_url) end.join('') end private def self.determine_path_type (config.asset_digest) ? :digest_path : :logical_path end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
classy_assets-0.7.0 | lib/classy_assets.rb |
classy_assets-0.6.3 | lib/classy_assets.rb |
classy_assets-0.6.2 | lib/classy_assets.rb |
classy_assets-0.6.1 | lib/classy_assets.rb |