/**
  * @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);
 }
Exemple #2
0
 /**
  * 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;
     });
 }
 /**
  * @param $dir
  *
  * @return _
  */
 public static function recursive($dir)
 {
     $arr = [];
     self::walk($arr, $dir);
     return _::create($arr);
 }