summaryrefslogtreecommitdiffstats
path: root/class/Parser.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-07-27 17:46:16 +0200
committerRemi Collet <fedora@famillecollet.com>2014-07-27 17:46:16 +0200
commit54774535fd7e067722a2cacc87faf30214ab9f5e (patch)
tree9f26fbf82322d3b311cbd28a95da04ac4fef8b82 /class/Parser.php
parente179552080b91ee49a10bbe8fce5ca2e7d1397c4 (diff)
Add Packagist parser
Diffstat (limited to 'class/Parser.php')
-rw-r--r--class/Parser.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/class/Parser.php b/class/Parser.php
index 31a000a..cdb984f 100644
--- a/class/Parser.php
+++ b/class/Parser.php
@@ -463,6 +463,55 @@ class Parser
}
/**
+ * Parse the content of all Packagist repository
+ *
+ * @param TableUpstream $uptable the table to write to
+ * @param TablePackagist $pktable the table to read from
+ *
+ * @return integer number of parsed line
+ */
+ static public function readPackagist(TableUpstream $uptable, TablePackagist $pktable)
+ {
+ self::log("Packagist search releases");
+ $pk = new PackagistClient();
+
+ $nb = $uptable->delete(array('type'=>'composer', 'channel'=>'packagist'));
+ self::log("Delete $nb packages");
+
+ $tot = 0;
+ foreach($pktable->request(array('ORDER'=>'rpmname')) as $rec) {
+ if ($rep = $pk->getPackage($rec['pkgname'])) {
+ $id = false;
+ if ($rep['stable']) {
+ $id = $uptable->record(
+ 'composer',
+ 'packagist',
+ $rec['rpmname'],
+ $rep['stable'],
+ true
+ );
+ }
+ if ($rep['unstable']) {
+ $id = $uptable->record(
+ 'composer',
+ 'packagist',
+ $rec['rpmname'],
+ $rep['unstable'],
+ false,
+ $rep['state']
+ );
+ }
+ if ($id) {
+ $tot++;
+ }
+ }
+ }
+ self::log("Write $tot packages");
+
+ return $tot;
+ }
+
+ /**
* Parse the content of all PEAR repository
*
* @param TableUpstream $uptable the table to write to