Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 8, 2021
1 parent 96da836 commit 7cd234a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-ray` will be documented in this file

## 1.2.0 - 2021-01-08

- add support for `local_path` and `remote_path` settings

## 1.1.0 - 2021-01-07

- add support for Lumen (#22)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"illuminate/database": "^7.0|^8.13",
"illuminate/support": "^7.0|^8.13",
"spatie/backtrace": "^1.0",
"spatie/ray": "^1.1",
"spatie/ray": "^1.3",
"symfony/stopwatch": "4.2|^5.2"
},
"require-dev": {
Expand Down
13 changes: 6 additions & 7 deletions src/OriginFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Spatie\LaravelRay\DumpRecorder\DumpRecorder;
use Spatie\Ray\Origin\Origin;
use Spatie\Ray\Ray;
use Spatie\Ray\Settings\Settings;

class OriginFactory
{
Expand Down Expand Up @@ -58,31 +59,29 @@ protected function getFrame(): ?Frame
}

if ($rayFrame->class === Collection::class && Str::startsWith($rayFrame->method, 'Spatie\LaravelRay')) {
$originFrame = $this->findFrameForCollectionMacro($frames, $indexOfRay);
return $this->findFrameForCollectionMacro($frames, $indexOfRay);
}

if ($rayFrame->class === QueryLogger::class) {
$originFrame = $this->findFrameForQuery($frames);
return $this->findFrameForQuery($frames);
}

if ($rayFrame->class === DumpRecorder::class) {
$originFrame = $this->findFrameForDump($frames);
return $this->findFrameForDump($frames);
}

if ($originFrame->class === Dispatcher::class) {
$originFrame = $this->findFrameForEvent($frames);
return $this->findFrameForEvent($frames);
}

if (Str::endsWith($originFrame->file, Ray::makePathOsSafe('/vendor/psy/psysh/src/ExecutionLoopClosure.php'))) {
$this->returnTinkerFrame();
}

if (Str::startsWith($originFrame->file, storage_path('framework/views'))) {
$originFrame = $this->replaceCompiledViewPathWithOriginalViewPath($originFrame);
return $this->replaceCompiledViewPathWithOriginalViewPath($originFrame);
}

$originFrame->file = \Spatie\LaravelRay\Ray::replaceRemotePathWithLocalPath($originFrame->file);

return $originFrame;
}

Expand Down
5 changes: 0 additions & 5 deletions src/Ray.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,5 @@ public function sendRequest($payloads, array $meta = []): BaseRay
return BaseRay::sendRequest($payloads, $meta);
}

public static function replaceRemotePathWithLocalPath($file_path)
{
$settings = app(Settings::class);

return str_replace($settings->remote_path, $settings->local_path, $file_path);
}
}
15 changes: 15 additions & 0 deletions tests/RayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,19 @@ public function the_show_events_function_accepts_a_callable()
$this->assertCount(1, $this->client->sentPayloads());
$this->assertEquals('event in callable', Arr::get($this->client->sentPayloads(), '0.payloads.0.content.name'));
}

/** @test */
public function it_can_replace_the_remote_path_with_the_local_one()
{
app(Settings::class)->remote_path = 'tests';
app(Settings::class)->local_path = 'local_tests';

ray('test');

$this->assertEquals(
'/local_tests/RayTest.php',
Arr::get($this->client->sentPayloads(), '0.payloads.0.origin.file')
);

}
}

0 comments on commit 7cd234a

Please sign in to comment.