Sha256: ecce9423afc1c912fad3d8bd8ca101c7919c0727fb3180ac3d77e188b9fea24a

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

# Copyright (c) 2020 Jerome Arbez-Gindre
# frozen_string_literal: true

module DefMastership
  # Change references from temporary to definitive with multiple RefChangers
  class ModifierBase
    attr_reader :config, :changes

    def initialize(config)
      @config = config
      @changes = []
    end

    def do_modifications(adoc_texts)
      line_modifier = new_line_modifier(@config, adoc_texts)

      adoc_texts =
        replacements.reduce(adoc_texts) do |texts, method|
          transform_values(texts, line_modifier, method)
        end

      @config = line_modifier.config
      @changes = line_modifier.changes
      adoc_texts
    end

    private

    def transform_values(texts, line_modifier, method)
      texts.transform_values do |text|
        text.lines.map { |line| line_modifier.public_send(method, line) }
            .join
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
defmastership-1.0.17 lib/defmastership/modifier_base.rb