# File lib/puppet/provider/package/openbsd.rb, line 14
14:   def self.instances
15:     packages = []
16: 
17:     begin
18:       execpipe(listcmd) do |process|
19:         # our regex for matching pkg_info output
20:         regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
21:         fields = [:name, :ensure, :flavor ]
22:         hash = {}
23: 
24:         # now turn each returned line into a package object
25:         process.each { |line|
26:           if match = regex.match(line.split[0])
27:             fields.zip(match.captures) { |field,value|
28:               hash[field] = value
29:             }
30:             yup = nil
31:             name = hash[:name]
32: 
33:             hash[:provider] = self.name
34: 
35:             packages << new(hash)
36:             hash = {}
37:           else
38:             # Print a warning on lines we can't match, but move
39:             # on, since it should be non-fatal
40:             warning("Failed to match line #{line}")
41:           end
42:         }
43:       end
44: 
45:       return packages
46:     rescue Puppet::ExecutionFailure
47:       return nil
48:     end
49:   end