コード例 #1
0
 /**
  * @throws  \BuildException
  */
 public function main()
 {
     GemsAssert::noneEmptyString($this->file, "File parameter not set.");
     $text = GemsFile::read($this->file);
     $lines = GemsFile::toArray($text);
     $version = GemsVersion::get($lines);
     $str = self::inc($version);
     // replace last line with new version
     $text = _::create($lines)->snip(1)->push($str)->join(PHP_EOL);
     GemsFile::write($this->file, $text);
 }
コード例 #2
0
ファイル: GemsVersion.php プロジェクト: thinkingmedia/phing
 /**
  * Reads the version number from a string
  *
  * @param string $text
  *
  * @return array
  * @throws \BuildException
  */
 public static function get($text)
 {
     $lines = GemsFile::toArray($text);
     // read the last line
     $version = trim(array_pop($lines));
     GemsAssert::notEmpty($version, "Last line of version file is empty.");
     GemsLog::log("Version: {$version}");
     // read the build number
     $numbers = explode('.', $version);
     GemsAssert::areEqual(count($numbers), 3, "Bad version format. Must be major.minor.build format.");
     GemsAssert::isTruthy(_::create($numbers)->all(function ($n) {
         return is_numeric($n);
     }), "Bad version format. Must 3 numeric values.");
     return _::create($numbers)->map(function ($n) {
         return (int) $n;
     });
 }