rsyntaxtree 1.9.0 → 1.10.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: ef69a566b76dec78e1e804475c604162173582605c852900b5cd5c5cf3f2e5eb
4
- data.tar.gz: 3ee903c09bab59e55e1dd81544768482ddd53c3f0eaf6081364f4bb0c446cfed
3
+ metadata.gz: 38f3abe8841c2097201c6120f900a0d9eb99fb8bea9c6dc8388ac38a8e0df2c7
4
+ data.tar.gz: d22ebd93a2a2ed135e4afcc21797f4f057a3b5d340fdfd265a7f5490ccc642fb
5
5
  SHA512:
6
- metadata.gz: f9057ca7c228e28351e95fb5b2573818736a738ed5ae2990db33291b884d1aa0d4e8158949b390b84f5151bf0117850521e0b25d1051fd7f5fe080d4559ecdfb
7
- data.tar.gz: dc727f0091f56ced11c29a25739f8ee73fe912fc8673e8c073a4f3fd7a9de37e4344c392f4e7691773c7abcd7c72f71209f991c1d450e9ddd96e230dbebf4461
6
+ metadata.gz: b3c9dc57831246bdd189e92998ba8325606635669e4e63839509d84db3e21911d0eb928f615b2d2d0f5d9ed6e711c2fed3785d3f1453988deef333a5e513ec48
7
+ data.tar.gz: eea07050d7df010b52615c475d4681749420c7b16687169c9e5ae3de5fbc6683daf939b9c17795442ed2589ad08dfddd745ad41b6d169f5238f521eaab638d3b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.0] - 2026-08
4
+
5
+ A transitional release ahead of 2.0, which drops JPG/GIF output and the
6
+ RMagick dependency.
7
+
8
+ ### Deprecated
9
+ - JPG and GIF output: the CLI prints a warning to stderr when either is
10
+ requested, and the documentation marks both as deprecated. JPEG blurs
11
+ line art and GIF has no use case here — use PNG. Both formats are
12
+ removed in 2.0.
13
+
14
+ ### Changed
15
+ - The library no longer loads RMagick at require time. SVG, PNG, PDF,
16
+ TikZ and LSIF work without ImageMagick installed; only a JPG or GIF
17
+ request needs RMagick, and a request without it reports the missing
18
+ dependency as a regular input error instead of a bare `LoadError`.
19
+
20
+ ### Fixed
21
+ - `RSTError` mutated the message it was given, so raising one with a plain
22
+ string literal crashed inside the error class with a `FrozenError`. Every
23
+ file here carries `frozen_string_literal`, which made the working form the
24
+ unobvious one.
25
+
3
26
  ## [1.9.0] - 2026-08
4
27
 
5
28
  ### Added
data/CITATION.cff CHANGED
@@ -11,8 +11,8 @@ repository-code: "https://github.com/yohasebe/rsyntaxtree"
11
11
  # Concept DOI: always resolves to the latest archived version on Zenodo
12
12
  doi: "10.5281/zenodo.21916150"
13
13
  license: MIT
14
- version: 1.8.2
15
- date-released: 2026-08-15
14
+ version: 1.10.0
15
+ date-released: 2026-08-19
16
16
  keywords:
17
17
  - linguistics
18
18
  - syntax tree
data/README.md CHANGED
@@ -66,7 +66,7 @@ Connect nodes with lines or arrows:
66
66
 
67
67
  ### Multiple Output Formats
68
68
 
69
- Generate trees in PNG, SVG, PDF, JPG, GIF, or LSIF (JSON) format.
69
+ Generate trees in PNG, SVG, PDF, or LSIF (JSON) format. (JPG and GIF are deprecated and will be removed in 2.0.)
70
70
 
71
71
  ## Web Interface
72
72
 
@@ -167,7 +167,7 @@ Usage:
167
167
  | Option | Description | Default |
168
168
  |--------|-------------|---------|
169
169
  | `-o, --outdir` | Output directory | `./` |
170
- | `-f, --format` | Output format: png, gif, jpg, pdf, svg, lsif | `png` |
170
+ | `-f, --format` | Output format: png, svg, pdf, lsif, tikz (jpg and gif are deprecated) | `png` |
171
171
  | `-l, --leafstyle` | Leaf style: auto, triangle, bar, nothing | `auto` |
172
172
  | `-n, --fontstyle` | Font style: sans, serif, cjk, mono | `sans` |
173
173
  | `-s, --fontsize` | Font size: 8-26 | `16` |
data/bin/rsyntaxtree CHANGED
@@ -160,6 +160,10 @@ opts.each do |key, value|
160
160
  end
161
161
  end
162
162
 
163
+ if %w[jpg gif].include?(string_opts[:format])
164
+ warn "Warning: #{string_opts[:format].upcase} output is deprecated and will be removed in RSyntaxTree 2.0. Use PNG instead."
165
+ end
166
+
163
167
  data = if ARGV[0] && File.exist?(File.expand_path(ARGV[0]))
164
168
  File.read ARGV[0]
165
169
  elsif ARGV[0]
@@ -7,7 +7,6 @@
7
7
  # Image utility functions to inspect text font metrics
8
8
  # Copyright (c) 2007-2026 Yoichiro Hasebe <yohasebe@gmail.com>
9
9
 
10
- require 'rmagick'
11
10
  require 'pango'
12
11
 
13
12
  # Font family lists shared by the SVG output and the Pango-based text
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSyntaxTree
4
- VERSION = "1.9.0"
4
+ VERSION = "1.10.0"
5
5
  end
data/lib/rsyntaxtree.rb CHANGED
@@ -53,8 +53,10 @@ DEFAULT_OPTS = {
53
53
 
54
54
  class RSTError < StandardError
55
55
  def initialize(msg = "Error: something unexpected occurred")
56
- msg.gsub!(WHITESPACE_BLOCK, "<>")
57
- super msg
56
+ # Non-destructive: every file here carries frozen_string_literal, so
57
+ # mutating the message in place turned a raise with a plain literal into
58
+ # a FrozenError from inside the error class itself.
59
+ super(msg.gsub(WHITESPACE_BLOCK, "<>"))
58
60
  end
59
61
  end
60
62
 
@@ -69,7 +71,6 @@ require_relative 'rsyntaxtree/string_parser'
69
71
 
70
72
  require 'cgi'
71
73
  require 'rsvg2'
72
- require 'rmagick'
73
74
 
74
75
  module RSyntaxTree
75
76
  class RSGenerator
@@ -243,24 +244,41 @@ module RSyntaxTree
243
244
  graph.svg_data
244
245
  end
245
246
 
247
+ # JPG and GIF output converts the PNG through RMagick. The require is
248
+ # lazy: both formats are deprecated and will be removed in 2.0, and the
249
+ # library must load without RMagick for every other format. A missing
250
+ # RMagick is reported as an input-level error, not a bare LoadError.
251
+ def with_rmagick
252
+ require 'rmagick'
253
+ yield
254
+ rescue LoadError
255
+ raise RSTError, +"Error: JPG/GIF output requires ImageMagick and the rmagick gem, " \
256
+ "which is not installed. Use PNG instead — JPG and GIF support " \
257
+ "is deprecated and will be removed in 2.0."
258
+ end
259
+
246
260
  def draw_jpg
247
- png_data = draw_png
248
- images = Magick::Image.from_blob(png_data)
249
- image = images.first
250
- image.format = 'JPEG'
251
- blob = image.to_blob
252
- images.each(&:destroy!)
253
- blob
261
+ with_rmagick do
262
+ png_data = draw_png
263
+ images = Magick::Image.from_blob(png_data)
264
+ image = images.first
265
+ image.format = 'JPEG'
266
+ blob = image.to_blob
267
+ images.each(&:destroy!)
268
+ blob
269
+ end
254
270
  end
255
271
 
256
272
  def draw_gif
257
- png_data = draw_png
258
- images = Magick::Image.from_blob(png_data)
259
- image = images.first
260
- image.format = 'GIF'
261
- blob = image.to_blob
262
- images.each(&:destroy!)
263
- blob
273
+ with_rmagick do
274
+ png_data = draw_png
275
+ images = Magick::Image.from_blob(png_data)
276
+ image = images.first
277
+ image.format = 'GIF'
278
+ blob = image.to_blob
279
+ images.each(&:destroy!)
280
+ blob
281
+ end
264
282
  end
265
283
 
266
284
  def draw_lsif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe