Sha256: 19917e293c111efe5384cf1b108cca070eb65d9b1cb3fae9ea9015ef1015e197

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

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

module DefMastership
  # Change all refs of a given project
  class ProjectRefChanger
    attr_reader :yaml_config, :adoc_texts, :changes

    def initialize(yaml_config, adoc_texts)
      @yaml_config = yaml_config
      @adoc_texts = adoc_texts
    end

    def replace_all
      batch = BatchChanger.from_h(@yaml_config)

      @adoc_texts =
        %i[refdef irefs].reduce(@adoc_texts) do |texts, method|
          texts.transform_values do |text|
            text.lines.map { |line| batch.replace(method, line) }.join
          end
        end

      @yaml_config = batch.to_h.to_yaml
      @changes = batch.changes
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defmastership-1.0.5 lib/defmastership/project_ref_changer.rb
defmastership-1.0.4 lib/defmastership/project_ref_changer.rb