Skip to content

Commit

Permalink
Homepage|Build Repository: Made use of Version for nicer version numb…
Browse files Browse the repository at this point in the history
…er output

The following new properties were added to the JSON object graphs:

- (integer) version_major = major version number
- (integer) version_minor = minor version number
- (integer) version_patch = patch version number
- (integer) version_revision = revision version number (build number)
  • Loading branch information
danij-deng committed Mar 28, 2013
1 parent 029f2a0 commit ef3ae96
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 33 deletions.
38 changes: 19 additions & 19 deletions web/plugins/buildrepository/buildrepository.php
Expand Up @@ -403,87 +403,87 @@ private function populateStaticPackages(&$packages)
* @todo Read this information from a config file, we should not
* expect to edit this file in order to change these...
*/
$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', '1.9.8',
$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', Version::fromString('1.9.8'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.8/deng-inst-1.9.8-1.exe/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.8-1');
$pack->setReleaseDate(strtotime('June 26, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_MAC10_4_X86_PPC, 'Doomsday', '1.9.8',
$pack = PackageFactory::newDistribution(PID_MAC10_4_X86_PPC, 'Doomsday', Version::fromString('1.9.8'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.8/deng-inst-1.9.8-1.dmg/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.8-1');
$pack->setReleaseDate(strtotime('June 26, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_MAC10_6_X86_X86_64, 'Doomsday', '1.9.8',
$pack = PackageFactory::newDistribution(PID_MAC10_6_X86_X86_64, 'Doomsday', Version::fromString('1.9.8'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.8/deng-inst-1.9.8-1_64bit.dmg/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.8-1');
$pack->setReleaseDate(strtotime('June 26, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_LINUX_X86, 'Doomsday', '1.9.8',
$pack = PackageFactory::newDistribution(PID_LINUX_X86, 'Doomsday', Version::fromString('1.9.8'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.8/deng-inst-1.9.8-1_i386.deb/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.8-1');
$pack->setReleaseDate(strtotime('June 26, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_LINUX_X86_64, 'Doomsday', '1.9.8',
$pack = PackageFactory::newDistribution(PID_LINUX_X86_64, 'Doomsday', Version::fromString('1.9.8'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.8/deng-inst-1.9.8-1_amd64.deb/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.8-1');
$pack->setReleaseDate(strtotime('June 26, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', '1.9.7',
$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', Version::fromString('1.9.7'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.7/deng-inst-1.9.7-1.exe/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.7-1');
$pack->setReleaseDate(strtotime('March 14, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_MAC10_4_X86_PPC, 'Doomsday', '1.9.7',
$pack = PackageFactory::newDistribution(PID_MAC10_4_X86_PPC, 'Doomsday', Version::fromString('1.9.7'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.7/deng-inst-1.9.7-1.dmg/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.7-1');
$pack->setReleaseDate(strtotime('March 14, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_MAC10_6_X86_X86_64, 'Doomsday', '1.9.7',
$pack = PackageFactory::newDistribution(PID_MAC10_6_X86_X86_64, 'Doomsday', Version::fromString('1.9.7'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.7/deng-inst-1.9.7-1.dmg/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.7-1');
$pack->setReleaseDate(strtotime('March 14, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_LINUX_X86, 'Doomsday', '1.9.7',
$pack = PackageFactory::newDistribution(PID_LINUX_X86, 'Doomsday', Version::fromString('1.9.7'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.7/deng-inst-1.9.7-1.deb/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.7-1');
$pack->setReleaseDate(strtotime('March 14, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_LINUX_X86_64, 'Doomsday', '1.9.7',
$pack = PackageFactory::newDistribution(PID_LINUX_X86_64, 'Doomsday', Version::fromString('1.9.7'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.9.7/deng-inst-1.9.7-1.deb/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
$pack->setReleaseNotesUri('http://dengine.net/dew/index.php?title=Doomsday_version_1.9.7-1');
$pack->setReleaseDate(strtotime('March 14, 2012'));
$packages[] = $pack;

$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', '1.8.6',
$pack = PackageFactory::newDistribution(PID_WIN_X86, 'Doomsday', Version::fromString('1.8.6'),
'http://sourceforge.net/projects/deng/files/Doomsday%20Engine/1.8.6/deng-inst-1.8.6.exe/download',
NULL/*no fallback download uri*/,
false/*not an autobuilder packaged*/);
Expand Down Expand Up @@ -651,20 +651,20 @@ private function chainBuildsByDoomsdayVersion()
if($pack->title() !== 'Doomsday') continue;

// Have we encountered this version before?.
$version = $pack->version();
$key = array_casekey_exists($version, $releases);
$versionText = "{$pack->version()}";
$key = array_casekey_exists($versionText, $releases);
if($key === false)
{
// Not yet construct a new build list (array) and associate it
// in the release array using the version number as the key.
$key = ucwords($version);
$key = ucwords($versionText);
$releases[$key] = array();

$buildList = &$releases[$key];
}
else
{
$buildList = &$releases[$version];
$buildList = &$releases[$versionText];
}

// Is this package a product of the autobuilder?
Expand Down Expand Up @@ -1379,20 +1379,20 @@ private function populateReleases(&$releases)
if($pack->title() !== 'Doomsday') continue;

// Have we encountered this version before?.
$version = $pack->version();
$key = array_casekey_exists($version, $releases);
$versionText = "{$pack->version()}";
$key = array_casekey_exists($versionText, $releases);
if($key === false)
{
// Not yet construct a new record and associate it
// in the release list using the version number as the key.
$key = ucwords($version);
$key = ucwords($versionText);
$releases[$key] = $this->newReleaseInfo($key);

$releaseInfo = &$releases[$key];
}
else
{
$releaseInfo = &$releases[$version];
$releaseInfo = &$releases[$versionText];
}

$build = NULL;
Expand Down
9 changes: 8 additions & 1 deletion web/plugins/buildrepository/packagefactory.class.php
Expand Up @@ -24,6 +24,8 @@

includeGuard('PackageFactory');

require_once(DIR_CLASSES.'/version.class.php');

require_once('packages/basepackage.class.php');
require_once('packages/nullpackage.class.php');
require_once('packages/distributionpackage.class.php');
Expand Down Expand Up @@ -106,9 +108,14 @@ public static function newFromSimpleXMLElement(&$log_pack, $releaseType='unstabl
}

if(!empty($log_pack->version))
$version = clean_text($log_pack->version);
{
$versionText = clean_text($log_pack->version);
$version = Version::fromString($versionText);
}
else
{
$version = NULL;
}

// Determine package type.
foreach($log_pack->attributes() as $attrib => $value)
Expand Down
Expand Up @@ -34,12 +34,12 @@ abstract class AbstractUnstableBuilderPackage extends AbstractUnstablePackage im
// Override implementation in AbstractUnstablePackage.
public function composeFullTitle($includeVersion=true, $includePlatformName=true, $includeBuildId=true)
{
$includeVersion = (boolean) $includeVersion;
$includeBuildId = (boolean) $includeBuildId;
$includeVersion = (bool) $includeVersion;
$includeBuildId = (bool) $includeBuildId;

$title = $this->title;
if($includeVersion && isset($this->version))
$title .= ' '. $this->version;
$title .= " {$this->version}";
if($includeBuildId && $this->buildId !== 0)
$title .= ' Build'. $this->buildId;
if($includePlatformName && $this->platformId !== PID_ANY)
Expand Down
Expand Up @@ -32,12 +32,12 @@ abstract class AbstractUnstablePackage extends AbstractPackage
// Override implementation in AbstractPackage.
public function composeFullTitle($includeVersion=true, $includePlatformName=true)
{
$includeVersion = (boolean) $includeVersion;
$includeBuildId = (boolean) $includeBuildId;
$includeVersion = (bool) $includeVersion;
$includeBuildId = (bool) $includeBuildId;

$title = $this->title;
if($includeVersion && isset($this->version))
$title .= ' '. $this->version;
$title .= " {$this->version}";
if($includePlatformName && $this->platformId !== PID_ANY)
{
$plat = &BuildRepositoryPlugin::platform($this->platformId);
Expand Down
25 changes: 18 additions & 7 deletions web/plugins/buildrepository/packages/basepackage.class.php
Expand Up @@ -25,19 +25,21 @@

includeGuard('BasePackage');

require_once(DIR_CLASSES.'/version.class.php');

abstract class BasePackage
{
protected $platformId;
protected $title = '(unnamed)';
protected $version = NULL;

public function __construct($platformId=PID_ANY, $title=NULL, $version=NULL)
public function __construct($platformId=PID_ANY, $title=NULL, Version $version = NULL)
{
$this->platformId = $platformId;
if(!is_null($title))
$this->title = "$title";
if(!is_null($version))
$this->version = "$version";
$this->version = $version;
}

public function &platformId()
Expand All @@ -57,11 +59,11 @@ public function &version()

public function composeFullTitle($includeVersion=true, $includePlatformName=true)
{
$includeVersion = (boolean) $includeVersion;
$includeVersion = (bool)$includeVersion;

$title = $this->title;
if($includeVersion && !is_null($this->version))
$title .= ' '. $this->version;
$title .= " {$this->version}";
if($includePlatformName && $this->platformId !== PID_ANY)
{
$plat = &BuildRepositoryPlugin::platform($this->platformId);
Expand Down Expand Up @@ -90,8 +92,17 @@ public function populateGraphTemplate(&$tpl)

$tpl['platform_id'] = $this->platformId();
$tpl['platform_name'] = $plat['name'];
$tpl['version'] = $this->version();
$tpl['title'] = $this->title();
$tpl['fulltitle'] = $this->composeFullTitle();

$tpl['title'] = $this->title();
$tpl['fulltitle'] = $this->composeFullTitle();

// Textual version representation.
$tpl['version'] = is_null($this->version)? '0' : "{$this->version}";

// Component version representation.
$tpl['version_major'] = is_null($this->version)? '0' : $this->version->major;
$tpl['version_minor'] = is_null($this->version)? '0' : $this->version->minor;
$tpl['version_patch'] = is_null($this->version)? '0' : $this->version->patch;
$tpl['version_revision'] = is_null($this->version)? '0' : $this->version->revision;
}
}

0 comments on commit ef3ae96

Please sign in to comment.