Class: Roadie::FilesystemProvider

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(path = Dir.pwd) ⇒ FilesystemProvider

Returns a new instance of FilesystemProvider.



13
14
15
# File 'lib/roadie/filesystem_provider.rb', line 13

def initialize(path = Dir.pwd)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/roadie/filesystem_provider.rb', line 11

def path
  @path
end

Instance Method Details

#find_stylesheet(name) ⇒ Stylesheet?

Returns:



18
19
20
21
22
23
# 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) ⇒ Stylesheet

Returns:

Raises:

  • InsecurePathError



27
28
29
30
31
32
33
34
35
# 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, %{#{file_path} does not exist. (Original name was "#{name}")}, self)
  end
end

#inspectObject



38
# File 'lib/roadie/filesystem_provider.rb', line 38

def inspect() "#<#{self.class} #@path>" end

#to_sObject



37
# File 'lib/roadie/filesystem_provider.rb', line 37

def to_s() inspect end