diff --git a/docs/usage/framework-agnostic-php-project.md b/docs/usage/framework-agnostic-php-project.md index 05191cbd..e64845cc 100644 --- a/docs/usage/framework-agnostic-php-project.md +++ b/docs/usage/framework-agnostic-php-project.md @@ -58,6 +58,19 @@ ray(['John', 'Paul', 'George', 'Ringo'])->label('Beatles'); ![screenshot](/docs/ray/v1/images/label.png) +### Showing a separator + +Another way to visually separate items in Ray, is to call `seperator`. + +```php +ray('first item'); + +ray()->separator(); + +ray('second item'); +``` + +![screenshot](/docs/ray/v1/images/separator.png) ### Creating a new screen @@ -193,7 +206,6 @@ foreach (range(1, 10) as $i) { If the argument passed to `limit()` is a negative number or zero, limiting is disabled. - ### Using a rate limiter A rate limiter can help to reduce the amount of sent messages. This would avoid spamming the desktop app, which can be helpful when using Ray in loops. @@ -213,7 +225,6 @@ Ray::rateLimiter()->clear(); A message to the desktop app will be sent once to notify the user the rate limit has been reached. - ### Sending a payload once To only send a payload once, use the `once` function. This is useful for debugging loops. diff --git a/docs/usage/reference.md b/docs/usage/reference.md index f536fbc1..a8f1955b 100644 --- a/docs/usage/reference.md +++ b/docs/usage/reference.md @@ -75,6 +75,7 @@ To display something in Ray use the `ray()` function. It accepts everything: str | `ray()->rateLimiter()->clear()` | Clears the rate limits | | `ray()->raw($value)` | Send raw output of a value to Ray without fancy formatting | | `ray(…)->red()` | Output in red | +| `ray()->separator()` | Add a visual separator | | `ray()->showApp()` | Bring the app to the foreground | | `ray(…)->small()` | Output text smaller | | `ray()->table($array, $label)` | Format an associative array with optional label | diff --git a/src/Payloads/SeparatorPayload.php b/src/Payloads/SeparatorPayload.php new file mode 100644 index 00000000..721329e7 --- /dev/null +++ b/src/Payloads/SeparatorPayload.php @@ -0,0 +1,11 @@ +sendRequest($payload); + } + public function html(string $html = ''): self { $payload = new HtmlPayload($html); diff --git a/tests/RayTest.php b/tests/RayTest.php index d6e6372c..f724d614 100644 --- a/tests/RayTest.php +++ b/tests/RayTest.php @@ -1286,6 +1286,14 @@ public function it_can_dump_a_string_with_a_global_function_name() $this->assertMatchesOsSafeSnapshot($this->client->sentPayloads()); } + /** @test */ + public function it_can_send_a_separator() + { + $this->ray->send('separator'); + + $this->assertMatchesOsSafeSnapshot($this->client->sentPayloads()); + } + protected function getNewRay(): Ray { return Ray::create($this->client, 'fakeUuid'); diff --git a/tests/__snapshots__/RayTest__it_can_send_a_separator__1.json b/tests/__snapshots__/RayTest__it_can_send_a_separator__1.json new file mode 100644 index 00000000..d0a34a5d --- /dev/null +++ b/tests/__snapshots__/RayTest__it_can_send_a_separator__1.json @@ -0,0 +1,21 @@ +[ + { + "uuid": "fakeUuid", + "payloads": [ + { + "type": "log", + "content": { + "values": [ + "separator" + ] + }, + "origin": { + "file": "\/tests\/RayTest.php", + "line_number": "xxx", + "hostname": "fake-hostname" + } + } + ], + "meta": [] + } +]