Skip to content

Commit

Permalink
user_agents.json -> user_agents.dist.json
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Mar 16, 2021
1 parent a166c2d commit 3b5aebb
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ vendor/
composer.lock
coverage.xml
phpunit.xml

tests/user_agents.json
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ test:

.PHONY: generate
generate:
php bin/user_agent_sorter.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.json
php bin/user_agent_sorter.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.dist.json
php bin/constant_generator.php

.PHONY: init
init:
php bin/init_user_agent.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.json
php bin/init_user_agent.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.dist.json
make generate
2 changes: 1 addition & 1 deletion bin/benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

$time = microtime(true);

$uas = json_decode(file_get_contents(__DIR__ . '/../tests/user_agents.json'), true);
$uas = json_decode(file_get_contents(__DIR__ . '/../tests/user_agents.dist.json'), true);


foreach( $uas as $ua => $junk ) {
Expand Down
2 changes: 1 addition & 1 deletion bin/constant_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require __DIR__ . '/../vendor/autoload.php';

$jsonfile = __DIR__ . '/../tests/user_agents.json';
$jsonfile = __DIR__ . '/../tests/user_agents.dist.json';

$uas = json_decode(
file_get_contents($jsonfile),
Expand Down
2 changes: 1 addition & 1 deletion bin/init_user_agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require(__DIR__ . '/../vendor/autoload.php');

$jsonfile = __DIR__ . '/../Tests/user_agents.json';
$jsonfile = __DIR__ . '/../Tests/user_agents.dist.json';

$uas = json_decode(file_get_contents($jsonfile), true);

Expand Down
2 changes: 1 addition & 1 deletion bin/user_agent_sorter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require(__DIR__ . '/../vendor/autoload.php');

$jsonfile = __DIR__ . '/../Tests/user_agents.json';
$jsonfile = __DIR__ . '/../Tests/user_agents.dist.json';

$uas = json_decode(file_get_contents($jsonfile), true);

Expand Down
7 changes: 6 additions & 1 deletion tests/UserAgentParserFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ public function test_parse_user_agent( $string, $expected ) {

public function userAgentDataProvider() {
$out = array();
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
if( filesize(__DIR__ . '/user_agents.json') > 0 ) {
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
} else {
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.dist.json'), true);
}

foreach( $uas as $string => $parts ) {
$out[] = array( $string, $parts );
}
Expand Down
7 changes: 6 additions & 1 deletion tests/UserAgentParserObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ class UserAgentParserObjectTest extends \PHPUnit\Framework\TestCase {

public function userAgentDataProvider() {
$out = array();
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
if( filesize(__DIR__ . '/user_agents.json') > 0 ) {
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
} else {
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.dist.json'), true);
}

foreach( $uas as $string => $parts ) {
$out[] = array( $string );
}
Expand Down
File renamed without changes.

0 comments on commit 3b5aebb

Please sign in to comment.