From c24f5d635c17715350635a93f69af159e3a359fb Mon Sep 17 00:00:00 2001 From: Yoann Celton Date: Tue, 27 Nov 2018 22:01:37 +1100 Subject: [PATCH] Prefilling info --- CHANGELOG.md | 2 +- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- LICENSE.md | 2 +- README.md | 34 ++++++------- composer.json | 20 ++++---- phpcs.xml.dist | 4 +- phpunit.xml.dist | 2 +- prefill.php | 111 ------------------------------------------ src/SkeletonClass.php | 2 +- tests/ExampleTest.php | 2 +- 11 files changed, 36 insertions(+), 147 deletions(-) delete mode 100644 prefill.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c2d68..715336a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to `:package_name` will be documented in this file. +All notable changes to `PhpMatrixSdk` will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 2dc0a86..f73017c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at `:author_email`. All +reported by contacting the project team at `aryess@github.com`. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 126fc7f..ed17ad0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Contributions are **welcome** and will be fully **credited**. -We accept contributions via Pull Requests on [Github](https://github.com/:vendor/:package_name). +We accept contributions via Pull Requests on [Github](https://github.com/Aryess/PhpMatrixSdk). ## Pull Requests diff --git a/LICENSE.md b/LICENSE.md index 25a454c..70b06ae 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # The MIT License (MIT) -Copyright (c) 2018 :author_name <:author_email> +Copyright (c) 2018 Yoann Celton > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index dd6941b..757552e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# :package_name +# PhpMatrixSdk [![Latest Version on Packagist][ico-version]][link-packagist] [![Software License][ico-license]](LICENSE.md) @@ -7,7 +7,7 @@ [![Quality Score][ico-code-quality]][link-code-quality] [![Total Downloads][ico-downloads]][link-downloads] -**Note:** Replace ```:author_name``` ```:author_username``` ```:author_website``` ```:author_email``` ```:vendor``` ```:package_name``` ```:package_description``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well. +**Note:** Replace ```Yoann Celton``` ```aryess``` ```https://github.com/aryess``` ```aryess@github.com``` ```Aryess``` ```PhpMatrixSdk``` ```Later``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well. This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors. @@ -30,13 +30,13 @@ vendor/ Via Composer ``` bash -$ composer require :vendor/:package_name +$ composer require Aryess/PhpMatrixSdk ``` ## Usage ``` php -$skeleton = new League\Skeleton(); +$skeleton = new Aryess\PhpMatrixSdk(); echo $skeleton->echoPhrase('Hello, League!'); ``` @@ -56,28 +56,28 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT ## Security -If you discover any security related issues, please email :author_email instead of using the issue tracker. +If you discover any security related issues, please email aryess@github.com instead of using the issue tracker. ## Credits -- [:author_name][link-author] +- [Yoann Celton][link-author] - [All Contributors][link-contributors] ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. -[ico-version]: https://img.shields.io/packagist/v/:vendor/:package_name.svg?style=flat-square +[ico-version]: https://img.shields.io/packagist/v/Aryess/PhpMatrixSdk.svg?style=flat-square [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square -[ico-travis]: https://img.shields.io/travis/:vendor/:package_name/master.svg?style=flat-square -[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/:vendor/:package_name.svg?style=flat-square -[ico-code-quality]: https://img.shields.io/scrutinizer/g/:vendor/:package_name.svg?style=flat-square -[ico-downloads]: https://img.shields.io/packagist/dt/:vendor/:package_name.svg?style=flat-square +[ico-travis]: https://img.shields.io/travis/Aryess/PhpMatrixSdk/master.svg?style=flat-square +[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/Aryess/PhpMatrixSdk.svg?style=flat-square +[ico-code-quality]: https://img.shields.io/scrutinizer/g/Aryess/PhpMatrixSdk.svg?style=flat-square +[ico-downloads]: https://img.shields.io/packagist/dt/Aryess/PhpMatrixSdk.svg?style=flat-square -[link-packagist]: https://packagist.org/packages/:vendor/:package_name -[link-travis]: https://travis-ci.org/:vendor/:package_name -[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/:package_name/code-structure -[link-code-quality]: https://scrutinizer-ci.com/g/:vendor/:package_name -[link-downloads]: https://packagist.org/packages/:vendor/:package_name -[link-author]: https://github.com/:author_username +[link-packagist]: https://packagist.org/packages/Aryess/PhpMatrixSdk +[link-travis]: https://travis-ci.org/Aryess/PhpMatrixSdk +[link-scrutinizer]: https://scrutinizer-ci.com/g/Aryess/PhpMatrixSdk/code-structure +[link-code-quality]: https://scrutinizer-ci.com/g/Aryess/PhpMatrixSdk +[link-downloads]: https://packagist.org/packages/Aryess/PhpMatrixSdk +[link-author]: https://github.com/aryess [link-contributors]: ../../contributors diff --git a/composer.json b/composer.json index 1a12a93..7bdcca2 100644 --- a/composer.json +++ b/composer.json @@ -1,18 +1,18 @@ { - "name": ":vendor/:package_name", + "name": "Aryess/PhpMatrixSdk", "type": "library", - "description": ":package_description", + "description": "Later", "keywords": [ - ":vendor", - ":package_name" + "Aryess", + "PhpMatrixSdk" ], - "homepage": "https://github.com/:vendor/:package_name", + "homepage": "https://github.com/Aryess/PhpMatrixSdk", "license": "MIT", "authors": [ { - "name": ":author_name", - "email": ":author_email", - "homepage": ":author_website", + "name": "Yoann Celton", + "email": "aryess@github.com", + "homepage": "https://github.com/aryess", "role": "Developer" } ], @@ -25,12 +25,12 @@ }, "autoload": { "psr-4": { - ":vendor\\:package_name\\": "src" + "Aryess\\PhpMatrixSdk\\": "src" } }, "autoload-dev": { "psr-4": { - ":vendor\\:package_name\\": "tests" + "Aryess\\PhpMatrixSdk\\": "tests" } }, "scripts": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 989f840..6f5d66f 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,6 @@ - - The coding standard of :package_name package + + The coding standard of PhpMatrixSdk package diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 90d7bd4..38e9e97 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ processIsolation="false" stopOnFailure="false"> - + tests diff --git a/prefill.php b/prefill.php deleted file mode 100644 index 822f88a..0000000 --- a/prefill.php +++ /dev/null @@ -1,111 +0,0 @@ - ['Your name', '', ''], - 'author_github_username' => ['Your Github username', ' in https://github.com/username', ''], - 'author_email' => ['Your email address', '', ''], - 'author_twitter' => ['Your twitter username', '', '@{author_github_username}'], - 'author_website' => ['Your website', '', 'https://github.com/{author_github_username}'], - - 'package_vendor' => ['Package vendor', ' in https://github.com/vendor/package', '{author_github_username}'], - 'package_name' => ['Package name', ' in https://github.com/vendor/package', ''], - 'package_description' => ['Package very short description', '', ''], - - 'psr4_namespace' => ['PSR-4 namespace', 'usually, Vendor\\Package', '{package_vendor}\\{package_name}'], -]; - -$values = []; - -$replacements = [ - ':vendor\\\\:package_name\\\\' => function () use(&$values) { return str_replace('\\', '\\\\', $values['psr4_namespace']) . '\\\\'; }, - ':author_name' => function () use(&$values) { return $values['author_name']; }, - ':author_username' => function () use(&$values) { return $values['author_github_username']; }, - ':author_website' => function () use(&$values) { return $values['author_website'] ?: ('https://github.com/' . $values['author_github_username']); }, - ':author_email' => function () use(&$values) { return $values['author_email'] ?: ($values['author_github_username'] . '@example.com'); }, - ':vendor' => function () use(&$values) { return $values['package_vendor']; }, - ':package_name' => function () use(&$values) { return $values['package_name']; }, - ':package_description' => function () use(&$values) { return $values['package_description']; }, - 'League\\Skeleton' => function () use(&$values) { return $values['psr4_namespace']; }, -]; - -function read_from_console ($prompt) { - if ( function_exists('readline') ) { - $line = trim(readline($prompt)); - if (!empty($line)) { - readline_add_history($line); - } - } else { - echo $prompt; - $line = trim(fgets(STDIN)); - } - return $line; -} - -function interpolate($text, $values) -{ - if (!preg_match_all('/\{(\w+)\}/', $text, $m)) { - return $text; - } - foreach ($m[0] as $k => $str) { - $f = $m[1][$k]; - $text = str_replace($str, $values[$f], $text); - } - return $text; -} - -$modify = 'n'; -do { - if ($modify == 'q') { - exit; - } - - $values = []; - - echo "----------------------------------------------------------------------\n"; - echo "Please, provide the following information:\n"; - echo "----------------------------------------------------------------------\n"; - foreach ($fields as $f => $field) { - $default = isset($field[COL_DEFAULT]) ? interpolate($field[COL_DEFAULT], $values): ''; - $prompt = sprintf( - '%s%s%s: ', - $field[COL_DESCRIPTION], - $field[COL_HELP] ? ' (' . $field[COL_HELP] . ')': '', - $field[COL_DEFAULT] !== '' ? ' [' . $default . ']': '' - ); - $values[$f] = read_from_console($prompt); - if (empty($values[$f])) { - $values[$f] = $default; - } - } - echo "\n"; - - echo "----------------------------------------------------------------------\n"; - echo "Please, check that everything is correct:\n"; - echo "----------------------------------------------------------------------\n"; - foreach ($fields as $f => $field) { - echo $field[COL_DESCRIPTION] . ": $values[$f]\n"; - } - echo "\n"; -} while (($modify = strtolower(read_from_console('Modify files with these values? [y/N/q] '))) != 'y'); -echo "\n"; - -$files = array_merge( - glob(__DIR__ . '/*.md'), - glob(__DIR__ . '/*.xml.dist'), - glob(__DIR__ . '/composer.json'), - glob(__DIR__ . '/src/*.php'), - glob(__DIR__ . '/tests/*.php') -); -foreach ($files as $f) { - $contents = file_get_contents($f); - foreach ($replacements as $str => $func) { - $contents = str_replace($str, $func(), $contents); - } - file_put_contents($f, $contents); -} - -echo "Done.\n"; -echo "Now you should remove the file '" . basename(__FILE__) . "'.\n"; diff --git a/src/SkeletonClass.php b/src/SkeletonClass.php index 8898b3f..d7d30f8 100644 --- a/src/SkeletonClass.php +++ b/src/SkeletonClass.php @@ -1,6 +1,6 @@