forked from ThaDafinser/UserAgentParserComparison
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b559d45
commit 521bc97
Showing
266 changed files
with
706,839 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,9 @@ $RECYCLE.BIN/ | |
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
.settings | ||
.buildpath | ||
.project | ||
vendor | ||
.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Martin Keckeis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# UserAgentParserComparison | ||
|
||
```php | ||
composer update -o | ||
|
||
bin/browscap build [version] | ||
|
||
bin/initCache.php | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
set_time_limit(- 1); | ||
ini_set('memory_limit', '256M'); | ||
chdir(dirname(__DIR__)); | ||
|
||
require 'vendor/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
include_once 'bootstrap.php'; | ||
|
||
/* | ||
* per cli parameter | ||
*/ | ||
if (! isset($filename)) { | ||
if (! isset($argv[1])) { | ||
throw new \Exception('parameter missing, usage: php generateMatrix.php myFile.php'); | ||
} | ||
|
||
$filename = $argv[1]; | ||
if (! file_exists($filename)) { | ||
throw new \Exception('file does not exists: ' . $filename); | ||
} | ||
} | ||
|
||
if (! isset($userAgents)) { | ||
$userAgents = include $filename; | ||
if (! is_array($userAgents)) { | ||
throw new \Exception('the data file does not return an array!'); | ||
} | ||
} | ||
|
||
if (isset($useFilename)) { | ||
$reportName = $useFilename; | ||
} else { | ||
$reportName = basename($filename); | ||
} | ||
$reportName = str_replace([ | ||
'.json', | ||
'.php' | ||
], '', $reportName); | ||
|
||
/* | ||
* include different datasets! | ||
*/ | ||
|
||
/* | ||
* do always the same - generate a matrix | ||
*/ | ||
|
||
use UserAgentParser\Provider; | ||
use UserAgentParserMatrix\Analyze; | ||
use UserAgentParserMatrix\GenerateSummary; | ||
use BrowscapPHP\Cache\BrowscapCache; | ||
use Doctrine\Common\Cache; | ||
use WurflCache\Adapter\File; | ||
use UserAgentParserMatrix\GenerateNotFound; | ||
|
||
/* | ||
* Providers | ||
*/ | ||
$cache = new File([ | ||
File::DIR => '.tmp/browscap_full' | ||
]); | ||
|
||
$browscapFull = new Provider\BrowscapPhp(); | ||
$browscapFull->setCache($cache); | ||
|
||
$cache = new Cache\PhpFileCache('.tmp/piwik'); | ||
$piwik = new Provider\PiwikDeviceDetector(); | ||
$piwik->setCache($cache); | ||
|
||
$chain = new Provider\Chain([ | ||
$browscapFull, | ||
new Provider\DonatjUAParser(), | ||
$piwik, | ||
new Provider\UAParser(), | ||
new Provider\WhichBrowser(), | ||
new Provider\Woothee(), | ||
new Provider\YzalisUAParser() | ||
]); | ||
|
||
$analyze = new Analyze(); | ||
$analyze->setUserAgents($userAgents); | ||
$analyze->setChainProvider($chain); | ||
$analyze->execute(); | ||
|
||
/* | ||
* create folder | ||
*/ | ||
$folder = 'results/' . $reportName; | ||
|
||
/* | ||
* Summary | ||
*/ | ||
$table = new GenerateSummary(); | ||
$table->setAnalyze($analyze); | ||
$table->setFolder($folder); | ||
$table->persist(); | ||
|
||
|
||
/* | ||
* Not found | ||
*/ | ||
$table = new GenerateNotFound(); | ||
$table->setAnalyze($analyze); | ||
$table->setFolder($folder); | ||
$table->persist(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
include_once 'bootstrap.php'; | ||
|
||
$handleAll = opendir('data'); | ||
if ($handleAll === false) { | ||
throw new \Exception('folder could not get opened'); | ||
} | ||
|
||
$generateFiles = []; | ||
|
||
while ($filename = readdir($handleAll)) { | ||
if ($filename == '.' || $filename == '..' || strpos($filename, '.php') === false) { | ||
continue; | ||
} | ||
|
||
$useFilename = str_replace('.php', '', $filename); | ||
|
||
$generateFiles[] = $useFilename; | ||
|
||
$userAgents = include 'data/' . $filename; | ||
if (! is_array($userAgents)) { | ||
throw new \Exception('could not load array from: ' . $filename); | ||
} | ||
|
||
echo '~~~Now dataset: ' . $useFilename . '~~~' . PHP_EOL; | ||
|
||
// generate | ||
require 'generateMatrix.php'; | ||
} | ||
closedir($handleAll); | ||
|
||
$htmlPart = '<h1>UserAgentParserComparison index'; | ||
$htmlPart .= '<h2>All results listed (different testsuites)</h2>'; | ||
|
||
$htmlPart .= '<table class="table table-bordered">'; | ||
|
||
$htmlPart .= '<tr>'; | ||
$htmlPart .= '<th>Testsuite</th>'; | ||
|
||
foreach ($chain->getProviders() as $provider) { | ||
$htmlPart .= '<th>' . $provider->getName() . '</th>'; | ||
} | ||
$htmlPart .= '</tr>'; | ||
|
||
foreach ($generateFiles as $file) { | ||
$htmlPart .= '<tr>'; | ||
|
||
$htmlPart .= '<th>' . $file . '</th>'; | ||
|
||
foreach ($chain->getProviders() as $provider) { | ||
$htmlPart .= '<td>'; | ||
$htmlPart .= '<a href="results/' . $file . '/summary.html">Summary</a><br />'; | ||
$htmlPart .= '<a href="results/' . $file . '/notFound_' . $provider->getName() . '.html">Not found</a>'; | ||
$htmlPart .= '</td>'; | ||
} | ||
|
||
$htmlPart .= '</tr>'; | ||
} | ||
$htmlPart .= '</table>'; | ||
|
||
/* | ||
* Index page | ||
*/ | ||
$html = <<<END | ||
<html> | ||
<head> | ||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> | ||
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | ||
</head> | ||
<body> | ||
$htmlPart | ||
</body> | ||
</html> | ||
END; | ||
|
||
file_put_contents('index.html', $html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
include 'bootstrap.php'; | ||
|
||
use BrowscapPHP\Browscap; | ||
use BrowscapPHP\Cache\BrowscapCache; | ||
use BrowscapPHP\Command; | ||
use BrowscapPHP\Exception; | ||
use WurflCache\Adapter\File; | ||
|
||
use DeviceDetector\DeviceDetector; | ||
use Doctrine\Common\Cache; | ||
|
||
/* | ||
* BrowscapPHP | ||
*/ | ||
/* | ||
* BrowscapPHP Lite | ||
*/ | ||
echo 'BrowscapPHP lite' . PHP_EOL; | ||
$cacheAdapter = new File(array( | ||
File::DIR => '.tmp/browscap_lite' | ||
)); | ||
$cache = new BrowscapCache($cacheAdapter); | ||
|
||
$parser = new Browscap(); | ||
$parser->setCache($cache); | ||
$parser->convertFile('vendor/browscap/browscap/build/php_browscap.ini'); | ||
|
||
/* | ||
* BrowscapPHP Full | ||
* this for full detection @see https://github.com/ThaDafinser/UserAgentParser/issues/3 | ||
*/ | ||
echo 'BrowscapPHP full' . PHP_EOL; | ||
$cacheAdapter = new File(array( | ||
File::DIR => '.tmp/browscap_full' | ||
)); | ||
$cache = new BrowscapCache($cacheAdapter); | ||
|
||
$parser = new Browscap(); | ||
$parser->setCache($cache); | ||
$parser->convertFile('vendor/browscap/browscap/build/full_php_browscap.ini'); | ||
|
||
/* | ||
* Piwik | ||
*/ | ||
echo 'PiwikDeviceDetector' . PHP_EOL; | ||
|
||
$dd = new DeviceDetector(); | ||
$dd->setCache(new Cache\PhpFileCache('.tmp/piwik')); | ||
$dd->setUserAgent('test'); | ||
$dd->parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "thadafinser/user-agent-parser-matrix", | ||
"description": "Generate a comparison matrix for different UserAgent parsers", | ||
"license": "MIT", | ||
|
||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
|
||
"authors": [ | ||
{ | ||
"name": "ThaDafinser", | ||
"email": "[email protected]" | ||
} | ||
], | ||
|
||
"autoload": { | ||
"psr-4": { | ||
"UserAgentParserMatrix\\": "src" | ||
} | ||
}, | ||
|
||
"require": { | ||
"thadafinser/user-agent-parser": ">=0.2.2,<1.0", | ||
|
||
"whichbrowser/testrunner": "^1.0" | ||
}, | ||
|
||
"require-dev": { | ||
"phpunit/PHPUnit": "^5.0", | ||
|
||
"fabpot/php-cs-fixer": "^1.10.0" | ||
} | ||
} |
Oops, something went wrong.