image_util 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 893e648382567326c70c82a4b3e3b6580889229c9d56c7a20ec4d182b45332b4
4
- data.tar.gz: 70fd8a63b0551a0aaca12dae391c076fb01621443ec1ae5e5f92c680655277f2
3
+ metadata.gz: 2665eb7733f8fa7dc6e091d09a8ddc3315d0461395fd15aa1eb2c12ca9de9df6
4
+ data.tar.gz: bc5ced5903fa35dfbe03a05ae6aff8e797ca3c5d39407881c288168f5cbe51d1
5
5
  SHA512:
6
- metadata.gz: 89a0a3bf90307337674acae7e1315505bc4a8363e58c041388dc6e6beeaab3f03e4534d2ff41e9a97c23f5775e62db6ebe5493658ac2b81e06f3a650a197d28a
7
- data.tar.gz: 6b425b6539c389431e78cdc98744a82888a3f55e0fdeed64062bf69a3e0448fec84e83264b3dd1380133a5adafa87e5751dd36595c7c3dc413e4ead3173d21ae
6
+ metadata.gz: caf2f99b10ff415168c0ac9defc7966d5e374d007a5859eab7580ae0865f6a6bc5203d116e094ca77dbbc26fcc69faaead7869b092297bc4a42749ae2a2f95cd
7
+ data.tar.gz: 66823c89ef52e3bb5c0927529c4dc99877253047a7659450da0d2a7bd7790944f836656b10c07bbbcb2eae40cb95ad95c694f5d69c2338a526fae36bfddedf21
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.5.0] - 2025-10-05
2
+ - Add `ImageUtil::Inspectable` interface for other gems to use
3
+
1
4
  ## [0.4.0] - 2025-10-04
2
5
  - BREAKING: Float color components now share the 0..255 range with integers instead of being scaled from 0..1.
3
6
  - Add `define_mutable_version` helper to create bang versions from immutable methods
@@ -4,6 +4,8 @@ module ImageUtil
4
4
  class Image
5
5
  autoload :Buffer, "image_util/image/buffer"
6
6
 
7
+ include ImageUtil::Inspectable
8
+
7
9
  Util.irb_fixup
8
10
 
9
11
  ALL = nil..nil
@@ -211,14 +213,8 @@ module ImageUtil
211
213
  Codec.encode(:sixel, self)
212
214
  end
213
215
 
214
- def pretty_print(p)
215
- if (image = Terminal.output_image($stdin, $stdout, self))
216
- p.flush
217
- p.output << image
218
- p.text("", 0)
219
- else
220
- super
221
- end
216
+ def inspect_image
217
+ self
222
218
  end
223
219
 
224
220
  def pixel_count(locations) = location_expand(locations).first.reduce(:*)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ImageUtil
4
+ module Inspectable
5
+ def pretty_print(pp)
6
+ image = inspect_image
7
+ return super unless image.is_a?(ImageUtil::Image)
8
+
9
+ rendered = ImageUtil::Terminal.output_image($stdin, $stdout, image)
10
+ if rendered
11
+ pp.flush
12
+ pp.output << rendered
13
+ pp.text("", 0)
14
+ else
15
+ super
16
+ end
17
+ rescue LoadError
18
+ super
19
+ end
20
+
21
+ def inspect_image
22
+ raise NotImplementedError, "including classes must implement #inspect_image"
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImageUtil
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/image_util.rb CHANGED
@@ -11,6 +11,7 @@ module ImageUtil
11
11
  autoload :Image, "image_util/image"
12
12
  autoload :Util, "image_util/util"
13
13
  autoload :Codec, "image_util/codec"
14
+ autoload :Inspectable, "image_util/inspectable"
14
15
  autoload :Magic, "image_util/magic"
15
16
  autoload :Extension, "image_util/extension"
16
17
  autoload :Filter, "image_util/filter"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmdne
@@ -134,6 +134,7 @@ files:
134
134
  - lib/image_util/generator/example/rose.png
135
135
  - lib/image_util/image.rb
136
136
  - lib/image_util/image/buffer.rb
137
+ - lib/image_util/inspectable.rb
137
138
  - lib/image_util/magic.rb
138
139
  - lib/image_util/statistic.rb
139
140
  - lib/image_util/statistic/colors.rb