rsyntaxtree 1.3.1 → 1.3.2
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/README.md +21 -2
- data/Rakefile +42 -8
- data/docs/_examples/016.md +1 -1
- data/docs/_examples/053.md +5 -12
- data/lib/rsyntaxtree/svg_graph.rb +1 -1
- data/lib/rsyntaxtree/utils.rb +3 -1
- data/lib/rsyntaxtree/version.rb +1 -1
- data/lib/rsyntaxtree.rb +15 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d293f1051661467a4b39531bb7868073256fc6a40e60affa4dee8daa45187f
|
4
|
+
data.tar.gz: 79ececb16b1b9394f5027ccec1f4dcba9d4cd541fe8829276eb9c18d5a377c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd4e3ceb0efc58a58b87b4273525aa9456e6050c5b7dfe41bcc0b790018240d2e1c1a0f34a42c45f78faf6913441f41a57aef30f60daab8ce7cfc24182a8b3ce
|
7
|
+
data.tar.gz: 76b44cc2c343a43714ab9cfe52c3a04c524fc81296e901796e0b2aa7b8205b73de4b2a88001d269a5fa834a9267e62e3d2a034b2fbde7d7ca471be90d41524ae
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ Documentation is currently available in the following languages:
|
|
10
10
|
- [日本語ドキュメント](https://yohasebe.github.io/rsyntaxtree/documentation_ja)
|
11
11
|
|
12
12
|
- [Example Gallery](https://yohasebe.github.io/rsyntaxtree/examples)
|
13
|
+
|
13
14
|
## Web Interface
|
14
15
|
|
15
16
|
<img src='https://github.com/yohasebe/rsyntaxtree/blob/master/img/rsyntaxtree-web-screenshot.png?raw=true' width='700px'/>
|
@@ -56,9 +57,27 @@ See [RSyntaxTree Example Gallery](https://yohasebe.github.io/rsyntaxtree/example
|
|
56
57
|
|
57
58
|
## Installation
|
58
59
|
|
59
|
-
|
60
|
+
```
|
61
|
+
gem install rsyntaxtree
|
62
|
+
```
|
63
|
+
|
64
|
+
### macOS Installation Notice
|
65
|
+
|
66
|
+
**Important for macOS users:** If you are installing the RSyntaxTree gem directly on macOS, you might encounter build errors for some native extensions (specifically for `gobject-introspection`, `cairo-gobject`, and `gio2`). These errors occur due to macOS linker requirements for dynamic symbol resolution. To work around this issue, please run the following commands in your terminal **before** installing RSyntaxTree:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
gem install gobject-introspection -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
|
70
|
+
gem install cairo-gobject -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
|
71
|
+
gem install gio2 -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
|
72
|
+
```
|
73
|
+
|
74
|
+
After executing these commands, you can install RSyntaxTree normally:
|
75
|
+
|
76
|
+
```bash
|
77
|
+
gem install rsyntaxtree
|
78
|
+
```
|
60
79
|
|
61
|
-
|
80
|
+
Alternatively, if you prefer a smoother installation process, consider using the [Docker image](https://hub.docker.com/r/yohasebe/rsyntaxtree) or the [web interface](https://yohasebe.com/rsyntaxtree).
|
62
81
|
|
63
82
|
## Usage
|
64
83
|
|
data/Rakefile
CHANGED
@@ -9,24 +9,58 @@ require_relative 'lib/rsyntaxtree/utils'
|
|
9
9
|
# task default: "test"
|
10
10
|
|
11
11
|
Rake::TestTask.new do |task|
|
12
|
-
|
13
|
-
|
12
|
+
task.pattern = "test/*_test.rb"
|
13
|
+
task.warning = false
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "Generate SVG and PNG example images locally"
|
17
17
|
task :generate do
|
18
|
-
|
18
|
+
require_relative "dev/generate_examples"
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Docker image Build"
|
22
22
|
task :docker_build do
|
23
|
-
|
23
|
+
`docker build ./ -t rsyntaxtree_devel`
|
24
24
|
end
|
25
25
|
|
26
26
|
desc "Generate SVG and PNG example images using Docker image"
|
27
27
|
task :docker_generate do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
docpath = File.expand_path(File.join(__dir__, "docs"))
|
29
|
+
`docker build ./ -t rsyntaxtree_devel`
|
30
|
+
`docker run --rm -v #{docpath}:/rsyntaxtree/hostdocs rsyntaxtree_devel ruby /rsyntaxtree/dev/generate_examples.rb /rsyntaxtree/hostdocs`
|
31
|
+
`cat #{docpath}/generate_examples.log`
|
32
|
+
end
|
33
|
+
|
34
|
+
# Add new task for macOS environment configuration
|
35
|
+
|
36
|
+
desc "Configure Bundler build options for macOS"
|
37
|
+
task :setup_macos do
|
38
|
+
require "rbconfig"
|
39
|
+
host_os = RbConfig::CONFIG['host_os']
|
40
|
+
|
41
|
+
# Check if the host OS is macOS (Darwin)
|
42
|
+
|
43
|
+
if host_os =~ /darwin/
|
44
|
+
puts "macOS detected. Setting up build options for native extensions..."
|
45
|
+
|
46
|
+
gems_with_options = {
|
47
|
+
"gobject-introspection" => '--with-ldflags=-Wl,-undefined,dynamic_lookup',
|
48
|
+
"cairo-gobject" => '--with-ldflags=-Wl,-undefined,dynamic_lookup',
|
49
|
+
"gio2" => '--with-ldflags=-Wl,-undefined,dynamic_lookup'
|
50
|
+
}
|
51
|
+
|
52
|
+
# Configure each gem with the necessary ldflags option using Bundler config command
|
53
|
+
|
54
|
+
gems_with_options.each do |gem_name, flags|
|
55
|
+
command = "bundle config build.#{gem_name} \"#{flags}\""
|
56
|
+
puts "Executing: #{command}"
|
57
|
+
unless system(command)
|
58
|
+
abort("Failed to execute command: #{command}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
puts "macOS setup complete. Please run 'bundle install' after this."
|
63
|
+
else
|
64
|
+
puts "This setup task is intended for macOS environments. Current OS: #{host_os}"
|
65
|
+
end
|
32
66
|
end
|
data/docs/_examples/016.md
CHANGED
data/docs/_examples/053.md
CHANGED
@@ -13,29 +13,22 @@ font: "Noto Serif"
|
|
13
13
|
---
|
14
14
|
```
|
15
15
|
[expr
|
16
|
-
[id x
|
17
|
-
|
18
|
-
]
|
16
|
+
[id x]
|
19
17
|
[suffix
|
20
18
|
\[
|
21
|
-
[id 2
|
22
|
-
|
23
|
-
]
|
19
|
+
[id 2 ]
|
24
20
|
\]
|
25
21
|
[suffix
|
26
22
|
\[
|
27
|
-
[id 3
|
28
|
-
|
29
|
-
]
|
23
|
+
[id 3 ]
|
30
24
|
\]
|
31
25
|
[suffix
|
32
26
|
\[
|
33
|
-
[id 4
|
34
|
-
|
35
|
-
]
|
27
|
+
[id 4 ]
|
36
28
|
\]
|
37
29
|
]
|
38
30
|
]
|
39
31
|
]
|
40
32
|
]
|
33
|
+
|
41
34
|
```
|
data/lib/rsyntaxtree/utils.rb
CHANGED
@@ -53,7 +53,9 @@ module FontMetrics
|
|
53
53
|
gca.interline_spacing = 0
|
54
54
|
gca.interword_spacing = 0
|
55
55
|
end
|
56
|
-
gc.get_multiline_type_metrics(background, text)
|
56
|
+
metrics = gc.get_multiline_type_metrics(background, text)
|
57
|
+
background.destroy! # Explicitly destroy the image
|
58
|
+
metrics
|
57
59
|
end
|
58
60
|
module_function :get_metrics
|
59
61
|
end
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/lib/rsyntaxtree.rb
CHANGED
@@ -160,11 +160,12 @@ module RSyntaxTree
|
|
160
160
|
context.render_rsvg_handle(rsvg)
|
161
161
|
b = StringIO.new
|
162
162
|
surface.write_to_png(b)
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
result = binary ? b : b.string
|
164
|
+
# Clean up resources
|
165
|
+
b.close unless binary
|
166
|
+
surface.finish
|
167
|
+
context.destroy
|
168
|
+
result
|
168
169
|
rescue Cairo::InvalidSize
|
169
170
|
raise RSTError, +"Error: the result syntree is too big"
|
170
171
|
end
|
@@ -178,11 +179,11 @@ module RSyntaxTree
|
|
178
179
|
context = Cairo::Context.new(surface)
|
179
180
|
context.render_rsvg_handle(rsvg)
|
180
181
|
surface.finish
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
182
|
+
result = binary ? b : b.string
|
183
|
+
# Clean up resources
|
184
|
+
b.close unless binary
|
185
|
+
context.destroy
|
186
|
+
result
|
186
187
|
rescue Cairo::InvalidSize
|
187
188
|
raise RSTError, +"Error: the result syntree is too big"
|
188
189
|
end
|
@@ -200,10 +201,12 @@ module RSyntaxTree
|
|
200
201
|
image, _data = Magick::Image.from_blob(svg) do |im|
|
201
202
|
im.format = 'svg'
|
202
203
|
end
|
203
|
-
image.to_blob do |im|
|
204
|
+
blob = image.to_blob do |im|
|
204
205
|
im.format = @params[:format].upcase
|
205
206
|
end
|
206
|
-
|
207
|
+
# Clean up resources
|
208
|
+
image.destroy!
|
209
|
+
blob
|
207
210
|
end
|
208
211
|
end
|
209
212
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsyntaxtree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optimist
|
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
358
358
|
- !ruby/object:Gem::Version
|
359
359
|
version: '0'
|
360
360
|
requirements: []
|
361
|
-
rubygems_version: 3.
|
361
|
+
rubygems_version: 3.4.13
|
362
362
|
signing_key:
|
363
363
|
specification_version: 4
|
364
364
|
summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
|