Skip to content

Commit

Permalink
Merge pull request #77 from igalic/patch-1
Browse files Browse the repository at this point in the history
simplify pkgname default
  • Loading branch information
stankevich committed Apr 6, 2014
2 parents cb06183 + 8560cc1 commit d416a93
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +41,7 @@
# Fotis Gimian
#
define python::pip (
$pkgname = undef,
$pkgname = $name,
$ensure = present,
$virtualenv = 'system',
$url = false,
Expand Down Expand Up @@ -77,29 +77,23 @@
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}",
}

Expand Down

0 comments on commit d416a93

Please sign in to comment.