Skip to content

Commit

Permalink
Doc and CS fixes;
Browse files Browse the repository at this point in the history
Added scanoptions.php;

Regenerated package.xml.
  • Loading branch information
boenrobot committed May 22, 2017
1 parent 0eaac86 commit 8af33b0
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 94 deletions.
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
README.md export-ignore
README export-ignore
README.md export-ignore
CREDITS export-ignore
RELEASE-* export-ignore
extrasetup.php export-ignore
package.xml export-ignore
packagexmlsetup.php export-ignore
extrasetup.php export-ignore
scanoptions.php export-ignore
2 changes: 1 addition & 1 deletion docs/wiki
Submodule wiki updated from fc21ec to 5025c7
File renamed without changes.
19 changes: 19 additions & 0 deletions examples/Script/prepare.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';

$util = new RouterOS\Util(
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password')
);
$util->setMenu('/system scheduler')->add(
array(
'name' => 'logger',
'interval' => '1m',
'on-event' => RouterOS\Script::prepare(
'/log info $phpver',
array(
'phpver' => phpversion()
)
)
)
);
10 changes: 10 additions & 0 deletions examples/Util/edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
use PEAR2\Net\RouterOS;

require_once 'PEAR2/Autoload.php';

$util = new RouterOS\Util(
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password')
);
$util->setMenu('/ip arp');
$util->edit(0, 'address', '192.168.88.103');
1 change: 1 addition & 0 deletions examples/Util/set-multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$util->setMenu('/ip arp');
$util->set(
$util->find(
0,
function ($response) {
//Matches any item with a comment that starts with two digits
return preg_match('/^\d\d/', $response->getArgument('comment'));
Expand Down
2 changes: 1 addition & 1 deletion extrasetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'pear2.php.net' => array(
'PEAR2_Autoload',
'PEAR2_Cache_SHM',
'PEAR2_Net_Transmitter',
'PEAR2_Console_CommandLine',
'PEAR2_Console_Color'
)
Expand All @@ -33,7 +34,6 @@
foreach ($channelPackages as $package) {
foreach ($registry->toPackage($package, $channel)->installcontents
as $file => $info) {
var_dump($package, $file);
if (strpos($file, 'php/') === 0 || strpos($file, 'src/') === 0) {
$filename = substr($file, 4);
$extrafiles['src/' . $filename]
Expand Down
46 changes: 41 additions & 5 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2016-11-07</date>
<time>03:50:39</time>
<date>2017-05-22</date>
<time>15:41:15</time>
<version>
<release>1.0.0b6</release>
<api>1.0.0</api>
Expand All @@ -37,6 +37,8 @@
- newRequest()
* Script::escapeString() no longer escapes bytes above 0x7F. This means that parameter string values are now influenced by charset settings, and thus no additional conversion is necessary. A new second argument can be set to TRUE to escape all bytes, including the previously untouched ASCII alphanumeric characters and underscores.
* Stream parameters in Script::append() (and inherently, Script::prepare() and Util::exec()) now have ALL bytes escaped.
* Script::escapeValue() converts NULL to &quot;nil&quot; instead of &quot;nothing&quot;.
* The $params array in Script::append() can declare variables with a value of type &quot;nothing&quot; by using numeric keys, and the variable names as values.
* Script::parseValue() now supports letter notation for time (1h2m3s), not just double colon notation (01:02:03), modeled after RouterOS. Related to that is also that leading zeroes, and zero minutes and seconds are now optional (e.g. &quot;1:&quot; is a valid way of saying 1 hour). Sub-second information is rounded up to the nearest second on current PHP versions (future versions are expected to support sub-second information in DateInterval by allowing seconds to be a double; The code currently attempts to give DateInterval a double, falling back to rounding to a second).
* Script::parseValue() now recognizes dates in the &quot;M/d/Y H:i:s&quot; format (used across RouterOS), and turns that into a DateTime object for that time (or midnight in UTC if the time part is omitted).
* Util::getAll() now throws a NotSupportedException if the arguments &quot;follow&quot;, &quot;follow-only&quot; or &quot;count-only&quot; are used. The first two, because PHP would hang (since Client::sendSync() is used under the hood), and the last one because it's unredable in the returned output (use Util::count() instead).
Expand All @@ -58,6 +60,21 @@
</file>
</dir>
<dir name="docs" baseinstalldir="/">
<dir name="wiki">
<file role="doc" name="Approaches-with-Client.md"/>
<file role="doc" name="Getting-started.md"/>
<file role="doc" name="Home.md"/>
<file role="doc" name="Manipulating-RouterOS-data-using-Client.md"/>
<file role="doc" name="Optional-features.md"/>
<file role="doc" name="Roscon.md"/>
<file role="doc" name="Script-composition-and-parsing.md"/>
<file role="doc" name="Shortcuts.md"/>
<file role="doc" name="Using-queries.md"/>
<file role="doc" name="Util-basics.md"/>
<file role="doc" name="Util-extras.md"/>
<file role="doc" name="_Footer.md"/>
<file role="doc" name="_Sidebar.md"/>
</dir>
<file role="doc" name="apigen.neon">
<tasks:replace type="pear-config" to="php_dir" from="../src"/>
</file>
Expand All @@ -79,9 +96,14 @@
<file role="doc" name="sync-request-arguments.php"/>
<file role="doc" name="sync-request-simple.php"/>
</dir>
<dir name="Script">
<file role="doc" name="parseValue.php"/>
<file role="doc" name="prepare.php"/>
</dir>
<dir name="Util">
<file role="doc" name="add.php"/>
<file role="doc" name="count.php"/>
<file role="doc" name="edit.php"/>
<file role="doc" name="enable_disable_remove.php"/>
<file role="doc" name="exec-basic.php"/>
<file role="doc" name="exec-params.php"/>
Expand All @@ -94,7 +116,6 @@
<file role="doc" name="get-number.php"/>
<file role="doc" name="getAll.php"/>
<file role="doc" name="move.php"/>
<file role="doc" name="parseValue.php"/>
<file role="doc" name="set-multiple.php"/>
<file role="doc" name="set-single.php"/>
</dir>
Expand Down Expand Up @@ -381,7 +402,7 @@
<package>
<name>PEAR2_Console_CommandLine</name>
<channel>pear2.php.net</channel>
<min>0.2.1</min>
<min>0.2.2</min>
</package>
<package>
<name>PEAR2_Console_Color</name>
Expand All @@ -400,14 +421,30 @@
<install name="docs/doxygen.ini" as="doxygen.ini"/>
<install name="docs/phpdoc.dist.xml" as="phpdoc.dist.xml"/>
<install name="docs/sami.php" as="sami.php"/>
<install name="docs/wiki/Approaches-with-Client.md" as="wiki/Approaches-with-Client.md"/>
<install name="docs/wiki/Getting-started.md" as="wiki/Getting-started.md"/>
<install name="docs/wiki/Home.md" as="wiki/Home.md"/>
<install name="docs/wiki/Manipulating-RouterOS-data-using-Client.md" as="wiki/Manipulating-RouterOS-data-using-Client.md"/>
<install name="docs/wiki/Optional-features.md" as="wiki/Optional-features.md"/>
<install name="docs/wiki/Roscon.md" as="wiki/Roscon.md"/>
<install name="docs/wiki/Script-composition-and-parsing.md" as="wiki/Script-composition-and-parsing.md"/>
<install name="docs/wiki/Shortcuts.md" as="wiki/Shortcuts.md"/>
<install name="docs/wiki/Using-queries.md" as="wiki/Using-queries.md"/>
<install name="docs/wiki/Util-basics.md" as="wiki/Util-basics.md"/>
<install name="docs/wiki/Util-extras.md" as="wiki/Util-extras.md"/>
<install name="docs/wiki/_Footer.md" as="wiki/_Footer.md"/>
<install name="docs/wiki/_Sidebar.md" as="wiki/_Sidebar.md"/>
<install name="examples/Client/callback-and-loop.php" as="examples/Client/callback-and-loop.php"/>
<install name="examples/Client/loop-and-extract.php" as="examples/Client/loop-and-extract.php"/>
<install name="examples/Client/send-and-complete.php" as="examples/Client/send-and-complete.php"/>
<install name="examples/Client/send-and-forget.php" as="examples/Client/send-and-forget.php"/>
<install name="examples/Client/sync-request-arguments.php" as="examples/Client/sync-request-arguments.php"/>
<install name="examples/Client/sync-request-simple.php" as="examples/Client/sync-request-simple.php"/>
<install name="examples/Script/parseValue.php" as="examples/Script/parseValue.php"/>
<install name="examples/Script/prepare.php" as="examples/Script/prepare.php"/>
<install name="examples/Util/add.php" as="examples/Util/add.php"/>
<install name="examples/Util/count.php" as="examples/Util/count.php"/>
<install name="examples/Util/edit.php" as="examples/Util/edit.php"/>
<install name="examples/Util/enable_disable_remove.php" as="examples/Util/enable_disable_remove.php"/>
<install name="examples/Util/exec-basic.php" as="examples/Util/exec-basic.php"/>
<install name="examples/Util/exec-params.php" as="examples/Util/exec-params.php"/>
Expand All @@ -420,7 +457,6 @@
<install name="examples/Util/get-number.php" as="examples/Util/get-number.php"/>
<install name="examples/Util/getAll.php" as="examples/Util/getAll.php"/>
<install name="examples/Util/move.php" as="examples/Util/move.php"/>
<install name="examples/Util/parseValue.php" as="examples/Util/parseValue.php"/>
<install name="examples/Util/set-multiple.php" as="examples/Util/set-multiple.php"/>
<install name="examples/Util/set-single.php" as="examples/Util/set-single.php"/>
<install name="scripts/roscon" as="roscon"/>
Expand Down
12 changes: 9 additions & 3 deletions packagexmlsetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@

$oldCwd = getcwd();
chdir(__DIR__);
$package->setRawRelease('php', '');
$release = $package->getReleaseToInstall('php');
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'.',
Expand All @@ -112,8 +114,12 @@
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
$filename = substr($path->getPathname(), 2);
$cFilename = str_replace('src/', 'php/', $filename);
if ('.git' === $path->getFilename()) {
continue;
}

$filename = substr($path->getPathname(), 2);
$cFilename = str_replace('src/', 'php/', $filename);

if (isset($package->files[$filename])) {
$parsedFilename = pathinfo($filename);
Expand All @@ -135,7 +141,7 @@
$as = substr($as, 0, -4);
}
}
$package->getReleaseToInstall('php')->installAs($filename, $as);
$release->installAs($filename, $as);

$contents = file_get_contents($filename);
foreach ($config['replace'] as $from => $attribs) {
Expand Down
36 changes: 36 additions & 0 deletions scanoptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* File scanoptions.php for PEAR2_Net_RouterOS.
*
* PHP version 5.3
*
* @category Net
* @package PEAR2_Net_RouterOS
* @author Vasil Rangelov <[email protected]>
* @copyright 2011 Vasil Rangelov
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version GIT: $Id$
* @link http://pear2.php.net/PEAR2_Net_RouterOS
*/

$scanoptions = array(
'ignore' => array()
);
$oldCwd = getcwd();
chdir(__DIR__);
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'.',
RecursiveDirectoryIterator::UNIX_PATHS
| RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
if ('.git' === $path->getFilename()) {
$scanoptions['ignore'][$path->getRealPath()]
= $path->isDir() ? 'dir' : 'file';
}
}
chdir($oldCwd);
return $scanoptions;
Loading

0 comments on commit 8af33b0

Please sign in to comment.