Class: Roadie::AssetProvider Abstract
- Inherits:
-
Object
- Object
- Roadie::AssetProvider
- Defined in:
- lib/roadie/asset_provider.rb
Overview
Subclass to create your own providers
Direct Known Subclasses
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
The prefix is whatever is prepended to your stylesheets when referenced inside markup.
Instance Method Summary collapse
-
#all(files) ⇒ Object
Iterates all the passed elements and calls #find on them, joining the results with a newline.
-
#find(name) ⇒ Object
abstract
Return the CSS contents of the file specified.
-
#initialize(prefix = "/assets") ⇒ AssetProvider
constructor
A new instance of AssetProvider.
Constructor Details
#initialize(prefix = "/assets") ⇒ AssetProvider
Returns a new instance of AssetProvider.
14 15 16 17 |
# File 'lib/roadie/asset_provider.rb', line 14 def initialize(prefix = "/assets") @prefix = prefix @quoted_prefix = prepare_prefix(prefix) end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
The prefix is whatever is prepended to your stylesheets when referenced inside markup.
The prefix is stripped away from any URLs before they are looked up in #find:
find("/assets/posts/comment.css")
# Same as: (if prefix == "/assets"
find("posts/comment.css")
10 11 12 |
# File 'lib/roadie/asset_provider.rb', line 10 def prefix @prefix end |
Instance Method Details
#all(files) ⇒ Object
Iterates all the passed elements and calls #find on them, joining the results with a newline.
27 28 29 |
# File 'lib/roadie/asset_provider.rb', line 27 def all(files) files.map { |file| find(file) }.join("\n") end |
#find(name) ⇒ Object
Implement in your own subclass
Return the CSS contents of the file specified. A provider should not care about the .css
extension; it can, however, behave differently if it’s passed or not.
If the asset cannot be found, the method should raise CSSFileNotFound.
45 46 47 |
# File 'lib/roadie/asset_provider.rb', line 45 def find(name) raise "Not implemented" end |