Skip to content

Commit 83bc8bf

Browse files
committed
feat: add clear_all and confetti
Add support for ray!().clear_all() and ray!().confetti
1 parent d23be5b commit 83bc8bf

File tree

6 files changed

+281
-10
lines changed

6 files changed

+281
-10
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 10
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
- uses: bp3d-actions/audit-check@9c23bd47e5e7b15b824739e0862cb878a52cc211
1515
with:
1616
token: ${{ secrets.GITHUB_TOKEN }}
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
timeout-minutes: 10
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
- uses: dtolnay/rust-toolchain@stable
2525

2626
- uses: taiki-e/install-action@nextest
@@ -35,7 +35,7 @@ jobs:
3535
- name: Prepare symlink configuration
3636
run: git config --global core.symlinks true
3737

38-
- uses: actions/checkout@v3
38+
- uses: actions/checkout@v4
3939
- uses: dtolnay/rust-toolchain@stable
4040

4141
- uses: taiki-e/install-action@nextest
@@ -52,7 +52,7 @@ jobs:
5252
runs-on: ubuntu-latest
5353
timeout-minutes: 25
5454
steps:
55-
- uses: actions/checkout@v3
55+
- uses: actions/checkout@v4
5656
- uses: dtolnay/rust-toolchain@stable
5757

5858
- name: cargo-release Cache

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55
authors = ["ALameLlama NicholasACiechanowski@gmail.com"]
66
description = "Spatie Ray in Rust"
77
homepage = "https://github.com/ALameLlama/ray-rust"
8+
readme = "README.md"
89
repository = "https://github.com/ALameLlama/ray-rust"
910
license = "MIT"
1011
keywords = ["spatie", "ray", "debug"]

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
# ray-rust
2-
# ray-rust
2+
3+
This is currently WIP and still missing features but has basic ray debugging.
4+
5+
## Examples
6+
7+
```rust
8+
use ray_rust::*
9+
10+
fn main() {
11+
ray!("Hello World");
12+
13+
ray!("Hello World!").color("green");
14+
15+
ray!().html("<strong>Hello World! 🦀</strong>");
16+
}
17+
```
18+
19+
## Installation
20+
21+
Add this to your `Cargo.toml`:
22+
23+
```toml
24+
[dependencies]
25+
ray-rust = "0.1"
26+
```

src/lib.rs

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ macro_rules! ray {
2727
}};
2828
}
2929

30+
#[macro_export]
31+
macro_rules! rd {
32+
() => {{
33+
Ray::new()
34+
35+
todo!("Need to add die");
36+
}};
37+
($($arg:expr),*) => {{
38+
let mut ray = Ray::new();
39+
let mut vec = Vec::new();
40+
41+
$(vec.push(format!("{:#?}", $arg));)*
42+
43+
ray.log(vec);
44+
45+
ray
46+
47+
todo!("Need to add die");
48+
}};
49+
}
50+
3051
#[derive(Debug, Serialize, Deserialize, Clone)]
3152
pub struct RayPayload {
3253
uuid: String,
@@ -116,6 +137,22 @@ impl Ray {
116137
self
117138
}
118139

140+
pub fn clear_all(&mut self) -> &mut Self {
141+
let message = RayMessage::ClearAll(RayClearAll {
142+
label: RayMessageType::ClearAll,
143+
});
144+
145+
let content = RayContent {
146+
content_type: RayClearAll::get_type(),
147+
origin: RayOrigin::new(),
148+
content: message,
149+
};
150+
151+
self.request.payloads.push(content);
152+
153+
self.send()
154+
}
155+
119156
pub fn log(&mut self, values: Vec<String>) -> &mut Self {
120157
let message = RayMessage::Log(RayLog {
121158
label: RayMessageType::Log,
@@ -182,4 +219,170 @@ impl Ray {
182219

183220
self.send()
184221
}
222+
223+
pub fn confetti(&mut self) -> &mut Self {
224+
let message = RayMessage::Confetti(RayConfetti {
225+
label: RayMessageType::Confetti,
226+
});
227+
228+
let content = RayContent {
229+
content_type: RayConfetti::get_type(),
230+
origin: RayOrigin::new(),
231+
content: message,
232+
};
233+
234+
self.request.payloads.push(content);
235+
236+
self.send()
237+
}
238+
239+
pub fn count(&mut self) -> &mut Self {
240+
todo!();
241+
}
242+
243+
pub fn counter_value(&mut self) -> &mut Self {
244+
todo!();
245+
}
246+
247+
pub fn die(&mut self) -> &mut Self {
248+
todo!();
249+
}
250+
251+
pub fn disable(&mut self) -> &mut Self {
252+
todo!();
253+
}
254+
255+
pub fn disabled(&mut self) -> &mut Self {
256+
todo!();
257+
}
258+
259+
pub fn enable(&mut self) -> &mut Self {
260+
todo!();
261+
}
262+
263+
pub fn enabled(&mut self) -> &mut Self {
264+
todo!();
265+
}
266+
267+
pub fn file(&mut self) -> &mut Self {
268+
todo!();
269+
}
270+
271+
pub fn gray(&mut self) -> &mut Self {
272+
todo!();
273+
}
274+
275+
pub fn green(&mut self) -> &mut Self {
276+
todo!();
277+
}
278+
279+
pub fn hide(&mut self) -> &mut Self {
280+
todo!();
281+
}
282+
283+
pub fn hide_app(&mut self) -> &mut Self {
284+
todo!();
285+
}
286+
287+
pub fn image(&mut self) -> &mut Self {
288+
todo!();
289+
}
290+
291+
// I'm not sure if this is possible in Rust
292+
pub fn r#if(&mut self) -> &mut Self {
293+
todo!();
294+
}
295+
296+
pub fn json(&mut self) -> &mut Self {
297+
todo!();
298+
}
299+
300+
pub fn label(&mut self) -> &mut Self {
301+
todo!();
302+
}
303+
304+
pub fn large(&mut self) -> &mut Self {
305+
todo!();
306+
}
307+
308+
pub fn limit(&mut self) -> &mut Self {
309+
todo!();
310+
}
311+
312+
pub fn link(&mut self) -> &mut Self {
313+
todo!();
314+
}
315+
316+
pub fn measure(&mut self) -> &mut Self {
317+
todo!();
318+
}
319+
320+
pub fn new_screen(&mut self) -> &mut Self {
321+
todo!();
322+
}
323+
324+
pub fn notify(&mut self) -> &mut Self {
325+
todo!();
326+
}
327+
328+
pub fn orange(&mut self) -> &mut Self {
329+
todo!();
330+
}
331+
332+
pub fn pass(&mut self) -> &mut Self {
333+
todo!();
334+
}
335+
336+
pub fn pause(&mut self) -> &mut Self {
337+
todo!();
338+
}
339+
340+
pub fn info(&mut self) -> &mut Self {
341+
todo!();
342+
}
343+
344+
pub fn purple(&mut self) -> &mut Self {
345+
todo!();
346+
}
347+
348+
// TODO: This has 3 functions max, per_second and clear
349+
pub fn rate_limiter(&mut self) -> &mut Self {
350+
todo!();
351+
}
352+
353+
pub fn red(&mut self) -> &mut Self {
354+
todo!();
355+
}
356+
357+
pub fn separator(&mut self) -> &mut Self {
358+
todo!();
359+
}
360+
361+
pub fn show_app(&mut self) -> &mut Self {
362+
todo!();
363+
}
364+
365+
pub fn small(&mut self) -> &mut Self {
366+
todo!();
367+
}
368+
369+
pub fn table(&mut self) -> &mut Self {
370+
todo!();
371+
}
372+
373+
pub fn to_json(&mut self) -> &mut Self {
374+
todo!();
375+
}
376+
377+
pub fn trace(&mut self) -> &mut Self {
378+
todo!();
379+
}
380+
381+
pub fn url(&mut self) -> &mut Self {
382+
todo!();
383+
}
384+
385+
pub fn xml(&mut self) -> &mut Self {
386+
todo!();
387+
}
185388
}

src/message.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,36 @@ pub enum RayMessage {
77
Text(RayText),
88
Color(RayColor),
99
HTML(RayHtml),
10+
ClearAll(RayClearAll),
11+
Confetti(RayConfetti),
1012
}
1113

1214
#[derive(Debug, Serialize, Deserialize, Clone)]
1315
pub enum RayMessageType {
1416
Log,
1517
Text,
1618
HTML,
19+
ClearAll,
20+
Confetti,
1721
}
1822

1923
#[derive(Debug, Serialize, Deserialize, Clone)]
2024
pub enum RayContentType {
2125
Log,
2226
Custom,
2327
Color,
28+
ClearAll,
29+
Confetti,
2430
}
2531

2632
impl RayContentType {
27-
pub fn as_string(&self) -> String {
33+
pub fn to_string(&self) -> String {
2834
match self {
2935
RayContentType::Log => "log".to_string(),
3036
RayContentType::Custom => "custom".to_string(),
3137
RayContentType::Color => "color".to_string(),
38+
RayContentType::ClearAll => "clear_all".to_string(),
39+
RayContentType::Confetti => "confetti".to_string(),
3240
}
3341
}
3442
}
@@ -42,7 +50,7 @@ pub struct RayLog {
4250

4351
impl RayLog {
4452
pub fn get_type() -> String {
45-
RayContentType::Log.as_string()
53+
RayContentType::Log.to_string()
4654
}
4755
}
4856

@@ -55,7 +63,7 @@ pub struct RayText {
5563

5664
impl RayText {
5765
pub fn get_type() -> String {
58-
RayContentType::Custom.as_string()
66+
RayContentType::Custom.to_string()
5967
}
6068
}
6169

@@ -67,7 +75,7 @@ pub struct RayColor {
6775

6876
impl RayColor {
6977
pub fn get_type() -> String {
70-
RayContentType::Color.as_string()
78+
RayContentType::Color.to_string()
7179
}
7280
}
7381

@@ -106,6 +114,30 @@ pub struct RayHtml {
106114

107115
impl RayHtml {
108116
pub fn get_type() -> String {
109-
RayContentType::Custom.as_string()
117+
RayContentType::Custom.to_string()
118+
}
119+
}
120+
121+
// https://github.com/spatie/ray/blob/main/src/Payloads/ClearAllPayload.php
122+
#[derive(Debug, Serialize, Deserialize, Clone)]
123+
pub struct RayClearAll {
124+
pub label: RayMessageType,
125+
}
126+
127+
impl RayClearAll {
128+
pub fn get_type() -> String {
129+
RayContentType::ClearAll.to_string()
130+
}
131+
}
132+
133+
// https://github.com/spatie/ray/blob/main/src/Payloads/ConfettiPayload.php
134+
#[derive(Debug, Serialize, Deserialize, Clone)]
135+
pub struct RayConfetti {
136+
pub label: RayMessageType,
137+
}
138+
139+
impl RayConfetti {
140+
pub fn get_type() -> String {
141+
RayContentType::Confetti.to_string()
110142
}
111143
}

0 commit comments

Comments
 (0)