brst-binding-ruby 0.1.0 → 0.1.1
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 +16 -0
- data/README.md +3 -3
- data/lib/brst/binding/ruby/library.rb +26 -0
- data/lib/brst/binding/ruby/types.rb +12 -17
- data/lib/brst/binding/ruby/version.rb +1 -1
- data/lib/brst/binding/ruby.rb +13 -4
- 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: 1ffc6380bc81c6819bac392ad7dd2c03d1a93f518a608d4f954a698b2d96cd83
|
|
4
|
+
data.tar.gz: 2ee50c6dd70da93da621bb859cbceaa4a87a2e1b41db7666b1fcc670462f7c36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45c365a86d18c3e229fe4344d0574760ccb68cb97b1ca2ae4309b566da65ff22c5f84f6a185258b24da7b16ff011eaef6dbe313248b796003fec1bda6422b873
|
|
7
|
+
data.tar.gz: b0eb2e4627c7f32df2694ddf49dad3ac1e695cdedf832debddddf031e9ce9f3cefdb4db4f9089e6bfd3c8356319bc5b054e6deefff48e9042c86f0e68ebaaac3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-11-21
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Loading the gem under `ruby -w` no longer prints "mismatched indentations"
|
|
7
|
+
warnings from the generated `types.rb`, which also registered five typedefs
|
|
8
|
+
twice.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- When the libBeresta shared library cannot be loaded, the `LoadError` now
|
|
12
|
+
says how to fix it (install libBeresta or set `BRST_BINDING_RUBY_LIB`)
|
|
13
|
+
ahead of the loader's own message.
|
|
14
|
+
- The generator deletes generated modules whose `.lsp` file is gone, and the
|
|
15
|
+
CI drift guard also fails on added or removed modules.
|
|
16
|
+
- CI covers Ruby 4.0.
|
|
17
|
+
|
|
3
18
|
## [0.1.0] - 2026-11-21
|
|
4
19
|
|
|
5
20
|
Initial experimental release.
|
|
@@ -20,4 +35,5 @@ Initial experimental release.
|
|
|
20
35
|
- libBeresta is not bundled. A `libbrst` shared library must be built and
|
|
21
36
|
installed separately (see README).
|
|
22
37
|
|
|
38
|
+
[0.1.1]: https://github.com/libBeresta/brst-binding-ruby/releases/tag/v0.1.1
|
|
23
39
|
[0.1.0]: https://github.com/libBeresta/brst-binding-ruby/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -10,11 +10,11 @@ language bindings. Bindings are auto-generated from libBeresta's canonical
|
|
|
10
10
|
S-expression definitions in [`gen/data/*.lsp`][gen-data], so they stay faithful
|
|
11
11
|
to the upstream API.
|
|
12
12
|
|
|
13
|
-
## Status: v0.1.
|
|
13
|
+
## Status: v0.1.x — experimental
|
|
14
14
|
|
|
15
15
|
- Auto-generated low-level FFI surface from `gen/data/*.lsp`. This release is
|
|
16
16
|
generated from libBeresta 1.0.1.
|
|
17
|
-
- Tested in CI on macOS 15 and Ubuntu 24.04 with Ruby 3.2 –
|
|
17
|
+
- Tested in CI on macOS 15 and Ubuntu 24.04 with Ruby 3.2 – 4.0.
|
|
18
18
|
- An idiomatic, higher-level Ruby API is **not** part of this gem; that is
|
|
19
19
|
planned as a separate gem on top of these low-level bindings.
|
|
20
20
|
- libBeresta itself is **not** bundled. The gem loads a `libbrst` shared
|
|
@@ -160,7 +160,7 @@ workflow refuses to publish when the tag, `VERSION` and `CHANGELOG.md` disagree.
|
|
|
160
160
|
- [libHaru][libHaru] — original PDF C library this work ultimately descends
|
|
161
161
|
from. Original copyright belongs to Takeshi Kanno and contributors.
|
|
162
162
|
- Russian-language docs in the upstream `.lsp` data are preserved verbatim in
|
|
163
|
-
the parsed tree but not surfaced in v0.1.
|
|
163
|
+
the parsed tree but not surfaced in the v0.1.x bindings.
|
|
164
164
|
|
|
165
165
|
## License
|
|
166
166
|
|
|
@@ -40,6 +40,32 @@ module Brst
|
|
|
40
40
|
# Fall back to library names; FFI will search system paths.
|
|
41
41
|
%w[brst libbrst]
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
INSTALL_URL = "https://github.com/libBeresta/brst-binding-ruby#install"
|
|
45
|
+
|
|
46
|
+
# Message for the LoadError raised when FFI cannot open libbrst. FFI's
|
|
47
|
+
# own message lists every path it tried but not what to do about it,
|
|
48
|
+
# so lead with that and keep the original text at the end.
|
|
49
|
+
def load_error_message(original)
|
|
50
|
+
override = ENV["BRST_BINDING_RUBY_LIB"]
|
|
51
|
+
advice =
|
|
52
|
+
if override && !override.empty?
|
|
53
|
+
"BRST_BINDING_RUBY_LIB is set to #{override.inspect}; check that it " \
|
|
54
|
+
"points to libbrst.dylib / libbrst.so."
|
|
55
|
+
else
|
|
56
|
+
"This gem does not bundle libBeresta. Install libBeresta where the " \
|
|
57
|
+
"system loader can find it, or set BRST_BINDING_RUBY_LIB to the path " \
|
|
58
|
+
"of libbrst.dylib / libbrst.so."
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
[
|
|
62
|
+
"brst-binding-ruby could not load the libBeresta shared library (libbrst).",
|
|
63
|
+
advice,
|
|
64
|
+
"See #{INSTALL_URL} for build steps.",
|
|
65
|
+
"",
|
|
66
|
+
"Original error: #{original}"
|
|
67
|
+
].join("\n")
|
|
68
|
+
end
|
|
43
69
|
end
|
|
44
70
|
end
|
|
45
71
|
end
|
|
@@ -56,15 +56,10 @@ module Brst
|
|
|
56
56
|
mod.typedef :pointer, :Error_Handler
|
|
57
57
|
mod.typedef :pointer, :Alloc_Func
|
|
58
58
|
mod.typedef :pointer, :Free_Func
|
|
59
|
-
|
|
60
|
-
mod.typedef :pointer, :DASH_PATTERN
|
|
61
|
-
mod.typedef :pointer, :Error_Handler
|
|
62
|
-
mod.typedef :pointer, :Alloc_Func
|
|
63
|
-
mod.typedef :pointer, :Free_Func
|
|
64
|
-
end
|
|
59
|
+
end
|
|
65
60
|
|
|
66
|
-
# ---- opaque pointers ----
|
|
67
|
-
def apply_pointers(mod)
|
|
61
|
+
# ---- opaque pointers ----
|
|
62
|
+
def apply_pointers(mod)
|
|
68
63
|
mod.typedef :pointer, :Array
|
|
69
64
|
mod.typedef :pointer, :Date
|
|
70
65
|
mod.typedef :pointer, :Dict
|
|
@@ -76,10 +71,10 @@ def apply_pointers(mod)
|
|
|
76
71
|
mod.typedef :pointer, :MMgr
|
|
77
72
|
mod.typedef :pointer, :Stream
|
|
78
73
|
mod.typedef :pointer, :Xref
|
|
79
|
-
end
|
|
74
|
+
end
|
|
80
75
|
|
|
81
|
-
# ---- enums (improvement #2: each enum acts as an :int-backed typedef) ----
|
|
82
|
-
def apply_enums(mod)
|
|
76
|
+
# ---- enums (improvement #2: each enum acts as an :int-backed typedef) ----
|
|
77
|
+
def apply_enums(mod)
|
|
83
78
|
mod.enum :AnnotType, [:ANNOT_TEXT, :ANNOT_LINK, :ANNOT_FREE_TEXT, :ANNOT_LINE, :ANNOT_SQUARE, :ANNOT_CIRCLE, :ANNOT_POLYGON, :ANNOT_POLYLINE, :ANNOT_HIGHLIGHT, :ANNOT_UNDERLINE, :ANNOT_SQUIGGLY, :ANNOT_STRIKEOUT, :ANNOT_STAMP, :ANNOT_CARET, :ANNOT_INK, :ANNOT_POPUP, :ANNOT_FILE_ATTACHMENT, :ANNOT_SOUND, :ANNOT_MOVIE, :ANNOT_WIDGET, :ANNOT_SCREEN, :ANNOT_PRINTER_MARK, :ANNOT_TRAPNET, :ANNOT_WATERMARK, :ANNOT_3D, :ANNOT_REDACT, :ANNOT_RICH_MEDIA, :ANNOT_PROJECTION]
|
|
84
79
|
mod.enum :AnnotFlags, [:ANNOT_FLAG_INVISIBLE, :ANNOT_FLAG_HIDDEN, :ANNOT_FLAG_PRINT, :ANNOT_FLAG_NOZOOM, :ANNOT_FLAG_NOROTATE, :ANNOT_FLAG_NOVIEW, :ANNOT_FLAG_READONLY, :ANNOT_FLAG_LOCKED, :ANNOT_FLAG_TOGGLE_NOVIEW, :ANNOT_FLAG_LOCKED_CONTENT]
|
|
85
80
|
mod.enum :AnnotHighlightMode, [:ANNOT_HIGHLIGHT_MODE_NONE, :ANNOT_HIGHLIGHT_MODE_INVERT, :ANNOT_HIGHLIGHT_MODE_OUTLINE, :ANNOT_HIGHLIGHT_MODE_PUSH]
|
|
@@ -112,10 +107,10 @@ def apply_enums(mod)
|
|
|
112
107
|
mod.enum :TextRenderingMode, [:TEXT_RENDERING_MODE_FILL, :TEXT_RENDERING_MODE_STROKE, :TEXT_RENDERING_MODE_FILL_THEN_STROKE, :TEXT_RENDERING_MODE_INVISIBLE, :TEXT_RENDERING_MODE_FILL_CLIPPING, :TEXT_RENDERING_MODE_STROKE_CLIPPING, :TEXT_RENDERING_MODE_FILL_STROKE_CLIPPING, :TEXT_RENDERING_MODE_CLIPPING]
|
|
113
108
|
mod.enum :TextAlignment, [:TEXT_ALIGN_LEFT, :TEXT_ALIGN_RIGHT, :TEXT_ALIGN_CENTER, :TEXT_ALIGN_JUSTIFY]
|
|
114
109
|
mod.enum :WritingMode, [:WRITING_MODE_HORIZONTAL, :WRITING_MODE_VERTICAL]
|
|
115
|
-
end
|
|
110
|
+
end
|
|
116
111
|
|
|
117
|
-
# ---- structs (improvement #3: by_value alias) ----
|
|
118
|
-
def apply_structs(mod)
|
|
112
|
+
# ---- structs (improvement #3: by_value alias) ----
|
|
113
|
+
def apply_structs(mod)
|
|
119
114
|
unless mod.const_defined?(:RGBColorStruct, false)
|
|
120
115
|
klass = Class.new(FFI::Struct) do
|
|
121
116
|
layout :r, :float,
|
|
@@ -163,10 +158,10 @@ def apply_structs(mod)
|
|
|
163
158
|
mod.const_set(:TextWidthStruct, klass)
|
|
164
159
|
end
|
|
165
160
|
mod.typedef mod.const_get(:TextWidthStruct).by_value, :TextWidth
|
|
166
|
-
end
|
|
161
|
+
end
|
|
167
162
|
|
|
168
|
-
# ---- definitions (typedef aliases) ----
|
|
169
|
-
def apply_definitions(mod)
|
|
163
|
+
# ---- definitions (typedef aliases) ----
|
|
164
|
+
def apply_definitions(mod)
|
|
170
165
|
mod.typedef :Dict, :Annotation
|
|
171
166
|
mod.typedef :Array, :Destination
|
|
172
167
|
mod.typedef :Dict, :EmbeddedFile
|
data/lib/brst/binding/ruby.rb
CHANGED
|
@@ -23,8 +23,17 @@ end
|
|
|
23
23
|
# Auto-load every generated FFI module. Order is irrelevant because every type
|
|
24
24
|
# (pointer/enum/struct/definition) is centralized in `types.rb`, which has
|
|
25
25
|
# already been loaded above.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
begin
|
|
27
|
+
Dir[File.expand_path("ruby/*.rb", __dir__)].sort.each do |f|
|
|
28
|
+
base = File.basename(f, ".rb")
|
|
29
|
+
next if %w[version library types].include?(base)
|
|
30
|
+
require f
|
|
31
|
+
end
|
|
32
|
+
rescue LoadError => e
|
|
33
|
+
# A LoadError that carries a path comes from `require` itself. One without
|
|
34
|
+
# a path is FFI failing to open libbrst: say how to fix that instead of
|
|
35
|
+
# only listing the paths the loader tried.
|
|
36
|
+
raise if e.path
|
|
37
|
+
|
|
38
|
+
raise LoadError, Brst::Binding::Ruby::Library.load_error_message(e.message), e.backtrace
|
|
30
39
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: brst-binding-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kenta Ishizaki
|
|
@@ -54,7 +54,7 @@ dependencies:
|
|
|
54
54
|
description: |
|
|
55
55
|
Experimental Ruby FFI bindings for libBeresta, a free, cross-platform PDF
|
|
56
56
|
generation C library forked from libHaru. Bindings are auto-generated from
|
|
57
|
-
libBeresta's canonical S-expression definitions (gen/data/*.lsp). v0.1.
|
|
57
|
+
libBeresta's canonical S-expression definitions (gen/data/*.lsp). v0.1.x
|
|
58
58
|
exposes a faithful low-level surface; an idiomatic high-level API is planned
|
|
59
59
|
as a separate gem. Tested on macOS and Linux. libBeresta itself is not
|
|
60
60
|
bundled and must be installed separately. Part of the libBeresta org's
|
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
134
|
version: '0'
|
|
135
135
|
requirements: []
|
|
136
|
-
rubygems_version:
|
|
136
|
+
rubygems_version: 3.6.9
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Low-level Ruby FFI bindings for libBeresta (PDF generation)
|
|
139
139
|
test_files: []
|