Skip to content

Instantly share code, notes, and snippets.

@co3k
Created September 5, 2011 11:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save co3k/1194705 to your computer and use it in GitHub Desktop.
Save co3k/1194705 to your computer and use it in GitHub Desktop.
バンドルプラグインリストのデータを読み込み、 OpenPNE の各メジャーバージョンの最新のマイナーバージョンにどのプラグインのどのバージョンがバンドルされているかをリストするやつ
<?php
// To run, you need the Symfony\Yaml and Symfony\ClassLoader.
// You can get these libraries from PEAR installer by the followings:
// $ pear channel-discover pear.symfony.com
// $ pear install symfony2/Yaml
require_once 'Symfony/Component/Yaml/Yaml.php';
require_once 'Symfony/Component/Yaml/Parser.php';
require_once 'Symfony/Component/Yaml/Inline.php';
require_once 'Symfony/Component/Yaml/Dumper.php';
require_once 'Symfony/Component/Yaml/Escaper.php';
require_once 'Symfony/Component/Yaml/Unescaper.php';
require_once 'Symfony/Component/Yaml/Exception/ExceptionInterface.php';
require_once 'Symfony/Component/Yaml/Exception/DumpException.php';
require_once 'Symfony/Component/Yaml/Exception/ParseException.php';
use Symfony\Component\Yaml\Yaml;
function get_major_version($full_version)
{
return preg_filter('/^([0-9]+\.[0-9]+)\.?.*$/', '$1', $full_version);
}
$pattern = '/Users/co3k/Documents/openpne/bundled-plugins-list/*.yml';
$latest_minor = array();
$bundled_version_table = array();
$result = array();
$it = new GlobIterator($pattern);
foreach ($it as $file) {
$op3_version = $file->getBasename('.'.$file->getExtension());
// create bundled version list
$list = Yaml::parse((string)$file);
foreach ($list as $plugin_name => $plugin_info) {
$bundled_version_table[$plugin_name][$plugin_info['version']][] = $op3_version;
}
// calc latest minor versions of OpenPNE3
if (false !== strpos($op3_version, '-dev')) { // skip development version
continue;
}
$major = get_major_version($op3_version);
if ($major * 10 % 2) {
continue; // skip unstable version
}
if (!isset($latest_minor[$major])) {
$latest_minor[$major] = $op3_version;
continue;
}
// compare with registered op3_version
if (version_compare($latest_minor[$major], $op3_version, '<')) {
$latest_minor[$major] = $op3_version;
}
}
sort($latest_minor); // covert this array to indexed
foreach ($bundled_version_table as $plugin_name => $plugin_versions) {
$result[$plugin_name] = array();
foreach ($plugin_versions as $plugin_version => $op3_versions) {
$bundled_versions = array_intersect($op3_versions, $latest_minor);
if ($bundled_versions) {
sort($bundled_versions); // reset
$result[$plugin_name][$plugin_version] = $bundled_versions;
}
}
}
echo Yaml::dump($result);
/**
Result of 2011/09/05 20:03 JST
opOpenSocialPlugin:
0.8.2.1: [3.0.8.4]
0.9.9.2: [3.2.7.5]
0.9.12: [3.4.15]
1.2.6: [3.6beta13]
opDiaryPlugin:
0.8.1: [3.0.8.4]
1.0.0.2: [3.2.7.5]
1.2.0.2: [3.4.15]
1.3.2.1: [3.6beta13]
opMessagePlugin:
0.8.2.4: [3.0.8.4]
0.9.1.1: [3.2.7.5]
0.9.2.1: [3.4.15]
0.9.2: [3.6beta13]
opAshiatoPlugin:
0.8.0.1: [3.0.8.4]
0.9.0.1: [3.2.7.5, 3.4.15]
0.9.1.2: [3.6beta13]
opAuthMailAddressPlugin:
1.0.0: [3.0.8.4]
1.1.4.1: [3.2.7.5]
1.2.1: [3.4.15]
1.3.3: [3.6beta13]
opAuthMobileUIDPlugin:
1.0.0: [3.0.8.4, 3.2.7.5]
1.0.0.1: [3.4.15]
1.3.2: [3.6beta13]
opAuthOpenIDPlugin:
1.0.0: [3.0.8.4]
1.1.1: [3.2.7.5, 3.4.15]
1.3.0: [3.6beta13]
opCommunityTopicPlugin:
0.8.1: [3.0.8.4]
0.9.8.1: [3.2.7.5, 3.4.15]
1.0.1.1: [3.6beta13]
opIntroFriendPlugin:
0.8.0.1: [3.0.8.4]
0.9.2.1: [3.6beta13]
opWebAPIPlugin:
0.1.0: [3.0.8.4]
0.4.0: [3.2.7.5]
0.5.0: [3.4.15, 3.6beta13]
opBlogPlugin:
0.9.0: [3.2.7.5, 3.4.15]
1.0.1: [3.6beta13]
opAlbumPlugin:
0.9.3.1: [3.2.7.5]
0.9.4.1: [3.4.15, 3.6beta13]
opFavoritePlugin:
1.0.0.4: [3.6beta13]
opRankingPlugin:
1.0.0.1: [3.6beta13]
*/
@co3k
Copy link
Author

co3k commented Sep 5, 2011

プラグインの各バージョンがどの OpenPNE 3のバージョンに対応しているかを容易に把握するためと、

urabe: そうだ エビちゃんのMLみて思ったけど ブログプラグインもそうだ
urabe: うべー
Co3k (Kousuke) Ebihara: なんと
urabe: スキーマできたので、あ・・あげれない っとなったんだった

という発言を受けて、同様の問題が他に存在するかどうかを把握して ML に報告するつもりで作りましたが、後者の目的についてはこのアプローチじゃダメだということに作った後で気がついてうかつすぎて悲しいです。

@co3k
Copy link
Author

co3k commented Sep 5, 2011

ライセンス書き漏れていましたが MIT License とします。

@co3k
Copy link
Author

co3k commented Sep 5, 2011

動作には Symfony2 の Yaml コンポーネントと 25 行目の

$pattern = '/Users/co3k/Documents/openpne/bundled-plugins-list/*.yml';

の書き換え、それから PHP 5.3 が必要です。ほんと雑ですいません。

@co3k
Copy link
Author

co3k commented Oct 28, 2011

とりあえず最新情報

opOpenSocialPlugin:
0.8.2.1: [3.0.8.5]
0.9.9.2: [3.2.7.6]
0.9.13: [3.4.16]
1.2.6: [3.6.0]
opDiaryPlugin:
0.8.1: [3.0.8.5]
1.0.0.2: [3.2.7.6]
1.2.0.2: [3.4.16]
1.4.0.1: [3.6.0]
opMessagePlugin:
0.8.2.4: [3.0.8.5]
0.9.1.1: [3.2.7.6]
0.9.2.1: [3.4.16]
0.9.2: [3.6.0]
opAshiatoPlugin:
0.8.0.1: [3.0.8.5]
0.9.0.1: [3.2.7.6, 3.4.16]
1.1.0: [3.6.0]
opAuthMailAddressPlugin:
1.0.0: [3.0.8.5]
1.1.4.1: [3.2.7.6]
1.2.1: [3.4.16]
1.3.4: [3.6.0]
opAuthMobileUIDPlugin:
1.0.0: [3.0.8.5, 3.2.7.6]
1.0.0.1: [3.4.16]
1.3.2: [3.6.0]
opAuthOpenIDPlugin:
1.0.0: [3.0.8.5]
1.1.1: [3.2.7.6, 3.4.16]
1.3.0: [3.6.0]
opCommunityTopicPlugin:
0.8.1: [3.0.8.5]
0.9.8.1: [3.2.7.6, 3.4.16]
1.0.2.2: [3.6.0]
opIntroFriendPlugin:
0.8.0.1: [3.0.8.5]
1.0.0: [3.6.0]
opWebAPIPlugin:
0.1.0: [3.0.8.5]
0.4.0: [3.2.7.6]
0.5.1: [3.4.16, 3.6.0]
opBlogPlugin:
0.9.0: [3.2.7.6, 3.4.16]
1.0.1: [3.6.0]
opAlbumPlugin:
0.9.3.1: [3.2.7.6]
0.9.4.1: [3.4.16, 3.6.0]
opFavoritePlugin:
1.0.1: [3.6.0]
opRankingPlugin:
1.0.1: [3.6.0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment