Class: Roadie::FilesystemProvider
- Inherits:
-
Object
- Object
- Roadie::FilesystemProvider
- Defined in:
- lib/roadie/filesystem_provider.rb
Overview
Asset provider that looks for files on your local filesystem.
It will be locked to a specific path and it will not access files above that directory.
Defined Under Namespace
Classes: InsecurePathError
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #find_stylesheet(name) ⇒ Stylesheet?
- #find_stylesheet!(name) ⇒ Stylesheet
-
#initialize(path = Dir.pwd) ⇒ FilesystemProvider
constructor
A new instance of FilesystemProvider.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path = Dir.pwd) ⇒ FilesystemProvider
Returns a new instance of FilesystemProvider.
15 16 17 |
# File 'lib/roadie/filesystem_provider.rb', line 15 def initialize(path = Dir.pwd) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/roadie/filesystem_provider.rb', line 13 def path @path end |
Instance Method Details
#find_stylesheet(name) ⇒ Stylesheet?
20 21 22 23 24 25 |
# File 'lib/roadie/filesystem_provider.rb', line 20 def find_stylesheet(name) file_path = build_file_path(name) if File.exist? file_path Stylesheet.new file_path, File.read(file_path) end end |
#find_stylesheet!(name) ⇒ Stylesheet
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/roadie/filesystem_provider.rb', line 29 def find_stylesheet!(name) file_path = build_file_path(name) if File.exist? file_path Stylesheet.new file_path, File.read(file_path) else basename = File.basename file_path raise CssNotFound.new( css_name: basename, message: %{#{file_path} does not exist. (Original name was "#{name}")}, provider: self ) end end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/roadie/filesystem_provider.rb', line 47 def inspect "#<#{self.class} #{@path}>" end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/roadie/filesystem_provider.rb', line 43 def to_s inspect end |