Sha256: 1d13fcfaef264043870619a7ae56e58210bcac54d93dc0a3591a9df495a4c245

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'asciidoctor'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacAsciidoctorBase0
    module Sources
      class Document
        enable_simple_cache
        enable_speaker
        require_sub __FILE__, include_modules: true
        common_constructor :source, :parent_document, :basename

        # Absolute path to the Asciidoctor file.
        #
        # @return [Pathname]
        def body_path
          root_path.join(
            ::Avm::EacAsciidoctorBase0::Sources::Base::CONTENT_DOCUMENT_BASENAME
          )
        end

        # @return [Avm::EacAsciidoctorBase0::Instances::Build::Document]
        def build_document
          source.build.document(subpath)
        end

        # Absolute path to the document's source root.
        #
        # @return [Pathname]
        def root_path
          source.content_directory.join(subpath)
        end

        # @return [Pathname]
        def subpath
          parent_document.if_present('.'.to_pathname) { |pd| pd.subpath.join(basename) }
        end

        # @return [String]
        def to_s
          subpath.to_path
        end

        private

        def children_uncached
          root_path.children.select(&:directory?)
            .reject { |path| path.basename.to_path == MEDIA_DIRECTORY_BASENAME }
            .map { |path| self.class.new(source, self, path.basename) }
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
avm-eac_asciidoctor_base0-0.25.0 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.97.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
avm-eac_asciidoctor_base0-0.24.0 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.96.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
avm-eac_asciidoctor_base0-0.23.0 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.88.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.87.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
avm-eac_asciidoctor_base0-0.22.1 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.86.13 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
avm-eac_asciidoctor_base0-0.22.0 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.85.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.84.2 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.84.1 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb
avm-eac_asciidoctor_base0-0.21.0 lib/avm/eac_asciidoctor_base0/sources/document.rb
eac_tools-0.84.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/document.rb