Sha256: efc960b1268a0d9316bed69c45eb9e90851d1e248e19e2ec5f6a510eee27ec14
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'sprockets' module Trackman module Assets module Components module Rails32PathResolver include PathResolver def translate url, parent_url root = working_dir.realpath path = url path.slice! /^(\/assets|assets\/)/ path = Pathname.new path if path.relative? folder = (root + Pathname.new(parent_url)).parent.realpath path = (folder + path).to_s path.slice! sprockets.paths.select{|p| path.include? p }.first end path = sprockets.resolve path path.relative_path_from(root).to_s end def sprockets @@sprockets ||= init_env end def init_env if defined?(::Rails) && ::Rails.application env = ::Rails.application.class.assets else env = ::Sprockets::Environment.new paths = ['app', 'lib', 'vendor'].inject([]) do |array, f| array + ["images", "stylesheets", "javascripts"].map{|p| "#{working_dir}/#{f}/assets/#{p}" } end paths << "#{working_dir}/public" paths.each{|p| env.append_path p } end env end def subfolder(file) if file.include?('.js') subfolder = "javascripts" elsif file.include?('.css') subfolder = "stylesheets" else subfolder = "images" end subfolder end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trackman-0.2.80 | lib/trackman/assets/components/rails32_path_resolver.rb |