xmlsquad / xml-authoring-library

A place to put code that is reused by many commands which are part of the [xml-authoring-tools suite](https://github.com/forikal-uk/xml-authoring-tools).
Apache License 2.0
0 stars 0 forks source link

Move the common gsheet-to-xml GoogleAPI Services and `DomainGSheetObjectFactoryInterface` to library #7

Closed forikal-uk closed 6 years ago

forikal-uk commented 6 years ago

Goal

See issue summary

Why

Aside from the $xmlSerializer, the following XmlSquad\GsheetXml\Application\Service classes:

...no longer contain logic that is exclusive to converting a gsheet-to-xml. They could be made to do any kind of process on a gsheet in drive.

How

forikal-uk commented 6 years ago

Create interface in library to represent GoogleDriveProcessorInterface with no methods yet.

Created:


namespace XmlSquad\Library\GoogleAPI;

interface GoogleDriveProcessorInterface
{

}
forikal-uk commented 6 years ago

Ensure XmlSquad\GsheetXml\Application\Service\XmlSerializer implements that, generic, GoogleDriveProcessorInterface.

Done. (needs committing though).

Test it with

$ pwd
/Users/jw/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
$ php bin/gsheet-to-xml.php https://drive.google.com/drive/folders/1p-O1y10xMDX_QnWbZd6GE0VcnmWbr_02?ogsrc=32 -r > testing.xml
forikal-uk commented 6 years ago

Move GoogleDriveProcessService, GoogleDriveFolderReadService and GoogleSpreadsheetReadService from XmlSquad\GsheetXml\Application\Service into library.

Moved.

Replace:

XmlSquad\GsheetXml\Application\Service

to:

XmlSquad\Library\Application\Service

Done.

forikal-uk commented 6 years ago

Replace type checks in library code to expect GoogleDriveProcessorInterface instead of XmlSerializerInterface

Replace use of :

forikal-uk commented 6 years ago

Also move: XmlSquad\GsheetXml\Model\Domain\DomainGSheetObjectFactoryInterface into library.

Replace:

forikal-uk commented 6 years ago

Adjust GoogleDriveProcessService so that GoogleDriveProcessorInterface is injected in the process methods as opposed to constructor (to allow the same GoogleDriveProcessService object instance to be used for different processes).

public method signatures changed:

forikal-uk commented 6 years ago

Test the GoogleDriveProcessService

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
$ ./vendor/phpunit/phpunit/phpunit vendor/xmlsquad/gsheet-to-xml/tests/
PHPUnit 7.4.0 by Sebastian Bergmann and contributors.

.....                                                               5 / 5 (100%)

Time: 50 ms, Memory: 4.00MB

OK (5 tests, 23 assertions)

The test script ought to be moved to the library too.

Done.

Run the phpunit tests

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
$ ./vendor/phpunit/phpunit/phpunit 
PHPUnit 7.4.0 by Sebastian Bergmann and contributors.

................................................................. 65 / 65 (100%)

Time: 2.23 seconds, Memory: 12.00MB

OK (65 tests, 1290 assertions)

Good.

forikal-uk commented 6 years ago

Generalise the XmlSquad\GsheetXml\Application\Service\XmlSerializer method names so it conforms to any kind of process on the Google Drive entities.

Done.

The method being invoked on the processor is now called:

$googleDriveProcessor->processDomainGSheetObjects($domainGSheetObjects)

and the service has a public method called

processGoogleUrl

forikal-uk commented 6 years ago

Add those generalised methods to the GoogleDriveProcessorInterface.

So, really we need to move it from

XmlSquad\GsheetXml\Model\Service\XmlSerializerInterface which is now redundant.

forikal-uk commented 6 years ago

Delete the XmlSerializerInterface

See comment above.

Done.

forikal-uk commented 6 years ago

Commit the changes

Done

In project:

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
$ composer status -v
You have version variations in the following dependencies:
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project/vendor/xmlsquad/gsheet-to-xml:
    From dev-master to dev-master
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project/vendor/xmlsquad/xml-authoring-library:
    From dev-master to dev-master

Update composer in project

$ composer update --prefer-source
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Updating xmlsquad/gsheet-to-xml dev-master (4961593 => 567dfca):  Checking out 567dfcaa82
  - Updating xmlsquad/xml-authoring-library dev-master (eee0223 => 36c23af):  Checking out 36c23af87e
Writing lock file
Generating autoload files

Test the gsheet-to-xml command

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
$ php bin/gsheet-to-xml.php https://drive.google.com/drive/folders/13_CYrzBCTxjtq048-3MTiqlNjRfqzxXj?ogsrc=32 -r > testing.xml

Good

Run tests

$ pwd
/Users/x/Documents/Projects/XmlAuthoringSuite/xml-authoring-project
./vendor/phpunit/phpunit/phpunit 
PHPUnit 7.4.0 by Sebastian Bergmann and contributors.

................................................................. 65 / 65 (100%)

Time: 2.86 seconds, Memory: 12.00MB

OK (65 tests, 1290 assertions)

All good.