• Source
    1. s = <<DATA
    2. PLAY RECAP *********************************************************************
    3. ec2-123.compute-1.amazonaws.com : ok=16 changed=2 unreachable=0 failed=0
    4. ec2-456.compute-1.amazonaws.com : ok=11 changed=0 unreachable=0 failed=0
    5. ec2-766.compute-1.amazonaws.com : ok=40 changed=15 unreachable=0 failed=0
    6. localhost : ok=0 changed=0 unreachable=0 failed=0
    7. DATA
    8. res = s
    9. .scan(/^(ec[0-9]+\S+) : ok=([0-9]+)/)
    10. .to_h.map{ |a, b| [ a,
    11. begin
    12. Integer b
    13. rescue ArgumentError
    14. b
    15. end ]}
    16. .sort_by {|a, b| b}
    17. .to_h
    18. puts res