Module: Sprockets::Legacy

Included in:
Base
Defined in:
lib/sprockets/legacy.rb

Instance Method Summary collapse

Instance Method Details

#cache_get(key) ⇒ Object



56
57
58
# File 'lib/sprockets/legacy.rb', line 56

def cache_get(key)
  cache._get(key)
end

#cache_set(key, value) ⇒ Object



60
61
62
# File 'lib/sprockets/legacy.rb', line 60

def cache_set(key, value)
  cache._set(key, value)
end

#each_logical_path(*args, &block) ⇒ Object

Deprecated: Iterate over all logical paths with a matcher.

Remove from 4.x.

args - List of matcher objects.

Returns Enumerator if no block is given.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sprockets/legacy.rb', line 12

def each_logical_path(*args, &block)
  return to_enum(__method__, *args) unless block_given?

  filters = args.flatten.map { |arg| Manifest.compile_match_filter(arg) }
  logical_paths.each do |a, b|
    if filters.any? { |f| f.call(a, b) }
      if block.arity == 2
        yield a, b
      else
        yield a
      end
    end
  end

  nil
end

#logical_pathsObject

Deprecated: Enumerate over all logical paths in the environment.

Returns an Enumerator of [logical_path, filename].



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sprockets/legacy.rb', line 32

def logical_paths
  return to_enum(__method__) unless block_given?

  seen = Set.new

  self.paths.each do |load_path|
    stat_tree(load_path).each do |filename, stat|
      next unless stat.file?

      path = split_subpath(load_path, filename)
      path, mime_type, _ = parse_path_extnames(path)
      path = normalize_logical_path(path)
      path += mime_types[mime_type][:extensions].first if mime_type

      if !seen.include?(path)
        yield path, filename
        seen << path
      end
    end
  end

  nil
end