Skip to content

Commit 42e0f43

Browse files
author
Jarl Stefansson
committed
Added support for pip installed virtualenv facter
1 parent b044b0b commit 42e0f43

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lib/facter/virtualenv_version.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
# Show the virtualenv version
2+
# works with virualenv loaded and without, pip installed and package installed
13
require 'puppet'
24
pkg = Puppet::Type.type(:package).new(:name => "virtualenv")
35
Facter.add("virtualenv_version") do
6+
has_weight 100
47
setcode do
5-
/^(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
8+
Facter::Util::Resolution.exec('virtualenv --version')
9+
end
10+
end
11+
12+
Facter.add("virtualenv_version") do
13+
has_eight 50
14+
setcode do
15+
if pkg.retrieve[pkg.property(:ensure)] != 'purged'
16+
/^.*(\d+\.\d+\.\d+).*$/.match(pkg.retrieve[pkg.property(:ensure)])[1]
17+
end
618
end
719
end

0 commit comments

Comments
 (0)