Class: Mascot::Extensions::IndexRequestPath

Inherits:
Object
  • Object
show all
Defined in:
lib/mascot/extensions/index_request_path.rb

Overview

Removes files beginning with “_” from the resource collection.

Constant Summary collapse

FILE_NAME =

Name of the file that we’ll want to change to a / path

"index.html".freeze

Instance Method Summary collapse

Constructor Details

#initialize(file_name: FILE_NAME) ⇒ IndexRequestPath

Returns a new instance of IndexRequestPath.



8
9
10
# File 'lib/mascot/extensions/index_request_path.rb', line 8

def initialize(file_name: FILE_NAME)
  @file_name = file_name
end

Instance Method Details

#process_resources(resources) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/mascot/extensions/index_request_path.rb', line 12

def process_resources(resources)
  resources.each do |r|
    if r.asset.path.basename.to_s.start_with? @file_name
      # TODO: Conslidate this into SafeRoot.
      r.request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s
    end
  end
end