kreuzberg 4.5.2-aarch64-linux → 4.6.0-aarch64-linux

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.
data/Gemfile.lock DELETED
@@ -1,274 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- kreuzberg (4.5.2)
5
- rb_sys (~> 0.9.119)
6
- sorbet-runtime (~> 0.5)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (8.1.2)
12
- base64
13
- bigdecimal
14
- concurrent-ruby (~> 1.0, >= 1.3.1)
15
- connection_pool (>= 2.2.5)
16
- drb
17
- i18n (>= 1.6, < 2)
18
- json
19
- logger (>= 1.4.2)
20
- minitest (>= 5.1)
21
- securerandom (>= 0.3)
22
- tzinfo (~> 2.0, >= 2.0.5)
23
- uri (>= 0.13.1)
24
- addressable (2.8.9)
25
- public_suffix (>= 2.0.2, < 8.0)
26
- ast (2.4.3)
27
- base64 (0.3.0)
28
- bigdecimal (4.0.1)
29
- byebug (13.0.0)
30
- reline (>= 0.6.0)
31
- coderay (1.1.3)
32
- concurrent-ruby (1.3.6)
33
- connection_pool (3.0.2)
34
- csv (3.3.5)
35
- diff-lcs (1.6.2)
36
- drb (2.2.3)
37
- ffi (1.17.3)
38
- ffi (1.17.3-aarch64-linux-gnu)
39
- ffi (1.17.3-aarch64-linux-musl)
40
- ffi (1.17.3-arm-linux-gnu)
41
- ffi (1.17.3-arm-linux-musl)
42
- ffi (1.17.3-arm64-darwin)
43
- ffi (1.17.3-x86-linux-gnu)
44
- ffi (1.17.3-x86-linux-musl)
45
- ffi (1.17.3-x86_64-darwin)
46
- ffi (1.17.3-x86_64-linux-gnu)
47
- ffi (1.17.3-x86_64-linux-musl)
48
- fileutils (1.8.0)
49
- i18n (1.14.8)
50
- concurrent-ruby (~> 1.0)
51
- io-console (0.8.2)
52
- json (2.19.2)
53
- json-schema (6.2.0)
54
- addressable (~> 2.8)
55
- bigdecimal (>= 3.1, < 5)
56
- language_server-protocol (3.17.0.5)
57
- lint_roller (1.1.0)
58
- listen (3.10.0)
59
- logger
60
- rb-fsevent (~> 0.10, >= 0.10.3)
61
- rb-inotify (~> 0.9, >= 0.9.10)
62
- logger (1.7.0)
63
- mcp (0.9.0)
64
- json-schema (>= 4.1)
65
- method_source (1.1.0)
66
- minitest (6.0.2)
67
- drb (~> 2.0)
68
- prism (~> 1.5)
69
- mutex_m (0.3.0)
70
- parallel (1.27.0)
71
- parser (3.3.10.2)
72
- ast (~> 2.4.1)
73
- racc
74
- prism (1.9.0)
75
- pry (0.16.0)
76
- coderay (~> 1.1)
77
- method_source (~> 1.0)
78
- reline (>= 0.6.0)
79
- pry-byebug (3.12.0)
80
- byebug (~> 13.0)
81
- pry (>= 0.13, < 0.17)
82
- public_suffix (7.0.5)
83
- racc (1.8.1)
84
- rainbow (3.1.1)
85
- rake (13.3.1)
86
- rake-compiler (1.3.1)
87
- rake
88
- rake-compiler-dock (1.11.0)
89
- rb-fsevent (0.11.2)
90
- rb-inotify (0.11.1)
91
- ffi (~> 1.0)
92
- rb_sys (0.9.124)
93
- rake-compiler-dock (= 1.11.0)
94
- rbs (3.10.3)
95
- logger
96
- tsort
97
- regexp_parser (2.11.3)
98
- reline (0.6.3)
99
- io-console (~> 0.5)
100
- rspec (3.13.2)
101
- rspec-core (~> 3.13.0)
102
- rspec-expectations (~> 3.13.0)
103
- rspec-mocks (~> 3.13.0)
104
- rspec-core (3.13.6)
105
- rspec-support (~> 3.13.0)
106
- rspec-expectations (3.13.5)
107
- diff-lcs (>= 1.2.0, < 2.0)
108
- rspec-support (~> 3.13.0)
109
- rspec-mocks (3.13.8)
110
- diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.13.0)
112
- rspec-support (3.13.7)
113
- rubocop (1.85.1)
114
- json (~> 2.3)
115
- language_server-protocol (~> 3.17.0.2)
116
- lint_roller (~> 1.1.0)
117
- mcp (~> 0.6)
118
- parallel (~> 1.10)
119
- parser (>= 3.3.0.2)
120
- rainbow (>= 2.2.2, < 4.0)
121
- regexp_parser (>= 2.9.3, < 3.0)
122
- rubocop-ast (>= 1.49.0, < 2.0)
123
- ruby-progressbar (~> 1.7)
124
- unicode-display_width (>= 2.4.0, < 4.0)
125
- rubocop-ast (1.49.1)
126
- parser (>= 3.3.7.2)
127
- prism (~> 1.7)
128
- rubocop-performance (1.26.1)
129
- lint_roller (~> 1.1)
130
- rubocop (>= 1.75.0, < 2.0)
131
- rubocop-ast (>= 1.47.1, < 2.0)
132
- rubocop-rspec (3.9.0)
133
- lint_roller (~> 1.1)
134
- rubocop (~> 1.81)
135
- ruby-progressbar (1.13.0)
136
- securerandom (0.4.1)
137
- sorbet-runtime (0.6.13055)
138
- steep (1.10.0)
139
- activesupport (>= 5.1)
140
- concurrent-ruby (>= 1.1.10)
141
- csv (>= 3.0.9)
142
- fileutils (>= 1.1.0)
143
- json (>= 2.1.0)
144
- language_server-protocol (>= 3.17.0.4, < 4.0)
145
- listen (~> 3.0)
146
- logger (>= 1.3.0)
147
- mutex_m (>= 0.3.0)
148
- parser (>= 3.1)
149
- rainbow (>= 2.2.2, < 4.0)
150
- rbs (~> 3.9)
151
- securerandom (>= 0.1)
152
- strscan (>= 1.0.0)
153
- terminal-table (>= 2, < 5)
154
- uri (>= 0.12.0)
155
- strscan (3.1.7)
156
- terminal-table (4.0.0)
157
- unicode-display_width (>= 1.1.1, < 4)
158
- tsort (0.2.0)
159
- tzinfo (2.0.6)
160
- concurrent-ruby (~> 1.0)
161
- unicode-display_width (3.2.0)
162
- unicode-emoji (~> 4.1)
163
- unicode-emoji (4.2.0)
164
- uri (1.1.1)
165
- yard (0.9.38)
166
-
167
- PLATFORMS
168
- aarch64-linux-gnu
169
- aarch64-linux-musl
170
- arm-linux-gnu
171
- arm-linux-musl
172
- arm64-darwin
173
- ruby
174
- x86-linux-gnu
175
- x86-linux-musl
176
- x86_64-darwin
177
- x86_64-linux
178
- x86_64-linux-gnu
179
- x86_64-linux-musl
180
-
181
- DEPENDENCIES
182
- bundler (~> 4.0)
183
- kreuzberg!
184
- pry (~> 0.14)
185
- pry-byebug (~> 3.10)
186
- rake (~> 13.0)
187
- rake-compiler (~> 1.2)
188
- rbs (~> 3.0)
189
- rspec (~> 3.12)
190
- rubocop (~> 1.66)
191
- rubocop-performance (~> 1.21)
192
- rubocop-rspec (~> 3.0)
193
- steep (~> 1.8)
194
- yard (~> 0.9)
195
-
196
- CHECKSUMS
197
- activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
198
- addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
199
- ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
200
- base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
201
- bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
202
- byebug (13.0.0) sha256=d2263efe751941ca520fa29744b71972d39cbc41839496706f5d9b22e92ae05d
203
- coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
204
- concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
205
- connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
206
- csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f
207
- diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
208
- drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
209
- ffi (1.17.3) sha256=0e9f39f7bb3934f77ad6feab49662be77e87eedcdeb2a3f5c0234c2938563d4c
210
- ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068
211
- ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2
212
- ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668
213
- ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053
214
- ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f
215
- ffi (1.17.3-x86-linux-gnu) sha256=868a88fcaf5186c3a46b7c7c2b2c34550e1e61a405670ab23f5b6c9971529089
216
- ffi (1.17.3-x86-linux-musl) sha256=f0286aa6ef40605cf586e61406c446de34397b85dbb08cc99fdaddaef8343945
217
- ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5
218
- ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
219
- ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
220
- fileutils (1.8.0) sha256=8c6b1df54e2540bdb2f39258f08af78853aa70bad52b4d394bbc6424593c6e02
221
- i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
222
- io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
223
- json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf
224
- json-schema (6.2.0) sha256=e8bff46ed845a22c1ab2bd0d7eccf831c01fe23bb3920caa4c74db4306813666
225
- kreuzberg (4.5.2)
226
- language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
227
- lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
228
- listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2
229
- logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
230
- mcp (0.9.0) sha256=a0a3737b0ac9df0772f4ef7e2b013c260ddbcf217a5d50a66bff0baeddf03e47
231
- method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
232
- minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
233
- mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
234
- parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
235
- parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
236
- prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
237
- pry (0.16.0) sha256=d76c69065698ed1f85e717bd33d7942c38a50868f6b0673c636192b3d1b6054e
238
- pry-byebug (3.12.0) sha256=594e094ae8a8390a7ad4c7b36ae36e13304ed02664c67417d108dc5f7213d1b7
239
- public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
240
- racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
241
- rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
242
- rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
243
- rake-compiler (1.3.1) sha256=6b351612b6e2d73ddd5563ee799bb58685176e05363db6758504bd11573d670a
244
- rake-compiler-dock (1.11.0) sha256=eab51f2cd533eb35cea6b624a75281f047123e70a64c58b607471bb49428f8c2
245
- rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
246
- rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e
247
- rb_sys (0.9.124) sha256=513476557b12eaf73764b3da9f8746024558fe8699bda785fb548c9aa3877ae7
248
- rbs (3.10.3) sha256=70627f3919016134d554e6c99195552ae3ef6020fe034c8e983facc9c192daa6
249
- regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
250
- reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
251
- rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
252
- rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
253
- rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
254
- rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
255
- rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
256
- rubocop (1.85.1) sha256=3dbcf9e961baa4c376eeeb2a03913dca5e3987033b04d38fa538aa1e7406cc77
257
- rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
258
- rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
259
- rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
260
- ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
261
- securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
262
- sorbet-runtime (0.6.13055) sha256=c8ae8c81310e0a28d290b11f44ddca59659b7d7f13752c0ef5d16964bbb84d18
263
- steep (1.10.0) sha256=1b295b55f9aaff1b8d3ee42453ee55bc2a1078fda0268f288edb2dc014f4d7d1
264
- strscan (3.1.7) sha256=5f76462b94a3ea50b44973225b7d75b2cb96d4e1bee9ef1319b99ca117b72c8c
265
- terminal-table (4.0.0) sha256=f504793203f8251b2ea7c7068333053f0beeea26093ec9962e62ea79f94301d2
266
- tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
267
- tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
268
- unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
269
- unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
270
- uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
271
- yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f
272
-
273
- BUNDLED WITH
274
- 4.0.5
data/Rakefile DELETED
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rake/extensiontask'
5
- require 'rspec/core/rake_task'
6
-
7
- GEMSPEC = Gem::Specification.load(File.expand_path('kreuzberg.gemspec', __dir__))
8
-
9
- # Vendor kreuzberg core crates before compilation
10
- task :vendor do
11
- vendor_script = File.expand_path('../../scripts/ci/ruby/vendor-kreuzberg-core.py', __dir__)
12
- puts 'Vendoring kreuzberg core crates...'
13
- sh "python3 #{vendor_script}"
14
- end
15
-
16
- Rake::ExtensionTask.new('kreuzberg_rb', GEMSPEC) do |ext|
17
- ext.lib_dir = 'lib'
18
- ext.ext_dir = 'ext/kreuzberg_rb'
19
- ext.cross_compile = true
20
- ext.cross_platform = %w[
21
- x86_64-linux
22
- aarch64-linux
23
- x86_64-darwin
24
- arm64-darwin
25
- x64-mingw32
26
- x64-mingw-ucrt
27
- ]
28
- end
29
-
30
- RSpec::Core::RakeTask.new(:spec)
31
-
32
- task compile: :vendor
33
- task spec: :compile
34
- task default: :spec
data/Steepfile DELETED
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Steep configuration for Kreuzberg Ruby package
4
-
5
- target :lib do
6
- signature 'sig'
7
-
8
- check 'lib'
9
-
10
- # Core library
11
- library 'pathname'
12
- library 'json'
13
- library 'fileutils'
14
- library 'open3'
15
-
16
- # Strategic ignores for steep limitations (not fixable, safe to ignore):
17
-
18
- # 1. Sorbet type annotations - Steep doesn't recognize Sorbet's T::Struct and T::Sig
19
- # This file uses Sorbet exclusively for type definitions
20
- ignore 'lib/kreuzberg/types.rb'
21
-
22
- # 2. Struct.new with keyword_init - steep cannot understand implicit attr_readers
23
- # defined by Struct.new in blocks (Table and Chunk classes)
24
- ignore 'lib/kreuzberg/result.rb'
25
-
26
- # 3. Generic type parameters in normalize_config - steep has difficulty with
27
- # methods that take Class as parameter and return instances
28
- ignore 'lib/kreuzberg/config.rb'
29
-
30
- # 4. Interface types - steep doesn't recognize that all Ruby objects have nil? and is_a?
31
- # even for interface types like _ToH
32
- ignore 'lib/kreuzberg/extraction_api.rb'
33
-
34
- # 5. Open3 methods - steep's built-in Open3 RBS signatures incomplete
35
- # (capture2, capture3, popen3 are standard library methods)
36
- ignore 'lib/kreuzberg/setup_lib_path.rb'
37
- ignore 'lib/kreuzberg/cli_proxy.rb'
38
- ignore 'lib/kreuzberg/mcp_proxy.rb'
39
-
40
- # Ignore Rust extension methods (defined in native code)
41
- ignore 'ext'
42
-
43
- # Ignore vendored code
44
- ignore 'vendor'
45
-
46
- # Ignore test files
47
- ignore 'spec'
48
-
49
- # Ignore examples
50
- ignore 'examples'
51
- end
@@ -1,282 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'kreuzberg'
4
-
5
- # NOTE: Ruby bindings use Tokio runtime with block_on() internally.
6
- # The "async" functions block the Ruby GVL during execution, so there's
7
- # no performance benefit over the _sync variants from Ruby's perspective.
8
-
9
- # ============================================================================
10
- # Pattern 1: Synchronous Extraction (Recommended)
11
- # ============================================================================
12
-
13
- def basic_sync_extraction
14
- result = Kreuzberg.extract_file_sync('document.pdf')
15
- puts "Content: #{result[:content]}"
16
- puts "MIME type: #{result[:mime_type]}"
17
- end
18
-
19
- # ============================================================================
20
- # Pattern 2: "Async" Extraction (Same Performance as Sync)
21
- # ============================================================================
22
-
23
- def basic_async_extraction
24
- result = Kreuzberg.extract_file('document.pdf')
25
- puts "Content: #{result[:content]}"
26
- end
27
-
28
- # ============================================================================
29
- # Pattern 3: Concurrent Processing with Ruby Threads
30
- # ============================================================================
31
-
32
- def concurrent_with_threads
33
- files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf']
34
-
35
- threads = files.map do |file|
36
- Thread.new do
37
- Kreuzberg.extract_file_sync(file)
38
- end
39
- end
40
-
41
- results = threads.map(&:value)
42
- results.each_with_index do |result, index|
43
- puts "File #{index + 1}: #{result[:content][0..100]}"
44
- end
45
- end
46
-
47
- # ============================================================================
48
- # Pattern 4: Batch Processing (Preferred for Multiple Files)
49
- # ============================================================================
50
-
51
- def batch_processing
52
- files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf']
53
-
54
- results = Kreuzberg.batch_extract_files_sync(files)
55
-
56
- puts "Processed #{results.length} files"
57
- results.each do |result|
58
- puts "Content preview: #{result[:content][0..50]}"
59
- end
60
- end
61
-
62
- # ============================================================================
63
- # Pattern 5: Extraction with Configuration
64
- # ============================================================================
65
-
66
- def extraction_with_config
67
- config = {
68
- ocr: {
69
- backend: 'tesseract',
70
- language: 'eng'
71
- },
72
- force_ocr: false
73
- }
74
-
75
- result = Kreuzberg.extract_file_sync('scanned.pdf', **config)
76
- puts "Extracted with OCR: #{result[:content]}"
77
- end
78
-
79
- # ============================================================================
80
- # Pattern 6: Extract from Bytes
81
- # ============================================================================
82
-
83
- def extract_from_bytes
84
- data = File.binread('document.pdf')
85
- result = Kreuzberg.extract_bytes_sync(data, 'application/pdf')
86
- puts "Extracted from memory: #{result[:content]}"
87
- end
88
-
89
- # ============================================================================
90
- # Pattern 7: Batch Extract from Bytes
91
- # ============================================================================
92
-
93
- def batch_extract_from_bytes
94
- files = ['doc1.pdf', 'doc2.pdf']
95
- bytes_array = files.map { |f| File.binread(f) }
96
- mime_types = ['application/pdf', 'application/pdf']
97
-
98
- results = Kreuzberg.batch_extract_bytes_sync(bytes_array, mime_types)
99
- puts "Processed #{results.length} files from memory"
100
- end
101
-
102
- # ============================================================================
103
- # Pattern 8: Error Handling
104
- # ============================================================================
105
-
106
- def error_handling
107
- Kreuzberg.extract_file_sync('nonexistent.pdf')
108
- rescue StandardError => e
109
- puts "Extraction failed: #{e.message}"
110
- end
111
-
112
- # ============================================================================
113
- # Pattern 9: Sequential Processing
114
- # ============================================================================
115
-
116
- def sequential_processing
117
- files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf']
118
-
119
- files.each do |file|
120
- result = Kreuzberg.extract_file_sync(file)
121
- puts "Processed #{file}: #{result[:content][0..50]}"
122
- end
123
- end
124
-
125
- # ============================================================================
126
- # Pattern 10: Background Processing with ActiveJob (Rails)
127
- # ============================================================================
128
-
129
- # Example ActiveJob for async processing in Rails
130
- # < ApplicationJob
131
- class DocumentExtractionJob
132
- def perform(file_path)
133
- result = Kreuzberg.extract_file_sync(file_path)
134
- puts "Background extraction complete: #{result[:content][0..100]}"
135
- end
136
- end
137
-
138
- # Usage in Rails controller:
139
- # DocumentExtractionJob.perform_later('document.pdf')
140
-
141
- # ============================================================================
142
- # Pattern 11: Concurrent Processing with Parallel Gem
143
- # ============================================================================
144
-
145
- def concurrent_with_parallel_gem
146
- require 'parallel'
147
-
148
- files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf', 'doc4.pdf']
149
-
150
- results = Parallel.map(files, in_processes: 4) do |file|
151
- Kreuzberg.extract_file_sync(file)
152
- end
153
-
154
- results.each do |result|
155
- puts "Content: #{result[:content][0..50]}"
156
- end
157
- end
158
-
159
- # ============================================================================
160
- # Pattern 12: Timeout Wrapper
161
- # ============================================================================
162
-
163
- def extraction_with_timeout(file_path, timeout_seconds = 30)
164
- require 'timeout'
165
-
166
- Timeout.timeout(timeout_seconds) do
167
- Kreuzberg.extract_file_sync(file_path)
168
- end
169
- rescue Timeout::Error
170
- puts "Extraction timed out after #{timeout_seconds} seconds"
171
- nil
172
- end
173
-
174
- # ============================================================================
175
- # Pattern 13: Custom Ruby PostProcessor Plugin
176
- # ============================================================================
177
-
178
- def register_postprocessor
179
- uppercase_processor = lambda do |result|
180
- result[:content] = result[:content].upcase
181
- result
182
- end
183
-
184
- Kreuzberg.register_post_processor('uppercase', uppercase_processor, 100)
185
-
186
- result = Kreuzberg.extract_file_sync('document.pdf')
187
- puts "Uppercase content: #{result[:content]}"
188
-
189
- Kreuzberg.unregister_post_processor('uppercase')
190
- end
191
-
192
- # ============================================================================
193
- # Pattern 14: Custom Ruby Validator Plugin
194
- # ============================================================================
195
-
196
- def register_validator
197
- min_length_validator = lambda do |result|
198
- raise 'Content too short' if result[:content].length < 100
199
- end
200
-
201
- Kreuzberg.register_validator('min_length', min_length_validator, 100)
202
-
203
- begin
204
- result = Kreuzberg.extract_file_sync('short_document.pdf')
205
- puts "Validation passed: #{result[:content]}"
206
- rescue StandardError => e
207
- puts "Validation failed: #{e.message}"
208
- end
209
-
210
- Kreuzberg.unregister_validator('min_length')
211
- end
212
-
213
- # ============================================================================
214
- # Pattern 15: Custom Ruby OCR Backend Plugin
215
- # ============================================================================
216
-
217
- # Example OCR backend implementation for custom processing.
218
- def register_ocr_backend
219
- backend = Class.new do
220
- def process_image(image_bytes, language)
221
- "Extracted text from #{image_bytes.length} bytes using #{language}"
222
- end
223
-
224
- def supports_language?(lang)
225
- %w[eng deu fra].include?(lang)
226
- end
227
- end.new
228
-
229
- Kreuzberg.register_ocr_backend('custom', backend)
230
-
231
- config = {
232
- ocr: {
233
- backend: 'custom',
234
- language: 'eng'
235
- },
236
- force_ocr: true
237
- }
238
-
239
- result = Kreuzberg.extract_file_sync('scanned.pdf', **config)
240
- puts "Custom OCR result: #{result[:content]}"
241
- end
242
-
243
- # ============================================================================
244
- # Main Demonstration
245
- # ============================================================================
246
-
247
- def main
248
- puts '=== Basic Sync Extraction ==='
249
- basic_sync_extraction
250
-
251
- puts '\n=== Basic Async Extraction (Blocks GVL) ==='
252
- basic_async_extraction
253
-
254
- puts '\n=== Concurrent with Ruby Threads ==='
255
- concurrent_with_threads
256
-
257
- puts '\n=== Batch Processing (Preferred) ==='
258
- batch_processing
259
-
260
- puts '\n=== Extraction with Config ==='
261
- extraction_with_config
262
-
263
- puts '\n=== Extract from Bytes ==='
264
- extract_from_bytes
265
-
266
- puts '\n=== Error Handling ==='
267
- error_handling
268
-
269
- puts '\n=== Sequential Processing ==='
270
- sequential_processing
271
-
272
- puts '\n=== Extraction with Timeout ==='
273
- extraction_with_timeout('large_document.pdf', 30)
274
-
275
- puts '\n=== Custom PostProcessor ==='
276
- register_postprocessor
277
-
278
- puts '\n=== Custom Validator ==='
279
- register_validator
280
- end
281
-
282
- main if __FILE__ == $PROGRAM_NAME
data/extconf.rb DELETED
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'mkmf'
4
- require 'rb_sys/mkmf'
5
- require 'rbconfig'
6
- require 'fileutils'
7
-
8
- if Gem.win_platform?
9
- # Use CI-provided CARGO_TARGET_DIR if available, otherwise use a short path
10
- # GitHub Actions sets CARGO_TARGET_DIR=C:\t for MAX_PATH mitigation
11
- if ENV['CARGO_TARGET_DIR']
12
- puts "Windows detected: Using existing CARGO_TARGET_DIR=#{ENV['CARGO_TARGET_DIR']}"
13
- else
14
- short_target_dir = Dir.exist?('C:/t') ? 'C:/t' : 'C:/kz-build'
15
- begin
16
- FileUtils.mkdir_p(short_target_dir)
17
- ENV['CARGO_TARGET_DIR'] = short_target_dir
18
- ENV['OUT_DIR'] = short_target_dir
19
- puts "Windows detected: Using short build path #{short_target_dir}"
20
- rescue StandardError => e
21
- puts "Warning: Could not create short path #{short_target_dir}: #{e.message}"
22
- end
23
- end
24
- end
25
-
26
- if /mswin|mingw/.match?(RbConfig::CONFIG['host_os'])
27
- devkit = ENV.fetch('RI_DEVKIT', nil)
28
- prefix = ENV['MSYSTEM_PREFIX'] || '/ucrt64'
29
-
30
- # Set up include paths for MSVC compatibility headers
31
- native_include = File.expand_path('ext/kreuzberg_rb/native/include', __dir__).tr('\\', '/')
32
- compat_include = File.expand_path('ext/kreuzberg_rb/native/include/msvc_compat', __dir__).tr('\\', '/')
33
-
34
- extra_args = []
35
- extra_args << "-I#{native_include}"
36
- extra_args << "-I#{compat_include}"
37
- extra_args << '-fms-extensions'
38
- extra_args << '-fno-omit-frame-pointer'
39
-
40
- if devkit
41
- sysroot = "#{devkit}#{prefix}".tr('\\', '/')
42
- extra_args.push('--target=x86_64-pc-windows-gnu', "--sysroot=#{sysroot}")
43
- end
44
-
45
- unless extra_args.empty?
46
- existing = ENV['BINDGEN_EXTRA_CLANG_ARGS'].to_s.split(/\s+/).reject(&:empty?)
47
- ENV['BINDGEN_EXTRA_CLANG_ARGS'] = (existing + extra_args).uniq.join(' ')
48
- puts "BINDGEN_EXTRA_CLANG_ARGS set to: #{ENV.fetch('BINDGEN_EXTRA_CLANG_ARGS', nil)}"
49
- end
50
-
51
- # Set target for Windows GNU toolchain if not already set
52
- ENV['CARGO_BUILD_TARGET'] ||= 'x86_64-pc-windows-gnu' if devkit || ENV['MSYSTEM']
53
- end
54
-
55
- default_profile = ENV.fetch('CARGO_PROFILE', 'release')
56
-
57
- create_rust_makefile('kreuzberg_rb') do |config|
58
- config.profile = default_profile.to_sym
59
- config.ext_dir = File.expand_path('ext/kreuzberg_rb/native', __dir__)
60
- end