Skip to content
This repository was archived by the owner on Nov 7, 2020. It is now read-only.

Commit 6f44008

Browse files
committed
update bob
1 parent dbc9b05 commit 6f44008

File tree

5 files changed

+59
-84
lines changed

5 files changed

+59
-84
lines changed

build/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/src/
1+
/bob

build/build.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

build/lib/dev/domains.php renamed to build/builders/domain.php

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,64 @@
1717

1818
namespace blobfolio\dev;
1919

20+
use \blobfolio\bob\format;
21+
use \blobfolio\bob\io;
22+
use \blobfolio\bob\log;
2023
use \blobfolio\common\mb as v_mb;
2124
use \blobfolio\common\ref\sanitize as r_sanitize;
22-
use \blobfolio\bob\utility;
2325

24-
class domains extends \blobfolio\bob\base\build {
25-
const NAME = 'domains';
26+
class domain extends \blobfolio\bob\base\mike {
27+
// Project Name.
28+
const NAME = 'blob-domain';
29+
const DESCRIPTION = 'blob-domain is a simple PHP library for parsing and validating domain names. It supports the full Public Suffix ruleset, translates Unicode to ASCII or vice versa (if the PHP extension INTL is present), and can break down a host into its constituent parts: subdomain, domain, and suffix.';
30+
const CONFIRMATION = '';
31+
const SLUG = '';
2632

27-
// Intl should catch this, but just in case...
33+
// Runtime requirements.
2834
const REQUIRED_FUNCTIONS = array('idn_to_ascii');
29-
const DOWNLOADS = array('https://publicsuffix.org/list/public_suffix_list.dat');
3035

31-
// We aren't using binaries or build steps.
32-
const SKIP_BINARY_DEPENDENCIES = true;
33-
const SKIP_BUILD = false;
34-
const SKIP_FILE_DEPENDENCIES = true;
35-
const SKIP_PACKAGE = true;
36+
const REQUIRED_DOWNLOADS = array(
37+
'https://publicsuffix.org/list/public_suffix_list.dat',
38+
);
3639

37-
// MaxMind URLs.
38-
const DATA_TEMPLATE = BOB_BUILD_DIR . 'skel/data.template';
39-
const DATA_SOURCE = 'https://publicsuffix.org/list/public_suffix_list.dat';
40-
const DATA_OUT = BOB_ROOT_DIR . 'lib/blobfolio/domain/data.php';
40+
// Automatic setup.
41+
const CLEAN_ON_SUCCESS = false; // Delete tmp/bob when done.
42+
const SHITLIST = null; // Specific shitlist.
4143

44+
// Functions to run to complete the build, in order, grouped by
45+
// heading.
46+
const ACTIONS = array(
47+
'Updating Data'=>array(
48+
'build',
49+
),
50+
);
4251

4352

44-
// -----------------------------------------------------------------
45-
// Build
46-
// -----------------------------------------------------------------
4753

4854
/**
49-
* Build Tasks
55+
* Build
56+
*
57+
* This is actually pretty simple; we don't need a million different
58+
* callbacks to get it built. Haha.
5059
*
5160
* @return void Nothing.
5261
*/
53-
protected static function build_tasks() {
54-
utility::log('Loading data…');
62+
public static function build() {
63+
if (!defined('BOB_ROOT_DIR')) {
64+
log::error('Missing root dir.');
65+
}
5566

56-
// Load the data.
57-
$data = file_get_contents(static::$downloads[static::DATA_SOURCE]);
67+
log::print('Loading data…');
68+
69+
$data = io::get_url(static::REQUIRED_DOWNLOADS[0]);
5870

5971
// We want to cut out the ICANN bits. If these strings don't
6072
// exist, there's something wrong.
6173
if (
6274
(false === ($start = v_mb::strpos($data, '// ===BEGIN ICANN DOMAINS==='))) ||
6375
(false === ($end = v_mb::strpos($data, '// ===END ICANN DOMAINS===')))
6476
) {
65-
utility::log('Unexpected data was returned.', 'error');
77+
log::error('Unexpected data was returned.');
6678
}
6779

6880
// Chop and sanitize.
@@ -71,7 +83,7 @@ protected static function build_tasks() {
7183
$data = explode("\n", $data);
7284
$data = array_filter($data, 'strlen');
7385

74-
utility::log('Parsing data…');
86+
log::print('Parsing data…');
7587

7688
$suffixes = array();
7789
foreach ($data as $line) {
@@ -89,25 +101,34 @@ protected static function build_tasks() {
89101
}
90102

91103
// Note how many we found.
92-
static::print_record_count(count($suffixes));
104+
log::total(count($suffixes));
105+
106+
log::print('Exporting data…');
93107

94-
utility::log('Exporting data…');
108+
$template_file = BOB_ROOT_DIR . 'skel/data.template';
109+
$out_file = dirname(BOB_ROOT_DIR) . '/lib/blobfolio/domain/data.php';
95110

96-
$out = file_get_contents(static::DATA_TEMPLATE);
111+
$out = file_get_contents($template_file);
97112
$out = str_replace(
98113
array(
99114
'%GENERATED%',
100115
'%SUFFIXES%',
101116
),
102117
array(
103118
date('Y-m-d H:i:s'),
104-
utility::array_to_php($suffixes, 2),
119+
format::array_to_php($suffixes, 2),
105120
),
106121
$out
107122
);
108-
file_put_contents(static::DATA_OUT, $out);
123+
file_put_contents($out_file, $out);
109124
}
110125

126+
127+
128+
// -----------------------------------------------------------------
129+
// Helpers
130+
// -----------------------------------------------------------------
131+
111132
/**
112133
* Build Storage
113134
*
@@ -136,24 +157,5 @@ protected static function build_save(&$old, $new) {
136157
}
137158
}
138159

139-
// ----------------------------------------------------------------- end build
140-
141-
142-
143-
// -----------------------------------------------------------------
144-
// Helpers
145-
// -----------------------------------------------------------------
146-
147-
/**
148-
* Record Count
149-
*
150-
* @param int $count Count.
151-
* @return void Nothing.
152-
*/
153-
protected static function print_record_count(int $count) {
154-
$count = number_format($count, 0, '.', ',');
155-
utility::log("Total TLDs: $count", 'success');
156-
}
157-
158160
// ----------------------------------------------------------------- end helpers
159161
}

build/composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Build blob-domain package.",
44
"version": "0.1",
55
"type": "library",
6-
"homepage": "https:\/\/blobfolio.com\/",
6+
"homepage": "https:\/\/github.com\/Blobfolio\/blob-domain",
77
"license": "WTFPL",
88
"authors": [
99
{
@@ -19,17 +19,21 @@
1919
"repositories": [
2020
{
2121
"type": "vcs",
22-
"url": "https:\/\/github.com\/Blobfolio\/bob.git"
22+
"url": "ssh://git@blobfolio.com:3417/bob"
2323
}
2424
],
2525
"config": {
2626
"vendor-dir": "lib\/vendor",
2727
"preferred-install": "dist"
2828
},
29+
"scripts": {
30+
"post-update-cmd": "blobfolio\\bob\\himself::install",
31+
"post-install-cmd": "blobfolio\\bob\\himself::install"
32+
},
2933
"minimum-stability": "dev",
3034
"autoload": {
3135
"psr-4": {
32-
"blobfolio\\dev\\":"lib\/dev"
36+
"blobfolio\\dev\\":"builders"
3337
},
3438
"files": []
3539
}

lib/blobfolio/domain/data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Suffix Data
44
*
55
* This data was automatically generated by the build script on
6-
* 2018-05-11 21:36:32.
6+
* 2018-05-14 21:37:58.
77
*
88
* @see {build/build.php}
99
*

0 commit comments

Comments
 (0)