Class: Propshaft::Resolver::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/propshaft/resolver/static.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest_path:, prefix:) ⇒ Static

Returns a new instance of Static.



5
6
7
# File 'lib/propshaft/resolver/static.rb', line 5

def initialize(manifest_path:, prefix:)
  @manifest_path, @prefix = manifest_path, prefix
end

Instance Attribute Details

#manifest_pathObject (readonly)

Returns the value of attribute manifest_path.



3
4
5
# File 'lib/propshaft/resolver/static.rb', line 3

def manifest_path
  @manifest_path
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/propshaft/resolver/static.rb', line 3

def prefix
  @prefix
end

Instance Method Details

#read(logical_path, encoding: "ASCII-8BIT") ⇒ Object



15
16
17
18
19
# File 'lib/propshaft/resolver/static.rb', line 15

def read(logical_path, encoding: "ASCII-8BIT")
  if asset_path = parsed_manifest[logical_path]
    File.read(manifest_path.dirname.join(asset_path), encoding: encoding)
  end
end

#resolve(logical_path) ⇒ Object



9
10
11
12
13
# File 'lib/propshaft/resolver/static.rb', line 9

def resolve(logical_path)
  if asset_path = parsed_manifest[logical_path]
    File.join prefix, asset_path
  end
end