Sha256: 6681099e3f3fd2ff1ad2e3378b02bbd9f64155eecffd52398cecb5a4ee4cd8a2

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

module Mascot
  module Extensions
    # Removes files beginning with "_" from the resource collection.
    class IndexRequestPath
      # Name of the file that we'll want to change to a / path
      FILE_NAME = "index.html".freeze

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

      def process_resources(node)
        node.each do |r|
          asset = r.asset
          if asset.path.basename.to_s.start_with? @file_name
            request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s
            node.remove_resource(r)
            node.add(path: request_path, asset: asset)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mascot-rails-0.1.12 lib/mascot/extensions/index_request_path.rb