Class: Foreman::Utils

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

Class Method Summary collapse

Class Method Details

.parse_concurrency(concurrency) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/foreman/utils.rb', line 5

def self.parse_concurrency(concurrency)
  begin
    pairs = concurrency.to_s.gsub(/\s/, "").split(",")
    
    default = concurrency.nil? ? 1 : 0
    
    pairs.inject(Hash.new(default)) do |hash, pair|
      process, amount = pair.split("=")
      hash.update(process => amount.to_i)        
    end
  end
end