Skip to content

Commit

Permalink
Merge pull request #20 from Vinelab/develop
Browse files Browse the repository at this point in the history
Develop into master. Release v1.0.0-beta.2
  • Loading branch information
Mulkave committed Sep 19, 2014
2 parents 0656d83 + 5463810 commit 02948ec
Show file tree
Hide file tree
Showing 26 changed files with 776 additions and 72 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.*",
"illuminate/config": "4.*",
"symfony/finder": "2.5.*@dev",
"symfony/console": "2.*",
"guzzlehttp/guzzle": "~4.0",
Expand Down
9 changes: 8 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
<directory suffix=".php">./tests/Vinelab</directory>
</testsuite>
</testsuites>
</phpunit>

<!--<logging>-->
<!--<log type="coverage-html" target="./CodeCoverage/"/>-->
<!--</logging>-->

</phpunit>


10 changes: 2 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,10 @@ Specify what to be ignored.

#### URL

Set the URL protocol:
Set the CDN URL:

```php
'protocol' => 'https',
```

Set the CDN domain:

```php
'domain' => 's3.amazonaws.com',
'url' => 'https://s3.amazonaws.com',
```

#### Threshold
Expand Down
26 changes: 13 additions & 13 deletions src/Vinelab/Cdn/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Asset implements AssetInterface{
*
* @var array
*/
private $default_include = [
protected $default_include = [
'directories' => ['public'],
'extensions' => [],
'patterns' => [],
Expand All @@ -29,7 +29,7 @@ class Asset implements AssetInterface{
*
* @var array
*/
private $default_exclude = [
protected $default_exclude = [
'directories' => [],
'files' => [],
'extensions' => [],
Expand All @@ -40,40 +40,40 @@ class Asset implements AssetInterface{
/**
* @var Array
*/
public $included_directories;
protected $included_directories;
/**
* @var Array
*/
public $included_files;
protected $included_files;
/**
* @var Array
*/
public $included_extensions;
protected $included_extensions;
/**
* @var Array
*/
public $included_patterns;
protected $included_patterns;

/**
* @var Array
*/
public $excluded_directories;
protected $excluded_directories;
/**
* @var Array
*/
public $excluded_files;
protected $excluded_files;
/**
* @var Array
*/
public $excluded_extensions;
protected $excluded_extensions;
/**
* @var Array
*/
public $excluded_patterns;
protected $excluded_patterns;
/*
* @var boolean
*/
public $exclude_hidden;
protected $exclude_hidden;

/*
* Allowed assets for upload (found in included_directories)
Expand Down Expand Up @@ -113,7 +113,7 @@ public function init($configurations = array())
*
* @param $configurations
*/
public function parseAndFillConfiguration($configurations)
private function parseAndFillConfiguration($configurations)
{
$this->default_include = isset($configurations['include']) ?
array_merge($this->default_include, $configurations['include']) : $this->default_include;
Expand Down Expand Up @@ -179,7 +179,7 @@ public function getExcludedPatterns()
}

/**
* @return mixed
* @return Collection
*/
public function getAssets()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Vinelab/Cdn/Cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class Cdn implements CdnInterface{
* @internal param \Vinelab\Cdn\Repository $configurations
*/
public function __construct(
FinderInterface $finder,
AssetInterface $asset_holder,
ProviderFactoryInterface $provider_factory,
CdnHelperInterface $helper
FinderInterface $finder,
AssetInterface $asset_holder,
ProviderFactoryInterface $provider_factory,
CdnHelperInterface $helper
) {
$this->finder = $finder;
$this->asset_holder = $asset_holder;
Expand All @@ -69,7 +69,7 @@ public function push()
// return an instance of the corresponding Provider concrete according to the configuration
$provider = $this->provider_factory->create($configurations);

$provider->upload($this->asset_holder->getAssets());
return $provider->upload($this->asset_holder->getAssets());
}

}
25 changes: 21 additions & 4 deletions src/Vinelab/Cdn/CdnFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
use Vinelab\Cdn\Contracts\ProviderFactoryInterface;
use Vinelab\Cdn\Contracts\CdnFacadeInterface;
use Vinelab\Cdn\Contracts\CdnHelperInterface;
use Vinelab\Cdn\Validators\CdnFacadeValidator;
use Vinelab\Cdn\Exceptions\EmptyPathException;

/**
* Class CdnFacade
* @package Vinelab\Cdn
*/
class CdnFacade implements CdnFacadeInterface{

/**
* @var Contracts\ProviderFactoryInterface
*/
protected $provider_factory;

/**
* @var instance of the default provider object
*/
Expand All @@ -24,20 +31,28 @@ class CdnFacade implements CdnFacadeInterface{
*/
protected $helper;

/**
* @var Validators\CdnFacadeValidator
*/
protected $cdn_facade_validator;

/**
* Calls the provider initializer
*
* @param ProviderFactoryInterface $provider_factory
* @param Contracts\CdnHelperInterface $helper
* @param Validators\CdnFacadeValidator $cdn_facade_validator
*
* @internal param \Vinelab\Cdn\Repository $configurations
*/
public function __construct(
ProviderFactoryInterface $provider_factory,
CdnHelperInterface $helper
CdnHelperInterface $helper,
CdnFacadeValidator $cdn_facade_validator
) {
$this->provider_factory = $provider_factory;
$this->helper = $helper;
$this->cdn_facade_validator = $cdn_facade_validator;

$this->init();
}
Expand All @@ -49,10 +64,14 @@ public function __construct(
*
* @param $path
*
* @return string
* @return mixed
* @throws Exceptions\EmptyPathException
*/
public function asset($path)
{
if ( ! isset($path))
throw new EmptyPathException('Path does not exist.');

// remove slashes from begging and ending of the path then call the
// url generator of the provider
return $this->provider->urlGenerator($this->cleanPath($path));
Expand Down Expand Up @@ -85,6 +104,4 @@ private function init()
$this->provider = $this->provider_factory->create($configurations);
}



}
5 changes: 4 additions & 1 deletion src/Vinelab/Cdn/CdnHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ public function __construct(Repository $configurations)
/**
* Check if the config file exist and return it or
* throw an exception
*
* @return array
* @throws Exceptions\MissingConfigurationFileException
*/
public function getConfigurations()
{
$configurations = $this->configurations->get('cdn::cdn');

if ( ! $configurations) {
throw new MissingConfigurationFileException('CDN Configurations file not found');
throw new MissingConfigurationFileException("CDN 'config file' (cdn.php) not found");
}

return $configurations;
Expand Down
16 changes: 14 additions & 2 deletions src/Vinelab/Cdn/CdnServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ public function register()
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\ConfigurationsInterface',
'Vinelab\Cdn\Validators\Configurations'
'Vinelab\Cdn\Validators\Contracts\ProviderValidatorInterface',
'Vinelab\Cdn\Validators\ProviderValidator'
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\CdnFacadeValidatorInterface',
'Vinelab\Cdn\Validators\CdnFacadeValidator'
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\ValidatorInterface',
'Vinelab\Cdn\Validators\Validator'
);

// register the commands:
Expand Down Expand Up @@ -106,6 +116,8 @@ public function register()
});


// registering the package (for the config files)
$this->package("vinelab/cdn");

}

Expand Down
1 change: 0 additions & 1 deletion src/Vinelab/Cdn/Contracts/AssetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
interface AssetInterface {

public function init($configurations);
public function parseAndFillConfiguration($configurations);

public function getIncludedDirectories();
public function getIncludedExtensions();
Expand Down
1 change: 1 addition & 0 deletions src/Vinelab/Cdn/Exceptions/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class CdnException extends \RuntimeException {}
class MissingConfigurationFileException extends CdnException {}
class MissingConfigurationException extends CdnException {}
class UnsupportedProviderException extends CdnException {}
class EmptyPathException extends CdnException {}

2 changes: 1 addition & 1 deletion src/Vinelab/Cdn/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function includeThis(AssetInterface $asset_holder)

// include files with this extensions
foreach ($asset_holder->getIncludedExtensions() as $extension) {
$this->name('*'.$extension);
$this->name('*' . $extension);
}

// include patterns
Expand Down
Loading

0 comments on commit 02948ec

Please sign in to comment.