/** * ライブラリのクラス一覧を返す * @param $in_vendor * @return array */ function get_classes($in_vendor = false) { return Lib::classes(true, $in_vendor); }
/** * 定義名のリスト * @param Request $req * @param string $value */ public static function __setup_def__(Request $req, $value) { $libs = array_keys(Lib::classes(true, true)); $list = array(); foreach ($libs as $path) { $ref = new InfoClass($path, false); foreach ($ref->def() as $def) { $list[$def->name()] = '(' . $def->fm_type() . ') ' . $def->document(); } } $len = Text::length(array_keys($list)); self::info_print("Define list:"); foreach ($list as $k => $v) { self::println(" " . str_pad($k, $len) . " : " . $v); } }
private static function lib($repository) { if (!$repository->start("lib")) { return; } foreach (Lib::classes(true) as $class_path => $class) { $i = new InfoClass($class_path, false); $base_dir = Lib::path(); $search_path = File::absolute($base_dir, str_replace(".", "/", $i->package())); $target = is_file($search_path . ".php") ? $search_path . ".php" : (is_file($search_path . "/" . basename($search_path) . ".php") ? $search_path : null); if ($target !== null) { $tgz_filename = $repository->tgz_path($i->package()); File::tgz($tgz_filename, $target, $base_dir); touch($tgz_filename, File::last_update($target)); $repository->add($i->package(), $i->name(), File::last_update($i->path()), $i->document()); } } }
/** * ディエクトリパスを指定してテストを実行する * @param string $path * @return Test */ public static final function verifies() { foreach (Lib::classes(true) as $path => $class) { self::verify($path); } if (is_dir(self::path())) { foreach (File::ls(self::path(), true) as $f) { $dir = str_replace(self::path(), "", $f->directory()); if (substr($dir, 0, 1) == "/") { $dir = substr($dir, 1); } if (substr($dir, -1) == "/") { $dir = substr($dir, 0, -1); } self::verify(str_replace("/", ".", empty($dir) ? "" : $dir . ".") . preg_replace("/_test\$/", "", $f->oname())); } } return new self(); }
/** * vendorsを更新する */ public static function vendors_update() { self::set_path(); if (is_dir(self::$vendor_path)) { File::rm(self::$vendor_path, false); } foreach (Lib::classes(true, true) as $key => $class) { Lib::import($key); } foreach (File::ls(App::path()) as $f) { if ($f->is_ext('php')) { $src = File::read($f); if (preg_match_all("/[^\\w](import|R|C)\\(([\"\\'])(.+?)\\2\\)/", $src, $match)) { foreach ($match[3] as $path) { try { self::import(trim($path)); } catch (Exception $e) { } } } if (Tag::setof($tag, $src, 'app')) { if (preg_match_all("/[^\\w]class=([\"\\'])(.+?)\\1/", $src, $match)) { foreach ($match[2] as $path) { try { self::import(trim($path)); } catch (Exceptions $e) { } } } } } } }