8bb51f0227
Following Bundler's lead, use loaded_specs api to look for possible javascript / stylesheets to inform Sprockets of in jasmine-headless-webkit.
46 lines
955 B
Ruby
46 lines
955 B
Ruby
require 'sprockets'
|
|
require 'rubygems'
|
|
|
|
module ::Sprockets
|
|
def self.find_gem_vendor_paths(options = {})
|
|
options = { :paths => %w{vendor lib app} }.merge(options)
|
|
|
|
for_types = [ options[:for] || [ 'javascripts', 'stylesheets' ] ].flatten
|
|
|
|
paths = []
|
|
|
|
GemEnvironment.each do |gemspec|
|
|
options[:paths].product(for_types).each do |base_dir, type|
|
|
path = File.join(gemspec.gem_dir, base_dir, "assets", type.to_s)
|
|
|
|
paths << path if File.directory?(path)
|
|
end
|
|
end
|
|
|
|
paths
|
|
end
|
|
|
|
class EnvironmentWithVendoredGems < Environment
|
|
def initialize(*args)
|
|
super(*args)
|
|
|
|
Sprockets.find_gem_vendor_paths.each { |path| append_path(path) }
|
|
end
|
|
end
|
|
|
|
class GemEnvironment
|
|
extend Enumerable
|
|
|
|
def self.gemspecs
|
|
Gem.loaded_specs.map(&:last)
|
|
end
|
|
|
|
def self.each(&block)
|
|
return enum_for(:each) unless block_given?
|
|
|
|
gemspecs.each {|spec| yield spec }
|
|
end
|
|
end
|
|
end
|
|
|