Class: Middleman::Sprockets::ImportedAsset
- Inherits:
-
Object
- Object
- Middleman::Sprockets::ImportedAsset
- Defined in:
- lib/middleman-sprockets/imported_asset.rb
Overview
ImportedAsset
Instance Attribute Summary collapse
-
#logical_path ⇒ Object
readonly
Returns the value of attribute logical_path.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#real_path ⇒ Object
readonly
Returns the value of attribute real_path.
Instance Method Summary collapse
-
#initialize(logical_path, determine_output_path = proc { nil }) ⇒ ImportedAsset
constructor
Create instance.
-
#match?(path) ⇒ Boolean
Does the given patch matches asset.
-
#resolve_path_with(resolver) ⇒ Object
Resolve logical path to real path.
-
#to_s ⇒ String
String representation of asset.
Constructor Details
#initialize(logical_path, determine_output_path = proc { nil }) ⇒ ImportedAsset
Create instance
15 16 17 18 19 20 21 22 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 15 def initialize(logical_path, determine_output_path = proc { nil }) @logical_path = Pathname.new(logical_path) @output_path = if output_path = determine_output_path.call(@logical_path) Pathname.new(output_path) else nil end end |
Instance Attribute Details
#logical_path ⇒ Object (readonly)
Returns the value of attribute logical_path.
6 7 8 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 6 def logical_path @logical_path end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
6 7 8 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 6 def output_path @output_path end |
#real_path ⇒ Object (readonly)
Returns the value of attribute real_path.
6 7 8 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 6 def real_path @real_path end |
Instance Method Details
#match?(path) ⇒ Boolean
Does the given patch matches asset
46 47 48 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 46 def match?(path) has_real_path? path end |
#resolve_path_with(resolver) ⇒ Object
Resolve logical path to real path
28 29 30 31 32 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 28 def resolve_path_with(resolver) @real_path = resolver.resolve(logical_path) raise ::Sprockets::FileNotFound, "Couldn't find asset '#{logical_path}'" if real_path == nil || real_path == '' end |
#to_s ⇒ String
String representation of asset
38 39 40 |
# File 'lib/middleman-sprockets/imported_asset.rb', line 38 def to_s logical_path.to_s end |