Skip to content

Commit 9d4e028

Browse files
authored
Add installer for Processwire module (#472)
* Add ProcessWire installer * Inflect package names to CamelCase * Add tests * Add readme
1 parent 02652f4 commit 9d4e028

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ is not needed to install packages with these frameworks:
9696
| PPI | **`ppi-module`**
9797
| Puppet | `puppet-module`
9898
| Porto | `porto-container`
99+
| ProcessWire | `processwire-module`
99100
| RadPHP | `radphp-bundle`
100101
| REDAXO | `redaxo-addon`
101102
| REDAXO bestyle-plugin | `redaxo-bestyle-plugin`

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"PPI",
5858
"Puppet",
5959
"Porto",
60+
"ProcessWire",
6061
"RadPHP",
6162
"ReIndex",
6263
"Roundcube",

src/Composer/Installers/Installer.php

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Installer extends LibraryInstaller
8888
'radphp' => 'RadPHPInstaller',
8989
'phifty' => 'PhiftyInstaller',
9090
'porto' => 'PortoInstaller',
91+
'processwire' => 'ProcessWireInstaller',
9192
'redaxo' => 'RedaxoInstaller',
9293
'redaxo5' => 'Redaxo5Installer',
9394
'reindex' => 'ReIndexInstaller',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Composer\Installers;
4+
5+
class ProcessWireInstaller extends BaseInstaller
6+
{
7+
protected $locations = array(
8+
'module' => 'site/modules/{$name}/',
9+
);
10+
11+
/**
12+
* Format package name to CamelCase
13+
*/
14+
public function inflectPackageVars($vars)
15+
{
16+
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
17+
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
18+
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
19+
20+
return $vars;
21+
}
22+
}

tests/Composer/Installers/Test/InstallerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public function dataForTestSupport()
196196
array('prestashop-theme', true),
197197
array('puppet-module', true),
198198
array('porto-container', true),
199+
array('processwire-module', true),
199200
array('radphp-bundle', true),
200201
array('redaxo-addon', true),
201202
array('redaxo-bestyle-plugin', true),
@@ -404,6 +405,7 @@ public function dataForTestInstallPath()
404405
array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
405406
array('porto-container', 'app/Containers/container-name/', 'test/container-name'),
406407
array('radphp-bundle', 'src/Migration/', 'atkrad/migration'),
408+
array('processwire-module', 'site/modules/HelloWorld/', 'test/hello-world'),
407409
array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
408410
array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
409411
array('redaxo5-addon', 'redaxo/src/addons/my_plugin/', 'shama/my_plugin'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace Composer\Installers\Test;
3+
4+
use Composer\Installers\ProcessWireInstaller;
5+
use Composer\Package\Package;
6+
use Composer\Composer;
7+
8+
class ProcessWireInstallerTest extends TestCase
9+
{
10+
private $composer;
11+
private $io;
12+
private $package;
13+
14+
/**
15+
* setUp
16+
*
17+
* @return void
18+
*/
19+
public function setUp()
20+
{
21+
$this->package = new Package('CamelCased', '1.0', '1.0');
22+
$this->composer = new Composer();
23+
}
24+
25+
/**
26+
* testInflectPackageVars
27+
*
28+
* @return void
29+
*/
30+
public function testInflectPackageVars()
31+
{
32+
$installer = new ProcessWireInstaller($this->package, $this->composer);
33+
$result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
34+
$this->assertEquals($result, array('name' => 'CamelCased'));
35+
36+
$installer = new ProcessWireInstaller($this->package, $this->composer);
37+
$result = $installer->inflectPackageVars(array('name' => 'with-dash'));
38+
$this->assertEquals($result, array('name' => 'WithDash'));
39+
40+
$installer = new ProcessWireInstaller($this->package, $this->composer);
41+
$result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
42+
$this->assertEquals($result, array('name' => 'WithUnderscore'));
43+
}
44+
}

0 commit comments

Comments
 (0)