Sha256: dfba43330d6ae82b8677928d95fe7b5fefbe010e259e669eb07eb43cd61a5785

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 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.flatten.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.formats.remove(r)
            node.add(path: request_path, asset: asset)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mascot-rails-0.1.16 lib/mascot/extensions/index_request_path.rb
mascot-rails-0.1.15 lib/mascot/extensions/index_request_path.rb