Sha256: fe005797091a7de63b6de58e9fbb931feb694640a209b38662f2bd527ba42f5f
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 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/ 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 ::Rails puts 'A rails env exists, loading it' env = ::Rails.application.config.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 } 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.61 | lib/trackman/assets/components/rails32_path_resolver.rb |