class Hiptest::NodeModifiers::ActionwordUniqRenamer
Public Class Methods
add(project)
click to toggle source
# File lib/hiptest-publisher/node_modifiers/actionword_uniq_renamer.rb, line 4 def self.add(project) self.new(project).make_uniq_names end
new(project)
click to toggle source
# File lib/hiptest-publisher/node_modifiers/actionword_uniq_renamer.rb, line 8 def initialize(project) @project = project end
Public Instance Methods
find_uniq_name(name, existing)
click to toggle source
# File lib/hiptest-publisher/node_modifiers/actionword_uniq_renamer.rb, line 22 def find_uniq_name(name, existing) return name unless existing.include?(name) index = 1 new_name = "" loop do new_name = "#{name} #{index}" break unless existing.include?(new_name) index += 1 end new_name end
make_uniq_names()
click to toggle source
# File lib/hiptest-publisher/node_modifiers/actionword_uniq_renamer.rb, line 12 def make_uniq_names @project.children[:libraries].children[:libraries].each do |library| library.children[:library_actionwords].each do |library_actionword| existing_names = library.children[:library_actionwords].reject{|aw| aw == library_actionword}.map(&:uniq_name) new_name = find_uniq_name(library_actionword.children[:name], existing_names) library_actionword.uniq_name = new_name end end end