Skip to content

Commit

Permalink
Merge pull request #22 from woothee/prepare_v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
okonomi committed Aug 13, 2015
2 parents c029f66 + 09ca713 commit 964f6ac
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ php:
- 5.4
- 5.5
- 5.6
- 7
- hhvm

matrix:
allow_failures:
- php: 7
- php: hhvm

before_script:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"php": ">= 5.3.3"
},
"require-dev": {
"phpunit/phpunit": ">=4.1.0",
"satooshi/php-coveralls": ">=0.6.0",
"symfony/yaml": ">=2.4.0",
"fabpot/php-cs-fixer": ">=0.4.0"
"phpunit/phpunit": "4.8.*",
"satooshi/php-coveralls": "0.6.*",
"symfony/yaml": "2.7.*",
"fabpot/php-cs-fixer": "1.10.*"
},
"autoload": {
"psr-4": { "Woothee\\": "src/" }
Expand Down
13 changes: 13 additions & 0 deletions src/AgentCategory/Browser/SafariChrome.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ public static function challenge($ua, &$result)

$version = DataSet::VALUE_UNKNOWN;

$epos = strpos($ua, 'Edge');

if ($epos > -1) {
if (preg_match('#Edge/([.0-9]+)#', $ua, $matches)) {
$version = $matches[1];

static::updateMap($result, DataSet::get('Edge'));
static::updateVersion($result, $version);

return true;
}
}

$cpos = strpos($ua, 'Chrome');

if ($cpos === false) {
Expand Down
31 changes: 31 additions & 0 deletions src/AgentCategory/Browser/Webview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Woothee\AgentCategory\Browser;

use Woothee\AgentCategory\AbstractCategory;
use Woothee\DataSet;

class Webview extends AbstractCategory
{
public static function challenge($ua, &$result)
{
if (strpos($ua, 'like Mac OS X') < 0) {
return false;
}

$version = DataSet::VALUE_UNKNOWN;

if (preg_match('/iP(?:hone;|ad;|od) .*like Mac OS X/', $ua, $matches)) {
if (preg_match('#Version/([.0-9]+)#', $ua, $matches)) {
$version = $matches[1];
}

static::updateMap($result, DataSet::get('Webview'));
static::updateVersion($result, $version);

return true;
}

return false;
}
}
4 changes: 4 additions & 0 deletions src/AgentCategory/Crawler/Crawlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public static function challenge($ua, &$result)
} elseif (strpos($ua, 'facebookexternalhit') !== false) {
static::updateMap($result, DataSet::get('facebook'));

return true;
} elseif (strpos($ua, 'Twitterbot/') !== false) {
static::updateMap($result, DataSet::get('twitter'));

return true;
} elseif (strpos($ua, 'ichiro') !== false) {
if (strpos($ua, 'http://help.goo.ne.jp/door/crawler.html') !== false || strpos($ua, 'compatible; ichiro/mobile goo;') !== false) {
Expand Down
5 changes: 5 additions & 0 deletions src/AgentCategory/Os/SmartPhone.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static function challenge($ua, &$result)
$data = DataSet::get('Android');
} elseif (strpos($ua, 'CFNetwork') !== false) {
$data = DataSet::get('iOS');
} elseif (strpos($ua, 'BB10') !== false) {
$data = DataSet::get('BlackBerry10');
if (preg_match('#BB10(?:.+)Version/([.0-9]+)#', $ua, $matches)) {
$version = $matches[1];
}
} elseif (strpos($ua, 'BlackBerry') !== false) {
$data = DataSet::get('BlackBerry');
if (preg_match('/BlackBerry(?:\\d+)\/([.0-9]+) /', $ua, $matches) === 1) {
Expand Down
4 changes: 3 additions & 1 deletion src/AgentCategory/Os/Windows.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public static function challenge($ua, &$result)

$version = $matches[1];

if ($version === 'NT 6.3') {
if ($version === 'NT 10.0') {
$data = DataSet::get('Win10');
} elseif ($version === 'NT 6.3') {
$data = DataSet::get('Win8.1');
} elseif ($version === 'NT 6.2') {
$data = DataSet::get('Win8');
Expand Down
5 changes: 5 additions & 0 deletions src/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Woothee\AgentCategory\Browser\Opera;
use Woothee\AgentCategory\Browser\SafariChrome;
use Woothee\AgentCategory\Browser\Sleipnir;
use Woothee\AgentCategory\Browser\Webview;
use Woothee\AgentCategory\Crawler\Crawlers;
use Woothee\AgentCategory\Crawler\Google;
use Woothee\AgentCategory\Crawler\MayBeCrawler;
Expand Down Expand Up @@ -77,6 +78,10 @@ public function tryBrowser($ua, &$result)
return true;
}

if (Webview::challenge($ua, $result)) {
return true;
}

return false;
}

Expand Down
32 changes: 31 additions & 1 deletion src/DataSet.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Woothee;

// GENERATED from dataset.yml at Sun Oct 26 00:45:06 JST 2014 by okonomi
// GENERATED from dataset.yml at Thu Aug 13 20:42:56 JST 2015 by yuya
class DataSet
{
const DATASET_KEY_LABEL = 'label';
Expand Down Expand Up @@ -58,6 +58,12 @@ class DataSet
'type' => 'browser',
'vendor' => 'Microsoft',
),
'Edge' => array(
'label' => 'Edge',
'name' => 'Edge',
'type' => 'browser',
'vendor' => 'Microsoft',
),
'Chrome' => array(
'label' => 'Chrome',
'name' => 'Chrome',
Expand Down Expand Up @@ -88,12 +94,24 @@ class DataSet
'type' => 'browser',
'vendor' => 'Fenrir Inc.',
),
'Webview' => array(
'label' => 'Webview',
'name' => 'Webview',
'type' => 'browser',
'vendor' => 'OS vendor',
),
'Win' => array(
'label' => 'Win',
'name' => 'Windows UNKNOWN Ver',
'type' => 'os',
'category' => 'pc',
),
'Win10' => array(
'label' => 'Win10',
'name' => 'Windows 10',
'type' => 'os',
'category' => 'pc',
),
'Win8.1' => array(
'label' => 'Win8.1',
'name' => 'Windows 8.1',
Expand Down Expand Up @@ -238,6 +256,12 @@ class DataSet
'type' => 'os',
'category' => 'smartphone',
),
'BlackBerry10' => array(
'label' => 'BlackBerry10',
'name' => 'BlackBerry 10',
'type' => 'os',
'category' => 'smartphone',
),
'docomo' => array(
'label' => 'docomo',
'name' => 'docomo',
Expand Down Expand Up @@ -508,6 +532,12 @@ class DataSet
'type' => 'full',
'category' => 'crawler',
),
'twitter' => array(
'label' => 'twitter',
'name' => 'twitter',
'type' => 'full',
'category' => 'crawler',
),
'mixi' => array(
'label' => 'mixi',
'name' => 'mixi',
Expand Down

0 comments on commit 964f6ac

Please sign in to comment.