Class: Hiptest::DefaultArgumentAdder

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/call_arguments_adder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ DefaultArgumentAdder

Returns a new instance of DefaultArgumentAdder.



9
10
11
12
# File 'lib/hiptest-publisher/call_arguments_adder.rb', line 9

def initialize(project)
  @project = project
  @indexer = ActionwordIndexer.new(project)
end

Class Method Details

.add(project) ⇒ Object



5
6
7
# File 'lib/hiptest-publisher/call_arguments_adder.rb', line 5

def self.add(project)
  DefaultArgumentAdder.new(project).update_calls
end

Instance Method Details

#update_callsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hiptest-publisher/call_arguments_adder.rb', line 14

def update_calls
  @project.find_sub_nodes(Hiptest::Nodes::Call).each do |call|
    aw_data = @indexer.get_index(call.children[:actionword])
    next if aw_data.nil?

    arguments = {}
    call.children[:arguments].each do |arg|
      arguments[arg.children[:name]] = arg.children[:value]
    end

    call.children[:all_arguments] = aw_data[:parameters].map do |p_name, default_value|
      Hiptest::Nodes::Argument.new(
        p_name,
        arguments.has_key?(p_name) ? arguments[p_name] : default_value
      )
    end
  end
end