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.



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

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.



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

def stepmod_dir
  @stepmod_dir
end

Class Method Details

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



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

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

Instance Method Details

#callObject



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

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)
  end

  @collection
end