Class: Defmastership::Modifier::UpdateEref
- Inherits:
-
Object
- Object
- Defmastership::Modifier::UpdateEref
- Includes:
- ModifierCommon
- Defined in:
- lib/defmastership/modifier/update_eref_common.rb
Overview
Update external refs version
Direct Known Subclasses
Instance Attribute Summary
Attributes included from ModifierCommon
Class Method Summary collapse
-
.default_config ⇒ Hash{Symbol => Object}
The default configuration.
Instance Method Summary collapse
-
#do_modifications(adoc_sources) ⇒ Object
Apply the modifier on all provided asciidoc sources based on modifier’s
self.replacement_methodslist. -
#initialize(config) ⇒ UpdateEref
constructor
A new instance of UpdateEref.
-
#replace_erefs(_filename, line) ⇒ String
Replace the definition’s external ref in the line if relevant.
Methods included from ModifierCommon
#method_missing, #respond_to_missing?, #setup_modifier_module
Constructor Details
#initialize(config) ⇒ UpdateEref
Returns a new instance of UpdateEref.
23 24 25 26 27 |
# File 'lib/defmastership/modifier/update_eref_common.rb', line 23 def initialize(config) @the_ref_document = Document.new setup_modifier_module(config) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Defmastership::Modifier::ModifierCommon
Class Method Details
.default_config ⇒ Hash{Symbol => Object}
Returns the default configuration.
15 16 17 18 19 20 |
# File 'lib/defmastership/modifier/update_eref_common.rb', line 15 def self.default_config { eref_type: '', ref_document: '' } 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
35 36 37 38 39 |
# File 'lib/defmastership/modifier/update_eref_common.rb', line 35 def do_modifications(adoc_sources) Array(ref_document).each { |ref_doc| the_ref_document.parse_file_with_preprocessor(ref_doc) } super end |
#replace_erefs(_filename, line) ⇒ String
Replace the definition’s external ref in the line if relevant
46 47 48 49 50 51 52 53 |
# File 'lib/defmastership/modifier/update_eref_common.rb', line 46 def replace_erefs(_filename, line) match = line.match(Core::DMRegexp::EREF_DEF) # Return early if there's no match or the type is not valid return line unless match && eref_type_valid?(match[:reference]) # Delegate the actual replacement to a separate method perform_replacement(line, match[:extrefs]) end |