/** * Planet クロールする **/ public static function __setup_crawl__() { $http_feed = new Feed(); foreach (C(PlanetSubscription)->find_all() as $subscription) { Exceptions::clear(); Log::debug(sprintf('[crawl] feed: %d (%s)', $subscription->id(), $subscription->title())); try { $feed = $http_feed->do_read($subscription->rss_url()); $subscription->title($feed->title()); if ($feed->is_link()) { $subscription->link(self::_get_link_href($feed->link())); } $subscription->rss_url($http_feed->url()); $subscription->save(true); foreach ($feed->entry() as $entry) { Exceptions::clear(); try { $planet_entry = new PlanetEntry(); $planet_entry->subscription_id($subscription->id()); $planet_entry->title(Tag::cdata($entry->title())); $planet_entry->description(Text::htmldecode(Tag::cdata($entry->fm_content()))); $planet_entry->link($entry->first_href()); $planet_entry->updated($entry->published()); $planet_entry->save(); } catch (Exception $e) { Log::warn($e->getMessage()); } } } catch (Exception $e) { Log::error($e); } } }
private static final function execute(InfoMethod $m, $block_name, $class, $is_setup, $is_teardown) { if (!$m->is_test() && $m->is_public()) { return self::$result[self::$current_file][self::$current_class][self::$current_method][$m->line()][] = array("none"); } $result = $line = ""; try { foreach ($m->test() as $line => $test) { if ($block_name === null || $test->name() === $block_name) { ob_start(); $exception = null; if ($is_setup) { call_user_func(array($class, "__test_setup__")); } try { eval(str_repeat("\n", $line) . $test->test()); } catch (Exception $e) { $exception = $e; } if ($is_teardown) { call_user_func(array($class, "__test_teardown__")); } if (isset($exception)) { throw $exception; } $result = ob_get_clean(); if (preg_match("/(Parse|Fatal) error:.+/", $result, $match)) { throw new ErrorException($match[0]); } } Exceptions::clear(); } print $result; } catch (Exception $e) { if (ob_get_level() > 0) { $result = ob_get_clean(); } if (preg_match("/^[\\s]+/ms", $test->test(), $match)) { $line = $line + substr_count($match[0], "\n"); } self::$result[self::$current_file][self::$current_class][self::$current_method][$line][] = array("exception", $e->getMessage(), $e->getFile(), $e->getLine()); Log::warn("[" . $e->getFile() . ":" . $e->getLine() . "] " . $e->getMessage()); } }