inlay 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +5 -2
- data/LICENSE.txt +1 -1
- data/README.md +10 -2
- data/lib/inlay/iruby.rb +54 -0
- data/lib/inlay/version.rb +1 -1
- metadata +38 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d97c1adc5805bd106533e8d79ca1f4c0d4a53b7c12a0fd2fb7bf63019fb31850
|
|
4
|
+
data.tar.gz: c3269a059efd2d082b2490236c045bf13d1784561fd211b432ec58092e632506
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f6dee9822a3703252c9ab592e7349b24a2a7e309d8fa208a2280726b2d77a3093f6a55009e33ae797bea2f311ebde574bc5093c8bbe206a30530463e52b7130
|
|
7
|
+
data.tar.gz: 2bf9bd10319948f0cbc6b48a86525bd83bd0c40906a5fd58feb1b9469d3c0cd4ff88d706c01af2da6a9666f0b6681db0603360735397c61f733d49f50066442d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.2.0
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- Add terminal image output and explicit `Inlay.show` API.
|
|
6
|
+
- Add `to_inlay` normalization and custom adapters.
|
|
7
|
+
- Integrate IRB, Pry, and IRuby display registries.
|
|
8
|
+
- Support notebook SVG, PNG, and animated GIF output.
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Inlay
|
|
2
2
|
|
|
3
|
-
Render Ruby graphics where you inspect them. Inlay shows Tessel images, RBGL surfaces, and chart output in
|
|
3
|
+
Render Ruby graphics where you inspect them. Inlay shows Tessel images, RBGL surfaces, and chart output in IRB, Pry, and IRuby, using terminal graphics protocols or notebook MIME output.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Render Ruby graphics where you inspect them. Inlay shows Tessel images, RBGL sur
|
|
|
8
8
|
gem install inlay
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Add `inlay` to your Gemfile. Inlay uses [Tessel](https://github.com/rbgfx/tessel) for images and [Termvas](https://github.com/rbgfx/termvas) for terminal output.
|
|
11
|
+
Add `inlay` to your Gemfile. Inlay uses [Tessel](https://github.com/rbgfx/tessel) for images and [Termvas](https://github.com/rbgfx/termvas) for terminal output. Flipbook adds animated GIF display in IRuby.
|
|
12
12
|
|
|
13
13
|
## Use in IRB
|
|
14
14
|
|
|
@@ -51,6 +51,14 @@ Objects can implement `to_inlay` and return a `Tessel::Image`, `{ png: bytes }`,
|
|
|
51
51
|
Inlay.register(MySurface) { |surface| surface.to_tessel_image }
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
## Use in IRuby
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
require "inlay/iruby"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Images are returned as PNG, SVG output as SVG, and animations as an embedded GIF when Flipbook is installed. Without Flipbook, an animation displays its first frame.
|
|
61
|
+
|
|
54
62
|
## Configuration
|
|
55
63
|
|
|
56
64
|
`Inlay.config.enabled` toggles terminal rendering. `max_rows` caps terminal height and `max_pixels` limits decoded and displayed input size. Small images (up to 32×32) are enlarged with nearest-neighbor scaling; larger images are reduced with alpha-aware area averaging. Set `INLAY=off` to disable terminal output for a process.
|
data/lib/inlay/iruby.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "inlay"
|
|
4
|
+
require "mime/types"
|
|
5
|
+
require "iruby/display"
|
|
6
|
+
require "base64"
|
|
7
|
+
require "tempfile"
|
|
8
|
+
begin
|
|
9
|
+
require "flipbook"
|
|
10
|
+
rescue LoadError
|
|
11
|
+
# Animation falls back to its first frame when Flipbook is unavailable.
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Inlay
|
|
15
|
+
module IRubyIntegration
|
|
16
|
+
module_function
|
|
17
|
+
|
|
18
|
+
def install
|
|
19
|
+
return if @installed
|
|
20
|
+
|
|
21
|
+
registry = IRuby::Display::Registry
|
|
22
|
+
registry.match { |object| Inlay.displayable?(object) }
|
|
23
|
+
registry.priority(100)
|
|
24
|
+
registry.format(nil) { |object| render(object) }
|
|
25
|
+
@installed = true
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def render(object)
|
|
29
|
+
normalized = Inlay.normalize(object)
|
|
30
|
+
if normalized.svg
|
|
31
|
+
["image/svg+xml", normalized.svg]
|
|
32
|
+
elsif normalized.png.is_a?(String)
|
|
33
|
+
["image/png", normalized.png]
|
|
34
|
+
elsif normalized.frames
|
|
35
|
+
animation(normalized.frames, normalized.fps)
|
|
36
|
+
else
|
|
37
|
+
["image/png", Tessel::PNG.encode(Normalizer.terminal_image(normalized))]
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def animation(frames, fps)
|
|
42
|
+
if defined?(Flipbook)
|
|
43
|
+
Tempfile.create(["inlay", ".gif"]) do |file|
|
|
44
|
+
Flipbook.write(file.path, frames, fps: fps)
|
|
45
|
+
["text/html", "<img alt=\"animation\" src=\"data:image/gif;base64,#{Base64.strict_encode64(File.binread(file.path))}\">"]
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
["image/png", Tessel::PNG.encode(frames.first)]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
Inlay::IRubyIntegration.install
|
data/lib/inlay/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inlay
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-09-25 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: tessel
|
|
@@ -77,6 +78,34 @@ dependencies:
|
|
|
77
78
|
- - ">="
|
|
78
79
|
- !ruby/object:Gem::Version
|
|
79
80
|
version: '1.13'
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: iruby
|
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
type: :development
|
|
89
|
+
prerelease: false
|
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
- !ruby/object:Gem::Dependency
|
|
96
|
+
name: flipbook
|
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
80
109
|
- !ruby/object:Gem::Dependency
|
|
81
110
|
name: pry
|
|
82
111
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -105,7 +134,8 @@ dependencies:
|
|
|
105
134
|
- - "~>"
|
|
106
135
|
- !ruby/object:Gem::Version
|
|
107
136
|
version: '3.0'
|
|
108
|
-
description: Render Tessel images
|
|
137
|
+
description: Render Tessel images, graphics buffers, and chart output in IRB, Pry,
|
|
138
|
+
and IRuby.
|
|
109
139
|
email:
|
|
110
140
|
- t.yudai92@gmail.com
|
|
111
141
|
executables: []
|
|
@@ -121,6 +151,7 @@ files:
|
|
|
121
151
|
- lib/inlay/adapters.rb
|
|
122
152
|
- lib/inlay/config.rb
|
|
123
153
|
- lib/inlay/irb.rb
|
|
154
|
+
- lib/inlay/iruby.rb
|
|
124
155
|
- lib/inlay/kernel.rb
|
|
125
156
|
- lib/inlay/normalizer.rb
|
|
126
157
|
- lib/inlay/pry.rb
|
|
@@ -135,6 +166,7 @@ licenses:
|
|
|
135
166
|
metadata:
|
|
136
167
|
homepage_uri: https://github.com/rbgfx/inlay
|
|
137
168
|
source_code_uri: https://github.com/rbgfx/inlay/tree/main
|
|
169
|
+
post_install_message:
|
|
138
170
|
rdoc_options: []
|
|
139
171
|
require_paths:
|
|
140
172
|
- lib
|
|
@@ -149,7 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
181
|
- !ruby/object:Gem::Version
|
|
150
182
|
version: '0'
|
|
151
183
|
requirements: []
|
|
152
|
-
rubygems_version: 4.
|
|
184
|
+
rubygems_version: 3.4.19
|
|
185
|
+
signing_key:
|
|
153
186
|
specification_version: 4
|
|
154
|
-
summary: Display Ruby graphics in terminals and
|
|
187
|
+
summary: Display Ruby graphics in terminals and notebooks
|
|
155
188
|
test_files: []
|