Sha256: 3d2eefc82b05a1bcf321c492d79307fd7e473abe95589031cc8515b7d6486ae6

Contents?: true

Size: 777 Bytes

Versions: 10

Compression:

Stored size: 777 Bytes

Contents

module Munge
  module Routers
    class RemoveIndexBasename
      def initialize(html_extensions:, index:)
        @html_extensions = html_extensions
        @index           = index
        @index_basename  = Munge::Util::Path.basename_no_extension(@index)
      end

      def type
        :route
      end

      def match?(initial_route, item)
        item_is_html?(item) && basename_is_index?(initial_route)
      end

      def call(initial_route, _item)
        Munge::Util::Path.dirname(initial_route)
      end

      private

      def item_is_html?(item)
        intersection = item.extensions & @html_extensions

        !intersection.empty?
      end

      def basename_is_index?(route)
        File.basename(route) == @index_basename
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
munge-0.14.0 lib/munge/routers/remove_index_basename.rb
munge-0.13.0 lib/munge/routers/remove_index_basename.rb
munge-0.12.0 lib/munge/routers/remove_index_basename.rb
munge-0.11.1 lib/munge/routers/remove_index_basename.rb
munge-0.11.0 lib/munge/routers/remove_index_basename.rb
munge-0.10.0 lib/munge/routers/remove_index_basename.rb
munge-0.9.0 lib/munge/routers/remove_index_basename.rb
munge-0.8.0 lib/munge/routers/remove_index_basename.rb
munge-0.7.1 lib/munge/routers/remove_index_basename.rb
munge-0.7.0 lib/munge/routers/remove_index_basename.rb