Module: Sprockets::GemPaths

Defined in:
lib/sprockets/gem_paths.rb,
lib/sprockets/gem_paths/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rubygems_latest_specsObject



5
6
7
8
9
10
11
12
# File 'lib/sprockets/gem_paths.rb', line 5

def self.rubygems_latest_specs
  # If newer Rubygems
  if ::Gem::Specification.respond_to? :latest_specs
    ::Gem::Specification.latest_specs
  else
    ::Gem.source_index.latest_specs
  end
end

Instance Method Details

#append_gem_pathsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sprockets/gem_paths.rb', line 14

def append_gem_paths
  try_paths = [
    %w{ assets },
    %w{ app },
    %w{ app assets },
    %w{ vendor },
    %w{ vendor assets },
    %w{ lib },
    %w{ lib assets }
  ].inject([]) do |sum, v|
    sum + [
      File.join(v, 'javascripts'),
      File.join(v, 'stylesheets'),
      File.join(v, 'images'),
      File.join(v, 'fonts')
    ]
  end

  (Sprockets::GemPaths.rubygems_latest_specs.map(&:full_gem_path)).each do |root_path|
    try_paths.map {|p| File.join(root_path, p) }.
      select {|p| File.directory?(p) }.
      each {|path| append_path(path) }
  end
end