Sha256: 47ae487daf6927e70ccd849b834557f0c8f25fdaf97863e0a5172ec428f613a0

Contents?: true

Size: 1.96 KB

Versions: 30

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module EacAsciidoctorBase0
    module Instances
      class Build
        class Document
          class HeaderMacroValue
            enable_method_class
            enable_settings_provider
            enable_simple_cache
            common_constructor :document

            delegate :build, :source_document, to: :document
            delegate :instance, to: :build
            delegate :author_email, :author_name, to: :instance

            ATTRIBUTES = ['Author Initials', 'toc', 'icons', 'numbered', 'website'].freeze
            TOC = 'left'
            ICONS = ''
            NUMBERED = ''

            # @return [String]
            def attribute_line(name, value)
              [":#{name}:", value].reject(&:blank?).join(' ')
            end

            def attributes_lines
              ATTRIBUTES.map { |attr| attribute_line(attr, attribute_value(attr)) }
            end

            def attribute_value(attr)
              setting_value(attr.variableize)
            end

            def author_initials
              instance.author_name_initials
            end

            def author_line
              "#{author_name} <#{author_email}>"
            end

            # @return [Array<String>]
            def result
              [stylesheet_line, title_line, author_line] + attributes_lines
            end

            # @return [String]
            def stylesheet_line
              attribute_line('stylesheet', stylesheet_path)
            end

            # @return [Pathname]
            def stylesheet_path
              source_document.source.theme_stylesheet_path
                             .relative_path_from(document.convert_base_dir)
            end

            # @return [String]
            def title_line
              "= #{source_document.title}"
            end

            def website
              instance.web_url
            end
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
eac_tools-0.56.1 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.56.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.7 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.6 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.5 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.4 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.3 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.2 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.1 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.55.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.54.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
avm-eac_asciidoctor_base0-0.15.0 lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.53.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
avm-eac_asciidoctor_base0-0.14.0 lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.52.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.51.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.50.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.49.0 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
eac_tools-0.48.1 sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb
avm-eac_asciidoctor_base0-0.13.0 lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb