Class: Roadie::FilesystemProvider

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



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

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#find_stylesheet(name) ⇒ Stylesheet?

Returns:



19
20
21
22
23
24
# File 'lib/roadie/filesystem_provider.rb', line 19

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



28
29
30
31
32
33
34
35
36
# File 'lib/roadie/filesystem_provider.rb', line 28

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