Sha256: e2c8e25900657f21a98ef24a0c54dfcc135a54ecb8abb7c5a82ed83fe1142e54

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 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.resources.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

1 entries across 1 versions & 1 rubygems

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