Sha256: 0d46eef373e50b945908a32956a7b83f538a72e8d97dff0e19427d1b5ecebb75
Contents?: true
Size: 794 Bytes
Versions: 2
Compression:
Stored size: 794 Bytes
Contents
module Sinatra module AssetPack module Css def self.preproc(str, assets) str.gsub(/url\(["']?(.*?)["']?\)/) { |url| file, options = $1.split('?') local = assets.local_file_for file url = if local if options.to_s.include?('embed') to_data_uri(local) else BusterHelpers.add_cache_buster(file, local) end else url end "url(#{url})" } end def self.to_data_uri(file) require 'base64' data = File.read(file) ext = File.extname(file) mime = Sinatra::Base.mime_type(ext) b64 = Base64.encode64(data).gsub("\n", '') "data:#{mime};base64,#{b64}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-assetpack-0.0.6 | lib/sinatra/assetpack/css.rb |
sinatra-assetpack-0.0.5 | lib/sinatra/assetpack/css.rb |