diff --git a/lib/onceover/beaker.rb b/lib/onceover/beaker.rb index b43e7cc..87e961a 100644 --- a/lib/onceover/beaker.rb +++ b/lib/onceover/beaker.rb @@ -11,9 +11,8 @@ def self.facts_to_vagrant_box(facts) # se or an array if facts.is_a?(Array) - returnval = [] - facts.each do |fact| - returnval << self.facts_to_vagrant_box(fact) + returnval = facts.map do |fact| + self.facts_to_vagrant_box(fact) end return returnval end @@ -64,9 +63,8 @@ def self.facts_to_platform(facts) warn "[DEPRECATION] #{__method__} is deprecated due to the removal of Beaker" if facts.is_a?(Array) - returnval = [] - facts.each do |fact| - returnval << self.facts_to_platform(fact) + returnval = facts.map do |fact| + self.facts_to_platform(fact) end return returnval end diff --git a/lib/onceover/controlrepo.rb b/lib/onceover/controlrepo.rb index e45197d..a3a83a0 100644 --- a/lib/onceover/controlrepo.rb +++ b/lib/onceover/controlrepo.rb @@ -182,9 +182,8 @@ def classes end # Get all the classes from all of the manifests - classes = [] - code_dirs.each do |dir| - classes << get_classes(dir) + classes = code_dirs.map do |dir| + get_classes(dir) end classes.flatten end @@ -208,9 +207,8 @@ def facts(filter = nil, key = 'values') raise "Filter param must be a hash" unless filter.is_a?(Hash) all_facts.keep_if do |hash| - matches = [] - filter.each do |filter_fact,value| - matches << keypair_is_in_hash(hash,filter_fact,value) + matches = filter.map do |filter_fact,value| + keypair_is_in_hash(hash,filter_fact,value) end !matches.include? false end @@ -231,10 +229,9 @@ def print_puppetfile_table puppetfile.load! output_array = [] - threads = [] error_array = [] - puppetfile.modules.each do |mod| - threads << Thread.new do + threads = puppetfile.modules.map do |mod| + Thread.new do begin row = [] logger.debug "Loading data for #{mod.full_name}" @@ -313,13 +310,12 @@ def update_puppetfile # TODO: Make sure we can deal with :latest # Create threading resources - threads = [] queue = Queue.new queue.push(puppetfile_string) puppetfile.modules.keep_if {|m| m.is_a?(R10K::Module::Forge)} - puppetfile.modules.each do |mod| - threads << Thread.new do + threads = puppetfile.modules.map do |mod| + Thread.new do logger.debug "Getting latest version of #{mod.full_name}" latest_version = mod.v3_module.current_release.version diff --git a/lib/onceover/group.rb b/lib/onceover/group.rb index a8a2c8e..9c64a87 100644 --- a/lib/onceover/group.rb +++ b/lib/onceover/group.rb @@ -28,10 +28,8 @@ def initialize(name = nil, members = []) @members = [] else # Turn it into a full list - member_objects = [] - # This should also handle lists that include groups - members.each { |member| member_objects << Onceover::TestConfig.find_list(member) } + member_objects = members.map { |member| Onceover::TestConfig.find_list(member) } member_objects.flatten! # Check that they are all the same type