Sha256: 6543105ec326c3eb4e3f1b60416b92f026f23b35f4b6267df09cb52760616971
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 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 puts "RESOLVED PATH #{path.to_s}" 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 env.append_path "#{working_dir}/public" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trackman-0.2.84 | lib/trackman/assets/components/rails32_path_resolver.rb |
trackman-0.2.82 | lib/trackman/assets/components/rails32_path_resolver.rb |