Sha256: cc32aa6f1c517f787a55b90b093821546cdc364cc530b377f0f1d374ca5b20e2

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 KB

Contents

module Sitepress
  module BuildPaths
    # Compiles pages directly from `/pages/blah.html.haml` to `/blah.html`. Handles root `index`
    # pages too, mainly grabbing the root, which doesn't have a name in the node, to the default_name
    # of the node, which is usually `index`.
    class RootPath
      attr_reader :resource

      extend Forwardable
      def_delegators :resource, :node, :format

      def initialize(resource)
        @resource = resource
      end

      def filename
        if format.nil?
          filename_without_format
        elsif format == node.default_format
          filename_with_default_format
        elsif format
          filename_with_format
        end
      end

      def path
        File.join(*resource.lineage, filename)
      end

      protected
      def filename_without_format
        node.default_name
      end

      def filename_with_format
        "#{node.default_name}.#{format}"
      end

      def filename_with_default_format
        filename_with_format
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
sitepress-rails-4.0.8 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.7 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.6 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.5 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.4 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.3 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.2 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.1 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.0 lib/sitepress/build_paths/root_path.rb
sitepress-rails-4.0.0.beta1 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.2.2 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.2.1 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.2.0 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.1.4 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.1.3 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.1.2 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.1.1 lib/sitepress/build_paths/root_path.rb
sitepress-rails-3.0.1 lib/sitepress/build_paths/root_path.rb
sitepress-rails-2.0.0 lib/sitepress/build_paths/root_path.rb
sitepress-rails-2.0.0.beta11 lib/sitepress/build_paths/root_path.rb