class Roadie::FilesystemProvider
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.
Attributes
path[R]
Public Class Methods
new(path = Dir.pwd)
click to toggle source
# File lib/roadie/filesystem_provider.rb, line 13 def initialize(path = Dir.pwd) @path = path end
Public Instance Methods
find_stylesheet(name)
click to toggle source
@return [Stylesheet, nil]
# File lib/roadie/filesystem_provider.rb, line 18 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)
click to toggle source
@raise InsecurePathError @return [Stylesheet]
# File lib/roadie/filesystem_provider.rb, line 27 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(basename, %Q{#{file_path} does not exist. (Original name was "#{name}")}, self) end end
inspect()
click to toggle source
# File lib/roadie/filesystem_provider.rb, line 38 def inspect() "#<#{self.class} #@path>" end
to_s()
click to toggle source
# File lib/roadie/filesystem_provider.rb, line 37 def to_s() inspect end
Private Instance Methods
build_file_path(name)
click to toggle source
# File lib/roadie/filesystem_provider.rb, line 41 def build_file_path(name) raise InsecurePathError, name if name.include?("..") File.join(@path, name[/^([^?]+)/]) end