{"id":25687103,"url":"https://github.com/holyshared/peridot-temporary-plugin","last_synced_at":"2025-02-24T20:08:09.682Z","repository":{"id":28913097,"uuid":"32438039","full_name":"holyshared/peridot-temporary-plugin","owner":"holyshared","description":"Temporary file / directory plugin for peridot-php","archived":false,"fork":false,"pushed_at":"2015-12-31T06:03:38.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T13:45:18.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/holyshared.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-18T04:33:54.000Z","updated_at":"2015-05-01T07:04:56.000Z","dependencies_parsed_at":"2022-08-02T17:15:20.434Z","dependency_job_id":null,"html_url":"https://github.com/holyshared/peridot-temporary-plugin","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fperidot-temporary-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fperidot-temporary-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fperidot-temporary-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holyshared%2Fperidot-temporary-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holyshared","download_url":"https://codeload.github.com/holyshared/peridot-temporary-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549397,"owners_count":19819139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-24T20:08:08.593Z","updated_at":"2025-02-24T20:08:09.664Z","avatar_url":"https://github.com/holyshared.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"peridot-temporary-plugin\n========================================================\n\nIt provides an api to create a temporary directory or file.  \nDirectory of file will be deleted at the end of the test.\n\n\n[![Build Status](https://travis-ci.org/holyshared/peridot-temporary-plugin.svg?branch=master)](https://travis-ci.org/holyshared/peridot-temporary-plugin)\n[![HHVM Status](http://hhvm.h4cc.de/badge/holyshared/peridot-temporary-plugin.svg)](http://hhvm.h4cc.de/package/holyshared/peridot-temporary-plugin)\n[![Coverage Status](https://coveralls.io/repos/holyshared/peridot-temporary-plugin/badge.svg?branch=master)](https://coveralls.io/r/holyshared/peridot-temporary-plugin?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/holyshared/peridot-temporary-plugin/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/holyshared/peridot-temporary-plugin/?branch=master)\n[![Dependency Status](https://www.versioneye.com/user/projects/551fbda0971f781c4800034f/badge.svg?style=flat)](https://www.versioneye.com/user/projects/551fbda0971f781c4800034f)\n\nBasic usage\n--------------------------------------------------------\n\nFirst will first register the plugin.  \nEdit the **peridot.php**, write the code to register.\n\n```php\nuse holyshared\\peridot\\temporary\\TemporaryPlugin;\n\nreturn function(EventEmitterInterface $emitter)\n{\n    TemporaryPlugin::create()-\u003eregisterTo($emitter);\n};\n```\n\n### Create a temporary directory\n\nCreate a temporary directory, call the **makeDirectory** method.  \nDirectory name is generated by [UUID](http://tools.ietf.org/html/rfc4122.html), use the id.\n\nPermissions can be specified in the argument.\n\n\n```php\nbeforeEach(function() {\n    $this-\u003etemp = $this-\u003emakeDirectory(); //return holyshared\\peridot\\temporary\\TemporaryDirectory instance\n});\nit('create temporary directory', function() {\n    expect($this-\u003etemp-\u003eexists())-\u003etoBeTrue();\n});\n```\n\nor\n\n```php\nbeforeEach(function() {\n    $this-\u003etemp = $this-\u003emakeDirectory(0755);\n});\nit('create temporary directory', function() {\n    expect($this-\u003etemp-\u003eexists())-\u003etoBeTrue();\n});\n```\n\n\n\n### Create a temporary file\n\nCreate a temporary file, call the **makeFile** method.  \nFile name is generated by [UUID](http://tools.ietf.org/html/rfc4122.html), use the id.\n\nPermissions can be specified in the argument.\n\n```php\nbeforeEach(function() {\n    $this-\u003etemp = $this-\u003emakeFile(); //return holyshared\\peridot\\temporary\\TemporaryFile instance\n});\nit('create temporary file', function() {\n    expect($this-\u003etemp-\u003eexists())-\u003etoBeTrue();\n});\n```\n\nor\n\n```php\nbeforeEach(function() {\n    $this-\u003etemp = $this-\u003emakeFile(0755);\n});\nit('create temporary file', function() {\n    expect($this-\u003etemp-\u003eexists())-\u003etoBeTrue();\n});\n```\n\nWrite to a temporary file\n--------------------------------------------------------\n\nYou can output the data to a temporary file in the **write** or **writeln** method of TemporaryFile instance.\n\n```php\nbeforeEach(function() {\n    $this-\u003etempDirectory = $this-\u003emakeDirectory();\n    $this-\u003etempFile = $this-\u003etempDirectory-\u003ecreateNewFile('report.txt');\n\n    $this-\u003etempFile-\u003ewriteln('Hello world!!');\n    $this-\u003etempFile-\u003ewriteln('Hello world!!');\n});\nafterEach(function() {\n    $this-\u003ecleanUpTemporary();\n});\n```\n\nor\n\n```php\nbeforeEach(function() {\n    $tempDirectory = $this-\u003emakeDirectory();\n    $tempFilePath = $tempDirectory-\u003eresolvePath('report.txt'); //File not created!!\n\n    $tempFile = new SplFileObject($tempFilePath, 'w');\n    $tempFile-\u003efwrite('Hello world!!');\n    $tempFile-\u003efwrite('Hello world!!');\n    $tempFile = null;\n});\n```\n\nRunning tests\n--------------------------------------------------------\n\nRun with the following command.\n\n\tcomposer test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fperidot-temporary-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholyshared%2Fperidot-temporary-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholyshared%2Fperidot-temporary-plugin/lists"}