cs-versionparse-commits Mailing List for CS PHP Version Parser
Status: Inactive
Brought to you by:
crazedsanity
You can subscribe to this list here.
| 2009 |
Jan
(11) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <cra...@us...> - 2009-08-11 18:24:50
|
Revision: 22
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=22&view=rev
Author: crazedsanity
Date: 2009-08-11 18:24:42 +0000 (Tue, 11 Aug 2009)
Log Message:
-----------
Ability to get values of private/protected vars.
/cs_version.abstract.class.php:
* __get() [NEW]:
-- allows other classes to retrieve values of private/protected
vars/members.
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-06-11 01:09:58 UTC (rev 21)
+++ trunk/0.1/cs_version.abstract.class.php 2009-08-11 18:24:42 UTC (rev 22)
@@ -74,6 +74,14 @@
//=========================================================================
+ public function __get($var) {
+ return($this->$var);
+ }//end __get()
+ //=========================================================================
+
+
+
+ //=========================================================================
final public function get_project() {
$retval = NULL;
$this->auto_set_version_file();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-06-11 01:10:24
|
Revision: 21
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=21&view=rev
Author: crazedsanity
Date: 2009-06-11 01:09:58 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
Fix some PHP notices for unit testing with error reporting set to E_ALL.
/cs_version.abstract.class.php:
* parse_version_string():
-- check for the presence of $pieces[2] before blindly using it to
avoid PHP notices.
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-02-03 20:02:40 UTC (rev 20)
+++ trunk/0.1/cs_version.abstract.class.php 2009-06-11 01:09:58 UTC (rev 21)
@@ -157,10 +157,12 @@
$pieces = explode('.', $version);
$retval = array(
'version_major' => $pieces[0],
- 'version_minor' => $pieces[1],
- 'version_maintenance' => $pieces[2]
+ 'version_minor' => $pieces[1]
);
- if(!strlen($retval['version_maintenance'])) {
+ if(isset($pieces[2]) && strlen($pieces[2])) {
+ $retval['version_maintenance'] = $pieces[2];
+ }
+ else {
$retval['version_maintenance'] = 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-02-03 20:02:44
|
Revision: 20
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=20&view=rev
Author: crazedsanity
Date: 2009-02-03 20:02:40 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
*** RELEASE 0.1.2 ***
SUMMARY OF CHANGES:::
* minor update to show filename it attempted to use for VERSION when dying.
SVN COMMANDS:::
merge --depth=infinity -r17:HEAD https://cs-versionparse.svn.sourceforge.net/svnroot/cs-versionparse/trunk/0.1
Modified Paths:
--------------
releases/0.1/VERSION
releases/0.1/cs_version.abstract.class.php
Property Changed:
----------------
releases/0.1/
Property changes on: releases/0.1
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/0.1:15-16
+ /trunk/0.1:15-16,18-19
Modified: releases/0.1/VERSION
===================================================================
--- releases/0.1/VERSION 2009-02-03 20:01:15 UTC (rev 19)
+++ releases/0.1/VERSION 2009-02-03 20:02:40 UTC (rev 20)
@@ -1,6 +1,6 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.1.1
+VERSION: 0.1.2
PROJECT: cs-versionparse
$HeadURL$
\ No newline at end of file
Modified: releases/0.1/cs_version.abstract.class.php
===================================================================
--- releases/0.1/cs_version.abstract.class.php 2009-02-03 20:01:15 UTC (rev 19)
+++ releases/0.1/cs_version.abstract.class.php 2009-02-03 20:02:40 UTC (rev 20)
@@ -137,7 +137,7 @@
$this->set_version_file_location($dir .'/VERSION');
}
else {
- throw new exception(__METHOD__ .": failed to automatically set version file");
+ throw new exception(__METHOD__ .": failed to automatically set version file (tried ". $dir ."/VERSION)");
}
}
}//end auto_set_version_file()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-02-03 20:01:18
|
Revision: 19
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=19&view=rev
Author: crazedsanity
Date: 2009-02-03 20:01:15 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
*** RELEASE 0.1.2 ***
SUMMARY OF CHANGES:::
* minor update to show filename it attempted to use for VERSION when dying.
Modified Paths:
--------------
trunk/0.1/VERSION
Modified: trunk/0.1/VERSION
===================================================================
--- trunk/0.1/VERSION 2009-02-03 18:45:23 UTC (rev 18)
+++ trunk/0.1/VERSION 2009-02-03 20:01:15 UTC (rev 19)
@@ -1,6 +1,6 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.1.1
+VERSION: 0.1.2
PROJECT: cs-versionparse
$HeadURL$
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-02-03 18:45:27
|
Revision: 18
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=18&view=rev
Author: crazedsanity
Date: 2009-02-03 18:45:23 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
Minor update to show filename it attempted to use for a VERSION file.
/cs_version.abstract.class.php:
* auto_set_version_file():
-- add bit indicating what file it attempted to use (#235)
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-30 14:36:40 UTC (rev 17)
+++ trunk/0.1/cs_version.abstract.class.php 2009-02-03 18:45:23 UTC (rev 18)
@@ -137,7 +137,7 @@
$this->set_version_file_location($dir .'/VERSION');
}
else {
- throw new exception(__METHOD__ .": failed to automatically set version file");
+ throw new exception(__METHOD__ .": failed to automatically set version file (tried ". $dir ."/VERSION)");
}
}
}//end auto_set_version_file()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-30 14:36:48
|
Revision: 17
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=17&view=rev
Author: crazedsanity
Date: 2009-01-30 14:36:40 +0000 (Fri, 30 Jan 2009)
Log Message:
-----------
*** RELEASE 0.1.1 ***
Fix unnecessary dependencies and debugging statements.
Modified Paths:
--------------
releases/0.1/VERSION
releases/0.1/cs_version.abstract.class.php
Property Changed:
----------------
releases/0.1/
Property changes on: releases/0.1
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/0.1:15-16
Modified: releases/0.1/VERSION
===================================================================
--- releases/0.1/VERSION 2009-01-30 14:23:52 UTC (rev 16)
+++ releases/0.1/VERSION 2009-01-30 14:36:40 UTC (rev 17)
@@ -1,6 +1,6 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.1
+VERSION: 0.1.1
PROJECT: cs-versionparse
$HeadURL$
\ No newline at end of file
Modified: releases/0.1/cs_version.abstract.class.php
===================================================================
--- releases/0.1/cs_version.abstract.class.php 2009-01-30 14:23:52 UTC (rev 16)
+++ releases/0.1/cs_version.abstract.class.php 2009-01-30 14:36:40 UTC (rev 17)
@@ -216,7 +216,6 @@
unset($versionInfo['version_suffix']);
$retval = "";
- $gf = new cs_globalFunctions;
foreach($versionInfo as $name=>$value) {
if(strlen($retval)) {
$retval .= ".". $value;
@@ -230,7 +229,6 @@
}
}
else {
- cs_debug_backtrace(1);
throw new exception(__METHOD__ .": missing indexes in given array (". $missing .")");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-30 14:23:54
|
Revision: 16
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=16&view=rev
Author: crazedsanity
Date: 2009-01-30 14:23:52 +0000 (Fri, 30 Jan 2009)
Log Message:
-----------
*** RELEASE 0.1.1 ***
Fix unnecessary dependencies and debugging statements.
Modified Paths:
--------------
trunk/0.1/VERSION
Modified: trunk/0.1/VERSION
===================================================================
--- trunk/0.1/VERSION 2009-01-29 20:22:22 UTC (rev 15)
+++ trunk/0.1/VERSION 2009-01-30 14:23:52 UTC (rev 16)
@@ -1,6 +1,6 @@
## Stores the current version of the cs-versionparse system, and it's source.
## Please do NOT modify this file.
-VERSION: 0.1
+VERSION: 0.1.1
PROJECT: cs-versionparse
$HeadURL$
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-29 20:22:26
|
Revision: 15
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=15&view=rev
Author: crazedsanity
Date: 2009-01-29 20:22:22 +0000 (Thu, 29 Jan 2009)
Log Message:
-----------
Fix invalid function/method calls (old debug stuff).
/cs_version.abstract.class.php:
* build_full_version_string():
-- remove creation of unused cs_globalFunctions{} object.
-- remove call to invalid cs_debug_print().
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-27 16:39:15 UTC (rev 14)
+++ trunk/0.1/cs_version.abstract.class.php 2009-01-29 20:22:22 UTC (rev 15)
@@ -216,7 +216,6 @@
unset($versionInfo['version_suffix']);
$retval = "";
- $gf = new cs_globalFunctions;
foreach($versionInfo as $name=>$value) {
if(strlen($retval)) {
$retval .= ".". $value;
@@ -230,7 +229,6 @@
}
}
else {
- cs_debug_backtrace(1);
throw new exception(__METHOD__ .": missing indexes in given array (". $missing .")");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-27 16:39:25
|
Revision: 14
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=14&view=rev
Author: crazedsanity
Date: 2009-01-27 16:39:15 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
*** RELEASE 0.1 ***
Initial public release. This system handles parsing of a VERSION file so that
version requirements (minimum/exact) can be determined by web applications.
Version checking by web applications is generally done to facilitate automatic
upgrades and as a sanity check for developers (especially when multiple external
projects have co-dependencies).
Added Paths:
-----------
releases/0.1/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-26 17:27:01
|
Revision: 13
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=13&view=rev
Author: crazedsanity
Date: 2009-01-26 17:26:57 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Updated tests to test new functionality & methods.
Modified Paths:
--------------
trunk/0.1/tests/testOfCSVersionParse.php
Modified: trunk/0.1/tests/testOfCSVersionParse.php
===================================================================
--- trunk/0.1/tests/testOfCSVersionParse.php 2009-01-26 17:26:22 UTC (rev 12)
+++ trunk/0.1/tests/testOfCSVersionParse.php 2009-01-26 17:26:57 UTC (rev 13)
@@ -70,6 +70,54 @@
}
}//end test_basics()
//--------------------------------------------------------------------------
+
+
+
+ //--------------------------------------------------------------------------
+ function test_check_higher() {
+
+ //NOTE: the first item should ALWAYS be higher.
+ $tests = array(
+ 'basic, no suffix' => array('1.0.1', '1.0.0'),
+ 'basic + suffix' => array('1.0.0-ALPHA1', '1.0.0-ALPHA0'),
+ 'basic w/o maint' => array('1.0.1', '1.0'),
+ 'suffix check' => array('1.0.0-BETA1', '1.0.0-ALPHA1'),
+ 'suffix check2' => array('1.0.0-ALPHA10', '1.0.0-ALPHA1'),
+ 'suffix check3' => array('1.0.1', '1.0.0-RC1')
+ );
+
+ foreach($tests as $name=>$checkData) {
+ $ver = new middleTestClass;
+ $this->assertTrue($ver->is_higher_version($checkData[1], $checkData[0]));
+ $this->assertFalse($ver->is_higher_version($checkData[0], $checkData[1]));
+ }
+
+ //now check to ensure there's no problem with parsing equivalent versions.
+ $tests = array(
+ 'no suffix' => array('1.0', '1.0.0'),
+ 'no maint + suffix' => array('1.0-ALPHA1', '1.0.0-ALPHA1'),
+ 'no maint + BETA' => array('1.0-BETA5555', '1.0.0-BETA5555'),
+ 'no maint + RC' => array('1.0-RC33', '1.0.0-RC33'),
+ 'maint with space' => array('1.0-RC 33', '1.0.0-RC33'),
+ 'extra spaces' => array(' 1.0 ', '1.0.0')
+ );
+ foreach($tests as $name=>$checkData) {
+ $ver = new middleTestClass;
+
+ //rip apart & recreate first version to test against the expected...
+ $derivedFullVersion = $ver->build_full_version_string($ver->parse_version_string($checkData[0]));
+ $this->assertEqual($derivedFullVersion, $checkData[1], "TEST=(". $name ."): derived version " .
+ "(". $derivedFullVersion .") doesn't match expected (". $checkData[1] .")");
+
+ //now rip apart & recreate the expected version (second) and make sure it matches itself.
+ $derivedFullVersion = $ver->build_full_version_string($ver->parse_version_string($checkData[1]));
+ $this->assertEqual($derivedFullVersion, $checkData[1], "TEST=(". $name ."): derived version " .
+ "(". $derivedFullVersion .") doesn't match expected (". $checkData[1] .")");
+ }
+
+
+ }//end test_check_higher()
+ //--------------------------------------------------------------------------
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-26 17:26:29
|
Revision: 12
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=12&view=rev
Author: crazedsanity
Date: 2009-01-26 17:26:22 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Enhancements for determining higher versions & parsing suffixes.
/cs_version.abstract.class.php:
* MAIN:::
-- new private var, fullVersionString: caches the derived full version
string (may be used later...)
-- new private var, suffixList: contains all valid suffixes & notes
about their intended meanings, which explains why they're orderd as such.
* get_version():
-- calls parse_version_string() to get information as an array.
-- calls build_full_version_string() to build the version string.
* parse_version_string() [NEW]:
-- parses full version string into it's respective bits (major, minor,
maintenance, and suffix).
* build_full_version_string() [NEW]:
-- uses data from parse_version_string() to build the full version
string.
* is_higher_version() [NEW]:
-- checks if a given version is higher than another given version.
-- NOTE: this logic was pulled from the upgradeClass from cs-project, in
hopes that eventually this will deprecate that code.
* parse_suffix() [NEW]:
-- parses the suffix to help determine if one suffix is higher or lower
than another (for is_higher_version()).
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-26 05:43:34 UTC (rev 11)
+++ trunk/0.1/cs_version.abstract.class.php 2009-01-26 17:26:22 UTC (rev 12)
@@ -13,8 +13,19 @@
abstract class cs_versionAbstract {
public $isTest = FALSE;
+
+
+
private $versionFileLocation=null;
+ private $fullVersionString;
+ private $suffixList = array(
+ 'ALPHA', //very unstable
+ 'BETA', //kinda unstable, but probably useable
+ 'RC' //all known bugs fixed, searching for unknown ones
+ );
+
+
abstract public function __construct();
@@ -34,43 +45,16 @@
if($findIt == 1 && count($matches) == 2) {
$fullVersionString = $matches[1];
- $pieces = explode('.', $fullVersionString);
- $retval = array(
- 'version_major' => $pieces[0],
- 'version_minor' => $pieces[1],
- 'version_maintenance' => $pieces[2]
- );
- if(!strlen($retval['version_maintenance'])) {
- $retval['version_maintenance'] = 0;
- }
+ $versionInfo = $this->parse_version_string($fullVersionString);
+ $this->fullVersionString = $this->build_full_version_string($versionInfo);
- if(preg_match('/-/', $retval['version_maintenance'])) {
- $bits = explode('-', $retval['version_maintenance']);
- $retval['version_maintenance'] = $bits[0];
- $suffix = $bits[1];
- }
- else {
- $suffix = "";
- }
- $fullVersionString = "";
- foreach(array_values($retval) as $chunk) {
- if(strlen($fullVersionString)) {
- $fullVersionString .= '.';
- }
- $fullVersionString .= $chunk;
- }
- if(strlen($suffix)) {
- $fullVersionString .= '-'. $suffix;
- }
-
-
if($asArray) {
- $retval['version_suffix'] = $suffix;
- $retval['version_string'] = $fullVersionString;
+ $retval = $versionInfo;
+ $retval['version_string'] = $this->fullVersionString;
}
else {
- $retval = $fullVersionString;
+ $retval = $this->build_full_version_string($versionInfo);
}
}
else {
@@ -160,5 +144,247 @@
//=========================================================================
+
+ //=========================================================================
+ /**
+ *
+ * TODO: add logic to split apart the suffix (i.e. "-ALPHA5" broken into "ALPHA" and "5").
+ */
+ public function parse_version_string($version) {
+ if(is_string($version) && strlen($version) && preg_match('/\./', $version)) {
+ $version = preg_replace('/ /', '', $version);
+
+ $pieces = explode('.', $version);
+ $retval = array(
+ 'version_major' => $pieces[0],
+ 'version_minor' => $pieces[1],
+ 'version_maintenance' => $pieces[2]
+ );
+ if(!strlen($retval['version_maintenance'])) {
+ $retval['version_maintenance'] = 0;
+ }
+
+ if(preg_match('/-/', $retval['version_maintenance'])) {
+ $bits = explode('-', $retval['version_maintenance']);
+ $retval['version_maintenance'] = $bits[0];
+ $suffix = $bits[1];
+ }
+ elseif(preg_match('/-/', $retval['version_minor'])) {
+ $bits = explode('-', $retval['version_minor']);
+ $retval['version_minor'] = $bits[0];
+ $suffix = $bits[1];
+ }
+ else {
+ $suffix = "";
+ }
+ $retval['version_suffix'] = $suffix;
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid version string passed (". $version .")");
+ }
+
+ return($retval);
+ }//end parse_version_string()
+ //=========================================================================
+
+
+
+ //=========================================================================
+ public function build_full_version_string(array $versionInfo) {
+ $requiredIndexes = array(
+ 'version_major', 'version_minor', 'version_maintenance', 'version_suffix'
+ );
+
+ $missing="";
+ $count=0;
+ foreach($requiredIndexes as $indexName) {
+ if(isset($versionInfo[$indexName])) {
+ $count++;
+ }
+ else {
+ if(strlen($missing)) {
+ $missing .= ", ". $indexName;
+ }
+ else {
+ $missing = $indexName;
+ }
+ }
+ }
+
+ if($count == count($requiredIndexes) && !strlen($missing)) {
+ $suffix = $versionInfo['version_suffix'];
+ unset($versionInfo['version_suffix']);
+
+ $retval = "";
+ $gf = new cs_globalFunctions;
+ foreach($versionInfo as $name=>$value) {
+ if(strlen($retval)) {
+ $retval .= ".". $value;
+ }
+ else {
+ $retval = $value;
+ }
+ }
+ if(strlen($suffix)) {
+ $retval .= "-". $suffix;
+ }
+ }
+ else {
+ cs_debug_backtrace(1);
+ throw new exception(__METHOD__ .": missing indexes in given array (". $missing .")");
+ }
+
+ return($retval);
+
+ }//end build_full_version_string()
+ //=========================================================================
+
+
+
+ //=========================================================================
+ public function is_higher_version($version, $checkIfHigher) {
+ $retval = FALSE;
+ $this->gfObj = new cs_globalFunctions;
+ if(!is_string($version) || !is_string($checkIfHigher)) {
+ throw new exception(__METHOD__ .": no valid version strings, version=(". $version ."), checkIfHigher=(". $checkIfHigher .")");
+ }
+ elseif($version == $checkIfHigher) {
+ $retval = FALSE;
+ }
+ else {
+ $curVersionArr = $this->parse_version_string($version);
+ $checkVersionArr = $this->parse_version_string($checkIfHigher);
+
+ unset($curVersionArr['version_string'], $checkVersionArr['version_string']);
+
+
+ $curVersionSuffix = $curVersionArr['version_suffix'];
+ $checkVersionSuffix = $checkVersionArr['version_suffix'];
+
+
+ unset($curVersionArr['version_suffix']);
+
+ foreach($curVersionArr as $index=>$versionNumber) {
+ $checkThis = $checkVersionArr[$index];
+
+ if(is_numeric($checkThis) && is_numeric($versionNumber)) {
+ //set them as integers.
+ settype($versionNumber, 'int');
+ settype($checkThis, 'int');
+
+ if($checkThis > $versionNumber) {
+ $retval = TRUE;
+ break;
+ }
+ elseif($checkThis == $versionNumber) {
+ //they're equal...
+ }
+ else {
+ //TODO: should there maybe be an option to throw an exception (freak out) here?
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": ". $index ." is not numeric in one of the strings " .
+ "(versionNumber=". $versionNumber .", checkThis=". $checkThis .")");
+ }
+ }
+
+ //now deal with those damnable suffixes, but only if the versions are so far identical: if
+ // the "$checkIfHigher" is actually higher, don't bother (i.e. suffixes don't matter when
+ // we already know there's a major, minor, or maintenance version that's also higher.
+ if($retval === FALSE) {
+ //EXAMPLE: $version="1.0.0-BETA3", $checkIfHigher="1.1.0"
+ // Moving from a non-suffixed version to a suffixed version isn't supported, but the inverse is:
+ // i.e. (1.0.0-BETA3 to 1.0.0) is okay, but (1.0.0 to 1.0.0-BETA3) is NOT.
+ // Also: (1.0.0-BETA3 to 1.0.0-BETA4) is okay, but (1.0.0-BETA4 to 1.0.0-BETA3) is NOT.
+ if(strlen($curVersionSuffix) && strlen($checkVersionSuffix) && $curVersionSuffix == $checkVersionSuffix) {
+ //matching suffixes.
+ }
+ elseif(strlen($curVersionSuffix) || strlen($checkVersionSuffix)) {
+ //we know the suffixes are there and DO match.
+ if(strlen($curVersionSuffix) && strlen($checkVersionSuffix)) {
+ //okay, here's where we do some crazy things...
+ $curVersionData = $this->parse_suffix($curVersionSuffix);
+ $checkVersionData = $this->parse_suffix($checkVersionSuffix);
+
+ if($curVersionData['type'] == $checkVersionData['type']) {
+ //got the same suffix type (like "BETA"), check the number.
+ if($checkVersionData['number'] > $curVersionData['number']) {
+ //new version's suffix number higher than current...
+ $retval = TRUE;
+ }
+ elseif($checkVersionData['number'] == $curVersionData['number']) {
+ //new version's suffix number is EQUAL TO current...
+ $retval = FALSE;
+ }
+ else {
+ //new version's suffix number is LESS THAN current...
+ $retval = FALSE;
+ }
+ }
+ else {
+ //not the same suffix... see if the new one is higher.
+ $suffixValues = array_flip($this->suffixList);
+ if($suffixValues[$checkVersionData['type']] > $suffixValues[$curVersionData['type']]) {
+ $retval = TRUE;
+ }
+ else {
+ //current suffix type is higher...
+ }
+ }
+
+ }
+ elseif(strlen($curVersionSuffix) && !strlen($checkVersionSuffix)) {
+ //i.e. "1.0.0-BETA1" to "1.0.0" --->>> OKAY!
+ $retval = TRUE;
+ }
+ elseif(!strlen($curVersionSuffix) && strlen($checkVersionSuffix)) {
+ //i.e. "1.0.0" to "1.0.0-BETA1" --->>> NOT ACCEPTABLE!
+ }
+ }
+ else {
+ //no suffix to care about
+ }
+ }
+ }
+
+ return($retval);
+
+ }//end is_higher_version()
+ //=========================================================================
+
+
+
+ //=========================================================================
+ protected function parse_suffix($suffix) {
+ $retval = NULL;
+ if(strlen($suffix)) {
+ //determine what kind it is.
+ foreach($this->suffixList as $type) {
+ if(preg_match('/^'. $type .'/', $suffix)) {
+ $checkThis = preg_replace('/^'. $type .'/', '', $suffix);
+ if(strlen($checkThis) && is_numeric($checkThis)) {
+ //oooh... it's something like "BETA3"
+ $retval = array(
+ 'type' => $type,
+ 'number' => $checkThis
+ );
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid suffix (". $suffix .")");
+ }
+ break;
+ }
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": invalid suffix (". $suffix .")");
+ }
+
+ return($retval);
+ }//end parse_suffix()
+ //=========================================================================
+
+
}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-26 05:43:38
|
Revision: 11
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=11&view=rev
Author: crazedsanity
Date: 2009-01-26 05:43:34 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Remove some debugging statements.
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-26 05:39:00 UTC (rev 10)
+++ trunk/0.1/cs_version.abstract.class.php 2009-01-26 05:43:34 UTC (rev 11)
@@ -131,7 +131,6 @@
protected function auto_set_version_file() {
if(!strlen($this->versionFileLocation)) {
$bt = debug_backtrace();
- $gf = new cs_globalFunctions;
foreach($bt as $callNum=>$data) {
if(strlen($data['class'])) {
if($data['class'] != __CLASS__) {
@@ -142,8 +141,6 @@
elseif(preg_match('/test$/', $dir)) {
$dir = preg_replace('/\/test$/', '', $dir);
}
- $gf->debug_print(__METHOD__ .": going to use (". $dir .")");
- cs_debug_backtrace(1);
break;
}
}
@@ -152,7 +149,6 @@
}
}
- $gf = new cs_globalFunctions;
if(file_exists($dir .'/VERSION')) {
$this->set_version_file_location($dir .'/VERSION');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-26 05:39:04
|
Revision: 10
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=10&view=rev
Author: crazedsanity
Date: 2009-01-26 05:39:00 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Added some unit testing, test files, & example script for testing.
Added Paths:
-----------
trunk/0.1/tests/
trunk/0.1/tests/example_test.php
trunk/0.1/tests/files/
trunk/0.1/tests/files/version1
trunk/0.1/tests/files/version2
trunk/0.1/tests/files/version3
trunk/0.1/tests/testOfCSVersionParse.php
Added: trunk/0.1/tests/example_test.php
===================================================================
--- trunk/0.1/tests/example_test.php (rev 0)
+++ trunk/0.1/tests/example_test.php 2009-01-26 05:39:00 UTC (rev 10)
@@ -0,0 +1,19 @@
+<?php
+/*
+ * Created on Jan 25, 2009
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+
+require_once(dirname(__FILE__) .'/testOfCSVersionParse.php');
+
+$test = &new TestOfA2P();
+$test->run(new HtmlReporter())
+?>
Property changes on: trunk/0.1/tests/example_test.php
___________________________________________________________________
Added: svn:keywords
+ Id
HeadURL
Date
Revision
Author
Added: trunk/0.1/tests/files/version1
===================================================================
--- trunk/0.1/tests/files/version1 (rev 0)
+++ trunk/0.1/tests/files/version1 2009-01-26 05:39:00 UTC (rev 10)
@@ -0,0 +1,3 @@
+
+PROJECT: test1
+VERSION: 0.1.2-ALPHA8754
\ No newline at end of file
Added: trunk/0.1/tests/files/version2
===================================================================
--- trunk/0.1/tests/files/version2 (rev 0)
+++ trunk/0.1/tests/files/version2 2009-01-26 05:39:00 UTC (rev 10)
@@ -0,0 +1,3 @@
+
+PROJECT: test2
+VERSION: 5.4
\ No newline at end of file
Added: trunk/0.1/tests/files/version3
===================================================================
--- trunk/0.1/tests/files/version3 (rev 0)
+++ trunk/0.1/tests/files/version3 2009-01-26 05:39:00 UTC (rev 10)
@@ -0,0 +1,3 @@
+
+PROJECT: test3 stuff
+VERSION: 5.4.3-BETA5543
\ No newline at end of file
Added: trunk/0.1/tests/testOfCSVersionParse.php
===================================================================
--- trunk/0.1/tests/testOfCSVersionParse.php (rev 0)
+++ trunk/0.1/tests/testOfCSVersionParse.php 2009-01-26 05:39:00 UTC (rev 10)
@@ -0,0 +1,79 @@
+<?php
+/*
+ * Created on Jan 25, 2009
+ *
+ * FILE INFORMATION:
+ *
+ * $HeadURL$
+ * $Id$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ * $LastChangedRevision$
+ */
+
+
+
+class testOfCSVersionParse extends UnitTestCase {
+
+ function __construct() {
+ $this->gfObj = new cs_globalFunctions;
+ }//end __construct()
+
+
+ //--------------------------------------------------------------------------
+ function test_basics() {
+
+ $tests = array(
+ 'files/version1' => array(
+ '0.1.2-ALPHA8754',
+ 'test1',
+ array(
+ 'version_major' => 0,
+ 'version_minor' => 1,
+ 'version_maintenance' => 2,
+ 'version_suffix' => 'ALPHA8754'
+ )
+ ),
+ 'files/version2' => array(
+ '5.4.0',
+ 'test2',
+ array(
+ 'version_major' => 5,
+ 'version_minor' => 4,
+ 'version_maintenance' => 0,
+ 'version_suffix' => null
+ )
+ ),
+ 'files/version3' => array(
+ '5.4.3-BETA5543',
+ 'test3 stuff',
+ array(
+ 'version_major' => 5,
+ 'version_minor' => 4,
+ 'version_maintenance' => 3,
+ 'version_suffix' => 'BETA5543'
+ )
+ )
+ );
+
+ foreach($tests as $fileName=>$expectedArr) {
+ $ver = new middleTestClass();
+ $ver->set_version_file_location(dirname(__FILE__) .'/'. $fileName);
+
+ $this->assertEqual($expectedArr[0], $ver->get_version(), "Failed to match string from file (". $fileName .")");
+ $this->assertEqual($expectedArr[1], $ver->get_project(), "Failed to match project from file (". $fileName .")");
+
+ //now check that pulling the version as an array is the same...
+ $checkItArr = $ver->get_version(true);
+ $expectThis = $expectedArr[2];
+ $expectThis['version_string'] = $expectedArr[0];
+ }
+ }//end test_basics()
+ //--------------------------------------------------------------------------
+}
+
+
+class middleTestClass extends cs_versionAbstract {
+ function __construct(){}
+}
+?>
Property changes on: trunk/0.1/tests/testOfCSVersionParse.php
___________________________________________________________________
Added: svn:keywords
+ Id
HeadURL
Date
Revision
Author
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-26 05:37:16
|
Revision: 9
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=9&view=rev
Author: crazedsanity
Date: 2009-01-26 05:37:12 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Better finding of VERSION and PROJECT, and tries to auto-set location of VERSION.
/cs_version.abstract.class.php:
* get_version():
-- calls new method, auto_set_version_file() to try to automatically
set the version file location.
-- use preg_match() to find the line with "VERSION: "
-- better exception thrown if version couldn't be found.
* get_project():
-- call auto_set_version_file() to find VERSION file location.
-- use preg_match() to find project name, instead of arbitrary lines.
* auto_set_version_file() [NEW]:
-- using debug_backtrace, it finds the first class that is NOT itself,
and uses that to set as the folder to look for "VERSION" in; if the
folder ends with "test" or "tests", that folder is removed.
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-25 23:19:53 UTC (rev 8)
+++ trunk/0.1/cs_version.abstract.class.php 2009-01-26 05:37:12 UTC (rev 9)
@@ -25,18 +25,15 @@
*/
final public function get_version($asArray=false) {
$retval = NULL;
+
+ $this->auto_set_version_file();
+
if(file_exists($this->versionFileLocation)) {
- $myData = file($this->versionFileLocation);
+ $myMatches = array();
+ $findIt = preg_match('/VERSION: (.+)/', file_get_contents($this->versionFileLocation), $matches);
- //set the logical line number that the version string is on, and
- // drop by one to get the corresponding array index.
- $lineOfVersion = 3;
- $arrayIndex = $lineOfVersion -1;
-
- $myVersionString = trim($myData[$arrayIndex]);
-
- if(preg_match('/^VERSION: /', $myVersionString)) {
- $fullVersionString = preg_replace('/^VERSION: /', '', $myVersionString);
+ if($findIt == 1 && count($matches) == 2) {
+ $fullVersionString = $matches[1];
$pieces = explode('.', $fullVersionString);
$retval = array(
'version_major' => $pieces[0],
@@ -77,7 +74,8 @@
}
}
else {
- throw new exception(__METHOD__ .": failed to retrieve version string");
+ throw new exception(__METHOD__ .": failed to retrieve version string in file " .
+ "(". $this->versionFileLocation .")");
}
}
else {
@@ -94,18 +92,13 @@
//=========================================================================
final public function get_project() {
$retval = NULL;
+ $this->auto_set_version_file();
if(file_exists($this->versionFileLocation)) {
- $myData = file($this->versionFileLocation);
+ $myMatches = array();
+ $findIt = preg_match('/PROJECT: (.+)/', file_get_contents($this->versionFileLocation), $matches);
- //set the logical line number that the version string is on, and
- // drop by one to get the corresponding array index.
- $lineOfProject = 4;
- $arrayIndex = $lineOfProject -1;
-
- $myProject = trim($myData[$arrayIndex]);
-
- if(preg_match('/^PROJECT: /', $myProject)) {
- $retval = preg_replace('/^PROJECT: /', '', $myProject);
+ if($findIt == 1 && count($matches) == 2 && strlen($matches[1])) {
+ $retval = $matches[1];
}
else {
throw new exception(__METHOD__ .": failed to retrieve project string");
@@ -133,5 +126,43 @@
//=========================================================================
+
+ //=========================================================================
+ protected function auto_set_version_file() {
+ if(!strlen($this->versionFileLocation)) {
+ $bt = debug_backtrace();
+ $gf = new cs_globalFunctions;
+ foreach($bt as $callNum=>$data) {
+ if(strlen($data['class'])) {
+ if($data['class'] != __CLASS__) {
+ $dir = dirname($data['file']);
+ if(preg_match('/tests$/', $dir)) {
+ $dir = preg_replace('/\/tests$/', '', $dir);
+ }
+ elseif(preg_match('/test$/', $dir)) {
+ $dir = preg_replace('/\/test$/', '', $dir);
+ }
+ $gf->debug_print(__METHOD__ .": going to use (". $dir .")");
+ cs_debug_backtrace(1);
+ break;
+ }
+ }
+ else {
+ throw new exception(__METHOD__ .": failed to locate the calling class in backtrace");
+ }
+ }
+
+ $gf = new cs_globalFunctions;
+ if(file_exists($dir .'/VERSION')) {
+ $this->set_version_file_location($dir .'/VERSION');
+ }
+ else {
+ throw new exception(__METHOD__ .": failed to automatically set version file");
+ }
+ }
+ }//end auto_set_version_file()
+ //=========================================================================
+
+
}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-25 23:20:02
|
Revision: 8
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=8&view=rev
Author: crazedsanity
Date: 2009-01-25 23:19:53 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
Fix exception to be more useful.
/cs_version.abstract.class.php:
* get_version():
-- when no file set, say so instead of generically saying it was unable
to find version information.
Modified Paths:
--------------
trunk/0.1/cs_version.abstract.class.php
Modified: trunk/0.1/cs_version.abstract.class.php
===================================================================
--- trunk/0.1/cs_version.abstract.class.php 2009-01-04 19:22:01 UTC (rev 7)
+++ trunk/0.1/cs_version.abstract.class.php 2009-01-25 23:19:53 UTC (rev 8)
@@ -81,7 +81,8 @@
}
}
else {
- throw new exception(__METHOD__ .": failed to retrieve version information");
+ throw new exception(__METHOD__ .": failed to retrieve version information, file " .
+ "(". $this->versionFileLocation .") does not exist or was not set");
}
return($retval);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cra...@us...> - 2009-01-04 19:22:22
|
Revision: 7
http://cs-versionparse.svn.sourceforge.net/cs-versionparse/?rev=7&view=rev
Author: crazedsanity
Date: 2009-01-04 19:22:01 +0000 (Sun, 04 Jan 2009)
Log Message:
-----------
Added a credits file.
Added Paths:
-----------
trunk/0.1/CREDITS
Added: trunk/0.1/CREDITS
===================================================================
--- trunk/0.1/CREDITS (rev 0)
+++ trunk/0.1/CREDITS 2009-01-04 19:22:01 UTC (rev 7)
@@ -0,0 +1,3 @@
+
+Lead Developer: Dan Falconer (cra...@us...)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|