Class: Defmastership::Modifier::UpdateDefVersion

Inherits:
UpdateDef
  • Object
show all
Defined in:
lib/defmastership/modifier/update_def_version.rb

Overview

modify one line after another

Defined Under Namespace

Modules: Helper

Instance Attribute Summary

Attributes inherited from UpdateDef

#document

Attributes included from ModifierCommon

#changes, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UpdateDef

reference_regexp, #replace_reference, replacement_methods

Methods included from ModifierCommon

#method_missing, #respond_to_missing?, #setup_modifier_module

Constructor Details

#initialize(config) ⇒ UpdateDefVersion

Returns a new instance of UpdateDefVersion.

Parameters:

  • config (YAML)

    the modifier’s provided configurations



24
25
26
27
28
29
30
# File 'lib/defmastership/modifier/update_def_version.rb', line 24

def initialize(config)
  @ref_document = Document.new

  Helper.normalilize_config!(config) if config.key?(:ref_document)

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Defmastership::Modifier::ModifierCommon

Class Method Details

.default_configHash{Symbol => Object}

Returns the default configuration.

Returns:

  • (Hash{Symbol => Object})

    the default configuration



13
14
15
16
17
18
19
20
21
# File 'lib/defmastership/modifier/update_def_version.rb', line 13

def self.default_config
  {
    def_type: '',
    ref_document: [],
    ref_tag: '',
    ref_repo: '.',
    first_version: ''
  }
end

Instance Method Details

#do_modifications(adoc_sources) ⇒ Object

Apply the modifier on all provided asciidoc sources based on modifier’s self.replacement_methods list

Parameters:

  • adoc_sources (Hash{String => String})

    asciidoc sources

    • :key filename

    • :value file content



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/defmastership/modifier/update_def_version.rb', line 38

def do_modifications(adoc_sources)
  if ref_tag == ''
    ref_document.each { |ref_doc| @ref_document.parse_file_with_preprocessor(ref_doc) }
  else
    Dir.mktmpdir('defmastership') do |tmpdir|
      parse_ref_files_from_git(adoc_sources, tmpdir)
    end
  end

  super
end