module Compass::SassExtensions::Functions::Urls
Public Class Methods
has?(base, instance_method)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 4 def self.has?(base, instance_method) Sass::Util.has?(:instance_method, base, instance_method) end
included(base)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 8 def self.included(base) base.send(:include, StylesheetUrl) unless has?(base, :stylesheet_url) base.send(:include, FontUrl) unless has?(base, :font_url) base.send(:include, ImageUrl) unless has?(base, :image_url) base.send(:include, GeneratedImageUrl) unless has?(base, :generated_image_url) end
Private Instance Methods
absolute_path?(path)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 219 def absolute_path?(path) path[0..0] == "/" || path[0..3] == "http" end
cache_busted_path(path, real_path)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 229 def cache_busted_path(path, real_path) cache_buster = compute_cache_buster(path, real_path) if cache_buster.nil? return path elsif cache_buster.is_a?(String) cache_buster = {:query => cache_buster} else path = cache_buster[:path] if cache_buster[:path] end if cache_buster[:query] "%s?%s" % [path, cache_buster[:query]] else path end end
clean_path(url)
click to toggle source
Emits a path, taking off any leading “./”
# File lib/compass/sass_extensions/functions/urls.rb, line 205 def clean_path(url) url = url.to_s url = url[0..1] == "./" ? url[2..-1] : url end
clean_url(url)
click to toggle source
Emits a url, taking off any leading “./”
# File lib/compass/sass_extensions/functions/urls.rb, line 211 def clean_url(url) Sass::Script::String.new("url('#{clean_path(url)}')") end
compute_cache_buster(path, real_path)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 246 def compute_cache_buster(path, real_path) if Compass.configuration.asset_cache_buster args = [path] if Compass.configuration.asset_cache_buster.arity > 1 args << (File.new(real_path) if real_path) end Compass.configuration.asset_cache_buster.call(*args) elsif real_path default_cache_buster(path, real_path) end end
compute_relative_path(path)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 223 def compute_relative_path(path) if (target_css_file = options[:css_filename]) Pathname.new(path).relative_path_from(Pathname.new(File.dirname(target_css_file))).to_s end end
default_cache_buster(path, real_path)
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 258 def default_cache_buster(path, real_path) if File.readable?(real_path) File.mtime(real_path).to_i.to_s else $stderr.puts "WARNING: '#{File.basename(path)}' was not found (or cannot be read) in #{File.dirname(real_path)}" end end
relative?()
click to toggle source
# File lib/compass/sass_extensions/functions/urls.rb, line 215 def relative? Compass.configuration.relative_assets? end