Skip to content

Commit

Permalink
Merge pull request #28 from stefanzweifel/dev/core-changes
Browse files Browse the repository at this point in the history
Rebuilding Core and more (Tests, New Exception Handling)
  • Loading branch information
stefanzweifel committed Sep 5, 2015
2 parents 93561d0 + 8953cb9 commit 6e9dfcb
Show file tree
Hide file tree
Showing 123 changed files with 5,766 additions and 1,570 deletions.
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ DB_DATABASE=screeenly
DB_USERNAME=homestead
DB_PASSWORD=secret

REDIS_SOCK=/path/to/your/.redis/sock

SLACK_CHANNEL=#general
SLACK_BOT=BOTNAME
SLACK_ICON=:ghost:
Expand All @@ -25,3 +23,8 @@ SESSION_DRIVER=file
SCREEENLY_RATE_LIMIT=1000
SCREEENLY_RATE_LIMIT_TIME=60
SCREEENLY_STORAGE_PATH=images/generated/

RAVEN_DSN=secret
RAVEN_LEVEL=debug

SCHEDULER_PING_URL=http://beats.envoyer.io/heartbeat/secret
13 changes: 10 additions & 3 deletions .env.travis
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ DB_DATABASE=screeenly_test
DB_USERNAME=travis
DB_PASSWORD=

REDIS_SOCK=/.redis/sock

SLACK_CHANNEL=#general
SLACK_BOT=BOTNAME
SLACK_ICON=:ghost:
Expand All @@ -20,4 +18,13 @@ APP_KEY=RandomString
APP_URL=http://screeeenly.com

CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_DRIVER=file

SCREEENLY_RATE_LIMIT=1000
SCREEENLY_RATE_LIMIT_TIME=60
SCREEENLY_STORAGE_PATH=images/generated/

RAVEN_DSN=secret
RAVEN_LEVEL=debug

SCHEDULER_PING_URL=secret
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ language: php
php:
- 5.5
- 5.6
- 7
- hhvm
- nightly

matrix:
allow_failures:
- php: hhvm
- php: 7
- php: nightly

sudo: false

Expand All @@ -12,4 +20,7 @@ before_script:
- travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction

script: phpunit
script: phpunit --coverage-clover build/logs/clover.xml

after_script:
- ./bin/test-reporter
130 changes: 0 additions & 130 deletions Envoy.blade.php

This file was deleted.

6 changes: 4 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('screeenly:clear:images')->hourly();
$schedule->command('screeenly:clear:logs')->daily();
$url = env('SCHEDULER_PING_URL');

$schedule->command('screeenly:clear:images')->hourly()->thenPing($url);
$schedule->command('screeenly:clear:logs')->daily()->thenPing($url);
}

}
126 changes: 126 additions & 0 deletions app/Core/Client/AbstractClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace Screeenly\Core\Client;

use Illuminate\Contracts\Config\Repository as Config;
use Screeenly\Core\Exception\UnavailableHostException;
use Screeenly\Core\Ping;
use Screeenly\Core\Screeenshot\Screenshot;

abstract class AbstractClient implements ClientInterface
{
/**
* Config Repository
* @var Illuminate\Contracts\Config\Repository
*/
protected $config;

/**
* Screenshot Instance
* @var Screeenly\Core\Screeenshot\Screenshot
*/
protected $screenshot;

/**
* Browser Height
* @var int
*/
protected $height;

/**
* Browser Width
* @var int
*/
protected $width;

/**
* Browser Viewport Height
* @var integer
*/
protected $viewportHeight = 768;

public function __construct(Config $config, Screenshot $screenshot)
{
$this->config = $config;
$this->screenshot = $screenshot;

// Set default values for height and width
$this->setHeight(null);
$this->setWidth(null);
}

/**
* Set Browser Height
* @param int $height
*/
public function setHeight($height)
{
return $this->height = $height;
}

/**
* Set Browser Width
* @param int $width
*/
public function setWidth($width)
{
if (is_null($width)) {
$width = $this->config->get('screeenly.core.screenshot_width');
}

return $this->width = $width;
}

/**
* Return Viewport Height
* @return int
*/
public function getViewportHeight()
{
return $this->viewportHeight;
}

/**
* Return Height
* @return int
*/
public function getHeight()
{
return $this->height;
}

/**
* Return Width
* @return int
*/
public function getWidth()
{
return $this->width;
}

/**
* Check if requested URL is available
* @return void
*/
public function isUrlAvailable()
{
$url = $this->screenshot->getRequestUrl();
$ping = app()->make(Ping::class);

if ($ping->isUp($url) === false) {
throw new UnavailableHostException("The URL {$url} is unavailable.", 422);
}
}


/**
* Create an empty file for testing purposes.
* (Should be replaced by a virtual file system)
* @param string $path
* @return void
*/
public function createTestFile($path)
{
\File::put(public_path($path), 'foo');
}
}
21 changes: 21 additions & 0 deletions app/Core/Client/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Screeenly\Core\Client;

interface ClientInterface
{
/**
* Boot Headless Browser
* Perfect to setup default values
* @return void
*/
public function boot();

/**
* Method to capture a Screenshot
* @param string $url
* @param mixed $key
* @return Screeenly\Core\Screeenshot\Screenshot
*/
public function capture($url, $key = null);
}
Loading

0 comments on commit 6e9dfcb

Please sign in to comment.