From 7c7afae3abdb0924fdc362a42ad3cd60644b910e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Sun, 6 Apr 2014 12:40:46 +0200 Subject: simplify pkgname default rather than having a rather ugly if and an unhandy case new variable, we can simplify this by making the default $name, in the parameter list. --- manifests/pip.pp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/manifests/pip.pp b/manifests/pip.pp index bf987a4..0c78903 100644 --- a/manifests/pip.pp +++ b/manifests/pip.pp @@ -8,7 +8,7 @@ # must be unique # # [*pkgname] -# name of the package. +# name of the package. If pkgname is not specified, use name (title) instead. # # [*ensure*] # present|absent. Default: present @@ -41,7 +41,7 @@ # Fotis Gimian # define python::pip ( - $pkgname = undef, + $pkgname = $name, $ensure = present, $virtualenv = 'system', $url = false, @@ -77,29 +77,23 @@ define python::pip ( default => "--proxy=${proxy}", } - # If pkgname is not specified, use name (title) instead. - $use_pkgname = $pkgname ? { - undef => $name, - default => $pkgname - } - # Check if searching by explicit version. if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ { - $grep_regex = "^${use_pkgname}==${ensure}\$" + $grep_regex = "^${pkgname}==${ensure}\$" } else { - $grep_regex = $use_pkgname ? { - /==/ => "^${use_pkgname}\$", - default => "^${use_pkgname}==", + $grep_regex = $pkgname ? { + /==/ => "^${pkgname}\$", + default => "^${pkgname}==", } } $egg_name = $egg ? { - false => $use_pkgname, + false => $pkgname, default => $egg } $source = $url ? { - false => $use_pkgname, + false => $pkgname, default => "${url}#egg=${egg_name}", } -- cgit v1.2.3