Skip to content

Commit

Permalink
backup bin files
Browse files Browse the repository at this point in the history
  • Loading branch information
bwinkers committed Jan 28, 2018
1 parent 5b91421 commit aab8168
Show file tree
Hide file tree
Showing 14 changed files with 4,485 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/bin/convertCSVToProperties.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

// Incoming property definitions are found here
$propsDir = realpath('./propsIn');

// Properties are stored here.
// They can be extended and reused across objects.
$propertyDir = realpath('./properties');
if (false === realpath($propertyDir)) {
mkdir($propertyDir);
$propertyDir = realpath($propertyDir);
}

// Create a directory iterator for the defined incoming properties directory
$dir = new DirectoryIterator($propsDir);

// Iterate through files in the incoming properties directory
foreach ($dir as $fileInfo) {

// Get the file name
$name = $fileInfo->getFilename();

// Skip '.', '..' and `.*` files
if (!$fileInfo->isDot() && substr($name, 0, 1) != '.') {
var_dump($fileInfo->getPathname());

$fullPath = $fileInfo->getPathname();

$row = 1;
if (($handle = fopen($fullPath, "r")) !== false) {
while (($data = fgetcsv($handle, 5000, ",")) !== false) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}




// Write the spec to the file pointer
//fwrite($fp, $spec);

// Close the file pointer
//fclose($fp);
}
}

function splitName($name)
{
$re = '/(?#! splitCamelCase Rev:20140412)
# Split camelCase "words". Two global alternatives. Either g1of2:
(?<=[a-z]) # Position is after a lowercase,
(?=[A-Z]) # and before an uppercase letter.
| (?<=[A-Z]) # Or g2of2; Position is after uppercase,
(?=[A-Z][a-z]) # and before upper-then-lower case.
/x';
$a = preg_split($re, $ccWord);
$count = count($a);
for ($i = 0; $i < $count; ++$i) {
printf(
"Word %d of %d = \"%s\"\n",
$i + 1,
$count,
$a[$i]
);
}
}
34 changes: 34 additions & 0 deletions src/bin/convertSchemRefs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

require_once "vendor/autoload.php";

$nugget = new \Activerules\Nugget\Nugget();

$shortopts = "";
$shortopts .= "s:"; // Required - path for incoming first-pass schema objects
$shortopts .= "t:"; // Required - the target '$refs' string to be replaced
$shortopts .= "r:"; // Required - Replacement root for '$refs'
$shortopts .= "o:"; // Required - path for generated schema w/ new $refs

$options = getopt($shortopts);

if (empty($options['s']) || empty($options['t']) || empty($options['r']) || empty($options['o'])) {
exit;
}

// The directory with the core Open API schema
$schemaDir = realpath($options['s']);

// The $refs path being replaced
$targetPath = $options['t'];

// The new $refs path
$replacementPath = $options['r'];

// A writeable directory for the OpenAPI schema w/new $ref paths
$schemaOut = realpath($options['o']);

/**
* Use Nugget
*/
$nugget->convertSchemaFileRefs($schemaDir, $schemaOut, $targetPath, $replacementPath);
34 changes: 34 additions & 0 deletions src/bin/convertSchemaRefs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

require_once "vendor/autoload.php";

$nugget = new \Activerules\Nugget\Nugget();

$shortopts = "";
$shortopts .= "s:"; // Required - path for incoming first-pass schema objects
$shortopts .= "t:"; // Required - the target '$refs' string to be replaced
$shortopts .= "r:"; // Required - Replacement root for '$refs'
$shortopts .= "o:"; // Required - path for generated schema w/ new $refs

$options = getopt($shortopts);

if (empty($options['s']) || empty($options['t']) || empty($options['r']) || empty($options['o'])) {
exit;
}

// The directory with the core Open API schema
$schemaDir = realpath($options['s']);

// The $refs path being replaced
$targetPath = $options['t'];

// The new $refs path
$replacementPath = $options['r'];

// A writeable directory for the OpenAPI schema w/new $ref paths
$schemaOut = realpath($options['o']);

/**
* Use Nugget
*/
echo $nugget->convertSchemaFileRefs($schemaDir, $schemaOut, $replacementPath, $targetPath);

0 comments on commit aab8168

Please sign in to comment.