Class: Stepmod::Utils::ChangesExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/stepmod/utils/changes_extractor.rb

Constant Summary collapse

MODULE_TYPES =
%w[arm mim arm_longform mim_longform].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stepmod_dir:, stdout: $stdout) ⇒ ChangesExtractor

Returns a new instance of ChangesExtractor.



17
18
19
20
21
22
23
# File 'lib/stepmod/utils/changes_extractor.rb', line 17

def initialize(stepmod_dir:, stdout: $stdout)
  @stdout = stdout
  @stepmod_dir = stepmod_dir
  @collection = Stepmod::Utils::ChangeCollection.new(
    stepmod_dir: stepmod_dir,
  )
end

Instance Attribute Details

#stepmod_dirObject

Returns the value of attribute stepmod_dir.



11
12
13
# File 'lib/stepmod/utils/changes_extractor.rb', line 11

def stepmod_dir
  @stepmod_dir
end

Class Method Details

.call(stepmod_dir:, stdout: $stdout) ⇒ Object



13
14
15
# File 'lib/stepmod/utils/changes_extractor.rb', line 13

def self.call(stepmod_dir:, stdout: $stdout)
  new(stepmod_dir: stepmod_dir, stdout: stdout).call
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/stepmod/utils/changes_extractor.rb', line 25

def call
  all_resource_changes_files.each do |resource_change_file|
    xml_changes = Nokogiri::XML(File.read(resource_change_file)).root
    add_resource_changes_to_collection(xml_changes, @collection)
  end

  all_modules_changes_files.each do |module_change_file|
    xml_changes = Nokogiri::XML(File.read(module_change_file)).root
    schema_name = Pathname.new(module_change_file).parent.basename.to_s
    add_module_changes_to_collection(xml_changes, @collection,
                                     schema_name)

    add_mapping_table_changes_to_collection(xml_changes, schema_name,
                                            @collection)
  end

  @collection
end