2017 © Pedro Peláez
 

library peridot-temporary-plugin

Temporary file / directory plugin for peridot-php

image

holyshared/peridot-temporary-plugin

Temporary file / directory plugin for peridot-php

  • Thursday, December 31, 2015
  • by holyshared
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,147 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 19 Versions
  • 0 % Grown

The README.md

peridot-temporary-plugin

It provides an api to create a temporary directory or file.
Directory of file will be deleted at the end of the test., (*1)

Build Status HHVM Status Coverage Status Scrutinizer Code Quality Dependency Status, (*2)

Basic usage

First will first register the plugin.
Edit the peridot.php, write the code to register., (*3)

use holyshared\peridot\temporary\TemporaryPlugin;

return function(EventEmitterInterface $emitter)
{
    TemporaryPlugin::create()->registerTo($emitter);
};

Create a temporary directory

Create a temporary directory, call the makeDirectory method.
Directory name is generated by UUID, use the id., (*4)

Permissions can be specified in the argument., (*5)

beforeEach(function() {
    $this->temp = $this->makeDirectory(); //return holyshared\peridot\temporary\TemporaryDirectory instance
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

or, (*6)

beforeEach(function() {
    $this->temp = $this->makeDirectory(0755);
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});

Create a temporary file

Create a temporary file, call the makeFile method.
File name is generated by UUID, use the id., (*7)

Permissions can be specified in the argument., (*8)

beforeEach(function() {
    $this->temp = $this->makeFile(); //return holyshared\peridot\temporary\TemporaryFile instance
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

or, (*9)

beforeEach(function() {
    $this->temp = $this->makeFile(0755);
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});

Write to a temporary file

You can output the data to a temporary file in the write or writeln method of TemporaryFile instance., (*10)

beforeEach(function() {
    $this->tempDirectory = $this->makeDirectory();
    $this->tempFile = $this->tempDirectory->createNewFile('report.txt');

    $this->tempFile->writeln('Hello world!!');
    $this->tempFile->writeln('Hello world!!');
});
afterEach(function() {
    $this->cleanUpTemporary();
});

or, (*11)

beforeEach(function() {
    $tempDirectory = $this->makeDirectory();
    $tempFilePath = $tempDirectory->resolvePath('report.txt'); //File not created!!

    $tempFile = new SplFileObject($tempFilePath, 'w');
    $tempFile->fwrite('Hello world!!');
    $tempFile->fwrite('Hello world!!');
    $tempFile = null;
});

Running tests

Run with the following command., (*12)

composer test

The Versions

31/12 2015

dev-master

9999999-dev

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

31/12 2015

1.0.5

1.0.5.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

05/12 2015

1.0.4

1.0.4.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

28/10 2015

1.0.3

1.0.3.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

01/10 2015

1.0.2

1.0.2.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

20/05 2015

1.0.1

1.0.1.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

01/05 2015

1.0.0

1.0.0.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

28/04 2015

0.4.3

0.4.3.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

26/04 2015

0.4.2

0.4.2.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

24/04 2015

0.4.1

0.4.1.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

21/04 2015

0.4.0

0.4.0.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

04/04 2015

0.3.2

0.3.2.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

02/04 2015

0.3.1

0.3.1.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

02/04 2015

0.3.0

0.3.0.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

01/04 2015

0.2.0

0.2.0.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

31/03 2015

0.1.3

0.1.3.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

26/03 2015

0.1.2

0.1.2.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

19/03 2015

0.1.1

0.1.1.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file

19/03 2015

0.1.0

0.1.0.0

Temporary file / directory plugin for peridot-php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

plugin test temporary peridot temporary directory temporary file