opscode/chef — pull request #1980 by bahamas10 (2014-09-03 23:58:03+00:00)
Title: fix FreeBSD pkgng provider (version detection)

Currently, the logic to detect the installed version of a package assumes the basename of the package is given. For instance, when I pass in a package to install such as `"editors/emacs-nox11"`, the regex to find it in the output of `pkg info editors/emacs-nox11` fails, because only the string `emacs-nox11` is found (without the editor portion).

This change makes it so the version is determined by extracting from the field specifically meant for this.

Here is example output of the command:

```
[dave@sjc1-alpha-01 /etc/chef]$ pkg info editors/emacs-nox11 | head -10
emacs-nox11-24.3_13,3
Name : emacs-nox11
Version : 24.3_13,3
Installed on : Fri Aug 29 17:34:47 PDT 2014
Origin : editors/emacs-nox11
Architecture : freebsd:10:x86:64
Prefix : /usr/local
Categories : ipv6 editors
Licenses : GPLv3
Maintainer : ashish@FreeBSD.org
```

The old logic attempts to match the version by matching the first line of output. This change makes it so it will now match the `/^Version/` field, which is a much cleaner approach.