asciinema_win 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: de31be564fc0382570323062a4fa0d780817be8af884c4f9b1d653d1c977e0f3
4
+ data.tar.gz: c31008a892536f6021788856bc338bf5836e7c8a84936382b5648145bbcf61ad
5
+ SHA512:
6
+ metadata.gz: 75637a47e7fd9a911e1789d760c594d43f3c22d078018411145093ed1c2007571f85bdc5aaa0599f8ad788401d67c177d6753206dc6ac88f10b4f5ca3da6f1f8
7
+ data.tar.gz: 6698dce62a9af34a753aa851052cb91d5409aea6c1b980e554108ae4b41f7e87ee09a5ab673109af6972a72f15b31977d2dfbbe529f23ea15a3a1f7a4592a527
data/README.md ADDED
@@ -0,0 +1,575 @@
1
+ # asciinema-win + Rich-Ruby
2
+
3
+ [![Ruby Version](https://img.shields.io/badge/ruby-3.4%2B-cc342d?style=flat-square&logo=ruby&logoColor=white)](https://www.ruby-lang.org/)
4
+ [![Platform](https://img.shields.io/badge/platform-Windows-0078d4?style=flat-square&logo=windows&logoColor=white)](https://github.com/yourusername/asciinema-win)
5
+ [![License](https://img.shields.io/badge/license-MIT-0078d4?style=flat-square)](LICENSE)
6
+ [![Pure Ruby](https://img.shields.io/badge/dependencies-zero-0078d4?style=flat-square)](https://github.com/yourusername/asciinema-win)
7
+ [![Tests](https://img.shields.io/badge/tests-118%20passing-0078d4?style=flat-square)](examples/comprehensive_test.rb)
8
+
9
+ > **Native Windows Terminal Recorder & Rich Text Library in Pure Ruby**
10
+
11
+ This project contains two integrated components:
12
+
13
+ 1. **asciinema-win** Native Windows terminal recorder with asciicast v2 format
14
+ 2. **Rich-Ruby** Beautiful terminal formatting with colors, tables, trees, syntax highlighting
15
+ 3. **Zero external dependencies** Pure Ruby only (uses Fiddle for Win32 API)
16
+
17
+ ---
18
+
19
+ ## Table of Contents
20
+
21
+ - [asciinema-win](#asciinema-win)
22
+ - [Features](#asciinema-features)
23
+ - [Quick Start](#asciinema-quick-start)
24
+ - [CLI Reference](#cli-reference)
25
+ - [Ruby API](#ruby-api)
26
+ - [Export Formats](#export-formats)
27
+ - [Rich-Ruby](#rich-ruby)
28
+ - [Features](#rich-ruby-features)
29
+ - [Quick Start](#rich-ruby-quick-start)
30
+ - [Usage Guide](#usage-guide)
31
+ - [Requirements](#requirements)
32
+ - [Installation](#installation)
33
+ - [Documentation](#documentation)
34
+ - [License](#license)
35
+
36
+ ---
37
+
38
+ # asciinema-win
39
+
40
+ Record and playback terminal sessions on native Windows with accurate timing and full color support. Produces recordings compatible with [asciinema.org](https://asciinema.org).
41
+
42
+ <a name="asciinema-features"></a>
43
+ ## Features
44
+
45
+ - **Zero Dependencies** - Pure Ruby using only stdlib (Fiddle for Win32 API)
46
+ - **Native Windows** - Direct access to Windows Console APIs
47
+ - **asciicast v2** - Recordings compatible with asciinema.org
48
+ - **Rich-Ruby Integration** - Beautiful terminal rendering
49
+ - **Multiple Export Formats** - HTML, SVG, text, JSON, and video (with FFmpeg)
50
+
51
+ ### Recording
52
+ - Capture screen buffer with colors and attributes
53
+ - Precise timing with microsecond accuracy
54
+ - Idle time limiting
55
+ - Command recording mode
56
+
57
+ ### Playback
58
+ - Accurate timing reproduction
59
+ - Adjustable speed (0.5x, 1x, 2x, etc.)
60
+ - Pause on markers
61
+
62
+ <a name="asciinema-quick-start"></a>
63
+ ## Quick Start
64
+
65
+ > **Note:** Use the full Ruby path: `C:\RubyMSVC34\bin\ruby.exe`
66
+
67
+ ### Record a Terminal Session
68
+
69
+ ```powershell
70
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win rec session.cast
71
+ # Press Ctrl+D to stop recording
72
+ ```
73
+
74
+ ### Record a Specific Command
75
+
76
+ ```powershell
77
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win rec -c "dir /s" output.cast
78
+ ```
79
+
80
+ ### Play Back a Recording
81
+
82
+ ```powershell
83
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win play session.cast
84
+ ```
85
+
86
+ ### Play at 2x Speed
87
+
88
+ ```powershell
89
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win play -s 2 session.cast
90
+ ```
91
+
92
+ ### Get Recording Info
93
+
94
+ ```powershell
95
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win info session.cast
96
+ ```
97
+
98
+ ### Export to HTML
99
+
100
+ ```powershell
101
+ C:\RubyMSVC34\bin\ruby.exe -Ilib exe\asciinema_win export session.cast -o session.html
102
+ ```
103
+
104
+ <a name="cli-reference"></a>
105
+ ## CLI Reference
106
+
107
+ ### `asciinema_win rec`
108
+
109
+ Record a terminal session.
110
+
111
+ ```
112
+ Usage: asciinema_win rec [options] <filename>
113
+
114
+ Options:
115
+ -t, --title <title> Recording title
116
+ -c, --command <cmd> Record specific command
117
+ -i, --idle-time-limit <s> Max idle time (default: 2.0)
118
+ -y, --overwrite Overwrite existing file
119
+ ```
120
+
121
+ ### `asciinema_win play`
122
+
123
+ Play back a recording.
124
+
125
+ ```
126
+ Usage: asciinema_win play [options] <filename>
127
+
128
+ Options:
129
+ -s, --speed <factor> Playback speed (default: 1.0)
130
+ -i, --idle-time-limit <s> Max idle time between frames
131
+ -m, --pause-on-markers Pause at marker events
132
+ ```
133
+
134
+ ### `asciinema_win export`
135
+
136
+ Export to other formats.
137
+
138
+ ```
139
+ Usage: asciinema_win export [options] <filename>
140
+
141
+ Formats:
142
+ html Standalone HTML with embedded player
143
+ svg SVG image snapshot
144
+ txt Plain text (ANSI stripped)
145
+ json Normalized JSON
146
+ gif Animated GIF (requires FFmpeg)
147
+ mp4 MP4 video (requires FFmpeg)
148
+ webm WebM video (requires FFmpeg)
149
+
150
+ Options:
151
+ -f, --format <fmt> Output format
152
+ -o, --output <file> Output file path
153
+ -t, --title <title> Title for HTML export
154
+ ```
155
+
156
+ ### `asciinema_win cat`
157
+
158
+ Output to stdout without timing.
159
+
160
+ ```
161
+ Usage: asciinema_win cat <filename>
162
+ ```
163
+
164
+ ### `asciinema_win info`
165
+
166
+ Show recording metadata.
167
+
168
+ ```
169
+ Usage: asciinema_win info <filename>
170
+ ```
171
+
172
+ <a name="ruby-api"></a>
173
+ ## Ruby API
174
+
175
+ ### Recording
176
+
177
+ ```ruby
178
+ require 'asciinema_win'
179
+
180
+ # Record an interactive session
181
+ AsciinemaWin.record("session.cast", title: "My Demo")
182
+
183
+ # Record a command
184
+ AsciinemaWin.record("command.cast", command: "dir /s")
185
+ ```
186
+
187
+ ### Playback
188
+
189
+ ```ruby
190
+ require 'asciinema_win'
191
+
192
+ # Simple playback
193
+ AsciinemaWin.play("session.cast")
194
+
195
+ # With options
196
+ AsciinemaWin.play("session.cast", speed: 2.0)
197
+ ```
198
+
199
+ ### Export
200
+
201
+ ```ruby
202
+ require 'asciinema_win'
203
+
204
+ # Export to HTML
205
+ AsciinemaWin::Export.export("session.cast", "output.html", format: :html)
206
+
207
+ # Export to SVG with theme
208
+ AsciinemaWin::Export.export("session.cast", "output.svg", format: :svg, theme: "dracula")
209
+ ```
210
+
211
+ ### Creating Recordings Programmatically
212
+
213
+ ```ruby
214
+ require 'asciinema_win'
215
+
216
+ AsciinemaWin::Asciicast.create("demo.cast", width: 80, height: 24) do |writer|
217
+ writer.write_output(0.0, "Hello ")
218
+ writer.write_output(0.5, "\e[32mWorld!\e[0m\r\n")
219
+ writer.write_marker(1.0, "greeting done")
220
+ end
221
+ ```
222
+
223
+ <a name="export-formats"></a>
224
+ ## Export Formats
225
+
226
+ | Format | Extension | Dependencies | Description |
227
+ |--------|-----------|--------------|-------------|
228
+ | Cast | `.cast` | None | Asciicast v2 (with speed/trim options) |
229
+ | HTML | `.html` | None | Standalone page with asciinema-player |
230
+ | SVG | `.svg` | None | Colored terminal snapshot with themes |
231
+ | Text | `.txt` | None | Plain text with ANSI stripped |
232
+ | JSON | `.json` | None | Normalized event data |
233
+ | GIF | `.gif` | FFmpeg | Animated GIF |
234
+ | MP4 | `.mp4` | FFmpeg | MP4 video |
235
+ | WebM | `.webm` | FFmpeg | WebM video |
236
+
237
+ ### Terminal Themes
238
+
239
+ SVG exports support multiple color themes:
240
+
241
+ - `asciinema` (default)
242
+ - `dracula`
243
+ - `monokai`
244
+ - `solarized-dark`
245
+ - `solarized-light`
246
+ - `nord`
247
+ - `one-dark`
248
+ - `github-dark`
249
+ - `tokyo-night`
250
+
251
+ ```ruby
252
+ # Export with Dracula theme
253
+ AsciinemaWin::Export.export("demo.cast", "demo.svg", format: :svg, theme: "dracula")
254
+
255
+ # List available themes
256
+ AsciinemaWin::Themes.names # => ["asciinema", "dracula", "monokai", ...]
257
+ ```
258
+
259
+ ### Speed Adjustment & Idle Compression
260
+
261
+ ```ruby
262
+ # Speed up playback 2x
263
+ AsciinemaWin::Export.adjust_speed("input.cast", "output.cast", speed: 2.0)
264
+
265
+ # Compress idle time to max 0.5s
266
+ AsciinemaWin::Export.adjust_speed("input.cast", "output.cast", max_idle: 0.5)
267
+
268
+ # Both
269
+ AsciinemaWin::Export.adjust_speed("input.cast", "output.cast", speed: 1.5, max_idle: 0.5)
270
+ ```
271
+
272
+ ### Recording Concatenation
273
+
274
+ ```ruby
275
+ # Combine multiple recordings
276
+ AsciinemaWin::Export.concatenate(
277
+ ["part1.cast", "part2.cast", "part3.cast"],
278
+ "combined.cast",
279
+ title: "Full Demo",
280
+ gap: 1.0 # seconds between recordings
281
+ )
282
+ ```
283
+
284
+ ### Thumbnail Generation
285
+
286
+ ```ruby
287
+ # Generate thumbnail from last frame
288
+ AsciinemaWin::Export.thumbnail("demo.cast", "thumb.svg", frame: :last, theme: "dracula")
289
+
290
+ # Other frame options: :first, :middle, or specific time in seconds
291
+ AsciinemaWin::Export.thumbnail("demo.cast", "thumb.svg", frame: :middle)
292
+ AsciinemaWin::Export.thumbnail("demo.cast", "thumb.svg", frame: 5.0) # at 5s
293
+ ```
294
+
295
+ ### Organized Output
296
+
297
+ Use `OutputOrganizer` for structured output directories:
298
+
299
+ ```ruby
300
+ # Create a session
301
+ session = AsciinemaWin::OutputOrganizer.create_session("my_demo")
302
+
303
+ # Get paths for various outputs
304
+ recording = session.recording_path("demo") # asciinema_output/recordings/my_demo_YYYYMMDD_HHMMSS/demo.cast
305
+ svg_path = session.export_path("demo", format: :svg) # asciinema_output/svg/my_demo_YYYYMMDD_HHMMSS/demo.svg
306
+ thumb = session.thumbnail_path("demo", frame: :last) # asciinema_output/thumbnails/svg/.../demo_last.svg
307
+
308
+ # View session summary
309
+ puts session.summary
310
+ ```
311
+
312
+ Output directory structure:
313
+ ```
314
+ asciinema_output/
315
+ ├── recordings/
316
+ │ └── my_demo_20251224_120000/
317
+ │ └── demo.cast
318
+ ├── svg/
319
+ │ └── my_demo_20251224_120000/
320
+ │ ├── demo_asciinema.svg
321
+ │ ├── demo_dracula.svg
322
+ │ └── ...
323
+ ├── html/
324
+ │ └── my_demo_20251224_120000/
325
+ │ └── demo.html
326
+ ├── json/
327
+ ├── text/
328
+ ├── thumbnails/
329
+ │ └── svg/
330
+ │ └── my_demo_20251224_120000/
331
+ │ ├── demo_first.svg
332
+ │ ├── demo_middle.svg
333
+ │ └── demo_last.svg
334
+ └── video/
335
+ ```
336
+
337
+ ---
338
+
339
+ # Rich-Ruby
340
+
341
+ A Pure Ruby library for rich text and beautiful formatting in the terminal.
342
+
343
+ <a name="rich-ruby-features"></a>
344
+ ## Features
345
+
346
+ - **Colors**: 16-color, 256-color, and TrueColor (24-bit)
347
+ - **Styles**: Bold, italic, underline, strikethrough, blink, reverse
348
+ - **Markup**: `[bold red]text[/]` syntax for inline styling
349
+ - **Panels**: Bordered boxes with titles
350
+ - **Tables**: Data tables with alignment and styling
351
+ - **Trees**: Hierarchical tree views
352
+ - **Progress**: Animated progress bars and spinners
353
+ - **Syntax**: Code highlighting for Ruby, Python, JavaScript, SQL
354
+ - **Markdown**: Render Markdown in the terminal
355
+ - **Windows**: Full Windows Console API support
356
+
357
+ <a name="rich-ruby-quick-start"></a>
358
+ ## Quick Start
359
+
360
+ ```ruby
361
+ require 'rich'
362
+
363
+ # Simple styled output
364
+ Rich.print("[bold cyan]Hello[/] [yellow]World![/]")
365
+
366
+ # Create a console for more control
367
+ console = Rich::Console.new
368
+ console.print("Welcome!", style: "bold green")
369
+
370
+ # Display a panel
371
+ panel = Rich::Panel.new(
372
+ "This is important information.",
373
+ title: "Notice",
374
+ border_style: "cyan"
375
+ )
376
+ puts panel.render(max_width: 50)
377
+
378
+ # Display a table
379
+ table = Rich::Table.new(title: "Users")
380
+ table.add_column("Name", header_style: "bold")
381
+ table.add_column("Role")
382
+ table.add_row("Alice", "Admin")
383
+ table.add_row("Bob", "User")
384
+ puts table.render(max_width: 40)
385
+ ```
386
+
387
+ <a name="usage-guide"></a>
388
+ ## Usage Guide
389
+
390
+ ### Colors and Styles
391
+
392
+ ```ruby
393
+ # Named colors
394
+ Rich.print("[red]Error[/] [green]Success[/] [blue]Info[/]")
395
+
396
+ # 256 colors
397
+ Rich.print("[color(208)]Orange[/]")
398
+
399
+ # RGB colors
400
+ Rich.print("[rgb(255,100,50)]Custom[/]")
401
+
402
+ # Background colors
403
+ Rich.print("[white on blue]Highlighted[/]")
404
+
405
+ # Styles
406
+ Rich.print("[bold]Bold[/] [italic]Italic[/] [underline]Underline[/]")
407
+ ```
408
+
409
+ ### Panels
410
+
411
+ ```ruby
412
+ panel = Rich::Panel.new(
413
+ "Content here",
414
+ title: "Title",
415
+ subtitle: "Subtitle",
416
+ border_style: "green",
417
+ padding: [1, 2]
418
+ )
419
+ puts panel.render(max_width: 60)
420
+ ```
421
+
422
+ ### Tables
423
+
424
+ ```ruby
425
+ table = Rich::Table.new(title: "Data", show_header: true)
426
+ table.add_column("ID", justify: :right)
427
+ table.add_column("Name", justify: :left)
428
+ table.add_column("Value", justify: :center)
429
+ table.add_row("1", "Item A", "100")
430
+ table.add_row("2", "Item B", "200")
431
+ puts table.render
432
+ ```
433
+
434
+ ### Trees
435
+
436
+ ```ruby
437
+ tree = Rich::Tree.new("Root")
438
+ child1 = tree.add("Child 1")
439
+ child1.add("Grandchild 1")
440
+ child1.add("Grandchild 2")
441
+ tree.add("Child 2")
442
+ puts tree.render
443
+ ```
444
+
445
+ ### Progress Bars
446
+
447
+ ```ruby
448
+ progress = Rich::Progress.new("Processing", total: 100)
449
+ 100.times do |i|
450
+ progress.update(i + 1)
451
+ sleep(0.05)
452
+ end
453
+ progress.complete!
454
+ ```
455
+
456
+ ### Syntax Highlighting
457
+
458
+ ```ruby
459
+ code = 'def hello; puts "Hello"; end'
460
+ syntax = Rich::Syntax.new(code, "ruby", theme: "monokai")
461
+ puts syntax.render
462
+ ```
463
+
464
+ ---
465
+
466
+ # Requirements
467
+
468
+ - **Ruby**: 3.0+ (tested on 3.4.8 MSVC)
469
+ - **Platform**: Windows 10/11 (asciinema-win requires Windows)
470
+ - **Dependencies**: None (zero external gems)
471
+
472
+ ### Development Environment
473
+
474
+ ```
475
+ C:\RubyMSVC34 # Ruby installation
476
+ C:\Users\#yourusername\vcpkg # Dependencies
477
+ C:\Program Files\Microsoft Visual Studio\18\Community # VS 2026
478
+ ```
479
+
480
+ ---
481
+
482
+ # Installation
483
+
484
+ ### From Source
485
+
486
+ ```powershell
487
+ git clone https://github.com/tigel-agm/asciinema-win.git
488
+ cd asciinema-win
489
+ ```
490
+
491
+ ### Build and Install Gem
492
+
493
+ ```powershell
494
+ C:\RubyMSVC34\bin\gem.bat build asciinema_win.gemspec
495
+ C:\RubyMSVC34\bin\gem.bat install asciinema_win-0.1.0.gem
496
+ ```
497
+
498
+ ---
499
+
500
+ # Documentation
501
+
502
+ - [docs/how-to-use.md](docs/how-to-use.md) - Rich-Ruby usage guide
503
+ - [docs/troubleshooting.md](docs/troubleshooting.md) - Solutions for common issues
504
+ - [docs/windows-notes.md](docs/windows-notes.md) - Windows-specific details
505
+ - [docs/cheat-sheet.md](docs/cheat-sheet.md) - Quick reference
506
+
507
+ ---
508
+
509
+ # Project Structure
510
+
511
+ ```
512
+ asciinema-win/
513
+ ├── asciinema_win.gemspec # Gem specification
514
+ ├── exe/
515
+ │ └── asciinema_win # CLI executable
516
+ ├── lib/
517
+ │ ├── asciinema_win.rb # asciinema-win entry point
518
+ │ ├── asciinema_win/
519
+ │ │ ├── version.rb
520
+ │ │ ├── screen_buffer.rb # Screen capture
521
+ │ │ ├── asciicast.rb # File format
522
+ │ │ ├── recorder.rb # Recording engine
523
+ │ │ ├── player.rb # Playback engine
524
+ │ │ ├── export.rb # Export formats
525
+ │ │ └── cli.rb # CLI
526
+ │ └── rich/ # Rich-Ruby library
527
+ │ ├── console.rb
528
+ │ ├── text.rb
529
+ │ ├── panel.rb
530
+ │ ├── table.rb
531
+ │ ├── tree.rb
532
+ │ ├── progress.rb
533
+ │ ├── syntax.rb
534
+ │ ├── markdown.rb
535
+ │ └── win32_console.rb # Windows API
536
+ ├── examples/
537
+ │ ├── test_capture.rb
538
+ │ ├── rich_ruby_recording_demo.rb
539
+ │ └── create_sample_recording.rb
540
+ └── docs/
541
+ └── ...
542
+ ```
543
+
544
+ ---
545
+
546
+ # File Format
547
+
548
+ asciinema-win uses **asciicast v2** format (newline-delimited JSON):
549
+
550
+ ```json
551
+ {"version":2,"width":80,"height":24,"timestamp":1735052000,"title":"Demo"}
552
+ [0.0,"o","Hello "]
553
+ [0.5,"o","\u001b[32mWorld!\u001b[0m\r\n"]
554
+ [1.0,"m","marker label"]
555
+ ```
556
+
557
+ Event types:
558
+ - `"o"` - Output (terminal data)
559
+ - `"i"` - Input (keyboard)
560
+ - `"r"` - Resize (`"80x24"`)
561
+ - `"m"` - Marker (bookmark)
562
+
563
+ ---
564
+
565
+ # License
566
+
567
+ MIT License - See [LICENSE](LICENSE)
568
+
569
+ ---
570
+
571
+ # Credits
572
+
573
+ - Inspired by [asciinema](https://asciinema.org)
574
+ - Rich-Ruby inspired by Python's [Rich](https://github.com/Textualize/rich)
575
+ - Developed on Ruby 3.4.8 (MSVC) on Windows
data/exe/asciinema_win ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # asciinema-win executable
4
+ #
5
+ # Native Windows terminal recorder and player in pure Ruby.
6
+ # Compatible with asciicast v2 format.
7
+ #
8
+ # Usage:
9
+ # asciinema_win rec <filename> Record terminal session
10
+ # asciinema_win play <filename> Play back recording
11
+ # asciinema_win cat <filename> Output to stdout (no timing)
12
+ # asciinema_win info <filename> Show recording info
13
+ # asciinema_win --help Show help
14
+
15
+ require_relative "../lib/asciinema_win"
16
+
17
+ exit AsciinemaWin::CLI.run(ARGV)