kreuzberg 4.6.0-aarch64-linux → 4.6.2-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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/kreuzberg/config.rb +22 -8
- data/lib/kreuzberg/extraction_api.rb +37 -0
- data/lib/kreuzberg/version.rb +1 -1
- data/lib/kreuzberg_rb.so +0 -0
- data/sig/kreuzberg.rbs +5 -1
- data/spec/binding/render_spec.rb +91 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 406c791db1a8cb29e3ff2e89a60e0a29ed73c0ff0548338b60c3574bd5944f6f
|
|
4
|
+
data.tar.gz: 7565bbe0708afceadc13f43b57103a03529992f705caf21f1ddaa00e68ad27d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a680fd2406f8dac338a53ab303ef29d117462cbf376d48be4af48846f7d4f82d4e7999e2aeac17a404e5da7feb79f1cccfb8f240153c0c36a4274e16eeb50f6f
|
|
7
|
+
data.tar.gz: dc1c1dc215020a65560490e159e38d6780b703bae597279cb0e3d2c369afce7a7bee06984972987d1c3a69fe2040da1cb1e2812df5c542590300dfcb09e5e7d7
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<img src="https://img.shields.io/maven-central/v/dev.kreuzberg/kreuzberg?label=Java&color=007ec6" alt="Java">
|
|
23
23
|
</a>
|
|
24
24
|
<a href="https://github.com/kreuzberg-dev/kreuzberg/releases">
|
|
25
|
-
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.6.
|
|
25
|
+
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.6.2" alt="Go">
|
|
26
26
|
</a>
|
|
27
27
|
<a href="https://www.nuget.org/packages/Kreuzberg/">
|
|
28
28
|
<img src="https://img.shields.io/nuget/v/Kreuzberg?label=C%23&color=007ec6" alt="C#">
|
data/lib/kreuzberg/config.rb
CHANGED
|
@@ -926,14 +926,14 @@ module Kreuzberg
|
|
|
926
926
|
# )
|
|
927
927
|
#
|
|
928
928
|
class Extraction
|
|
929
|
-
attr_reader :use_cache, :enable_quality_processing, :force_ocr,
|
|
929
|
+
attr_reader :use_cache, :enable_quality_processing, :force_ocr, :force_ocr_pages,
|
|
930
930
|
:include_document_structure,
|
|
931
931
|
:ocr, :chunking, :language_detection, :pdf_options,
|
|
932
932
|
:images, :postprocessor,
|
|
933
933
|
:token_reduction, :keywords, :html_options, :pages,
|
|
934
934
|
:max_concurrent_extractions, :output_format, :result_format,
|
|
935
935
|
:security_limits, :layout, :concurrency,
|
|
936
|
-
:cache_namespace, :cache_ttl_secs
|
|
936
|
+
:cache_namespace, :cache_ttl_secs, :extraction_timeout_secs
|
|
937
937
|
|
|
938
938
|
# Alias for backward compatibility - image_extraction is the canonical name
|
|
939
939
|
alias image_extraction images
|
|
@@ -954,11 +954,11 @@ module Kreuzberg
|
|
|
954
954
|
#
|
|
955
955
|
# Keys that are allowed in the Extraction config
|
|
956
956
|
ALLOWED_KEYS = %i[
|
|
957
|
-
use_cache enable_quality_processing force_ocr include_document_structure ocr chunking
|
|
957
|
+
use_cache enable_quality_processing force_ocr force_ocr_pages include_document_structure ocr chunking
|
|
958
958
|
language_detection pdf_options image_extraction
|
|
959
959
|
postprocessor token_reduction keywords html_options pages
|
|
960
960
|
max_concurrent_extractions output_format result_format
|
|
961
|
-
security_limits layout concurrency cache_namespace cache_ttl_secs
|
|
961
|
+
security_limits layout concurrency cache_namespace cache_ttl_secs extraction_timeout_secs
|
|
962
962
|
].freeze
|
|
963
963
|
|
|
964
964
|
# Aliases for backward compatibility
|
|
@@ -1019,6 +1019,7 @@ module Kreuzberg
|
|
|
1019
1019
|
use_cache: true,
|
|
1020
1020
|
enable_quality_processing: true,
|
|
1021
1021
|
force_ocr: false,
|
|
1022
|
+
force_ocr_pages: nil,
|
|
1022
1023
|
include_document_structure: false,
|
|
1023
1024
|
ocr: nil,
|
|
1024
1025
|
chunking: nil,
|
|
@@ -1037,10 +1038,12 @@ module Kreuzberg
|
|
|
1037
1038
|
layout: nil,
|
|
1038
1039
|
concurrency: nil,
|
|
1039
1040
|
cache_namespace: nil,
|
|
1040
|
-
cache_ttl_secs: nil
|
|
1041
|
+
cache_ttl_secs: nil,
|
|
1042
|
+
extraction_timeout_secs: nil)
|
|
1041
1043
|
kwargs = {
|
|
1042
1044
|
use_cache: use_cache, enable_quality_processing: enable_quality_processing,
|
|
1043
|
-
force_ocr: force_ocr,
|
|
1045
|
+
force_ocr: force_ocr, force_ocr_pages: force_ocr_pages,
|
|
1046
|
+
include_document_structure: include_document_structure,
|
|
1044
1047
|
ocr: ocr, chunking: chunking, language_detection: language_detection,
|
|
1045
1048
|
pdf_options: pdf_options, image_extraction: image_extraction,
|
|
1046
1049
|
postprocessor: postprocessor,
|
|
@@ -1050,7 +1053,8 @@ module Kreuzberg
|
|
|
1050
1053
|
security_limits: security_limits, layout: layout,
|
|
1051
1054
|
concurrency: concurrency,
|
|
1052
1055
|
cache_namespace: cache_namespace,
|
|
1053
|
-
cache_ttl_secs: cache_ttl_secs
|
|
1056
|
+
cache_ttl_secs: cache_ttl_secs,
|
|
1057
|
+
extraction_timeout_secs: extraction_timeout_secs
|
|
1054
1058
|
}
|
|
1055
1059
|
extracted = extract_from_hash(hash, kwargs)
|
|
1056
1060
|
|
|
@@ -1068,6 +1072,7 @@ module Kreuzberg
|
|
|
1068
1072
|
@use_cache = params[:use_cache] ? true : false
|
|
1069
1073
|
@enable_quality_processing = params[:enable_quality_processing] ? true : false
|
|
1070
1074
|
@force_ocr = params[:force_ocr] ? true : false
|
|
1075
|
+
@force_ocr_pages = params[:force_ocr_pages]
|
|
1071
1076
|
@include_document_structure = params[:include_document_structure] ? true : false
|
|
1072
1077
|
@ocr = normalize_config(params[:ocr], OCR)
|
|
1073
1078
|
@chunking = normalize_config(params[:chunking], Chunking)
|
|
@@ -1086,6 +1091,7 @@ module Kreuzberg
|
|
|
1086
1091
|
@result_format = validate_result_format(params[:result_format])
|
|
1087
1092
|
@cache_namespace = params[:cache_namespace]
|
|
1088
1093
|
@cache_ttl_secs = params[:cache_ttl_secs]&.to_i
|
|
1094
|
+
@extraction_timeout_secs = params[:extraction_timeout_secs]&.to_i
|
|
1089
1095
|
@security_limits = params[:security_limits]
|
|
1090
1096
|
end
|
|
1091
1097
|
|
|
@@ -1118,12 +1124,14 @@ module Kreuzberg
|
|
|
1118
1124
|
use_cache: @use_cache,
|
|
1119
1125
|
enable_quality_processing: @enable_quality_processing,
|
|
1120
1126
|
force_ocr: @force_ocr,
|
|
1127
|
+
force_ocr_pages: @force_ocr_pages,
|
|
1121
1128
|
include_document_structure: @include_document_structure,
|
|
1122
1129
|
max_concurrent_extractions: @max_concurrent_extractions,
|
|
1123
1130
|
output_format: @output_format,
|
|
1124
1131
|
result_format: @result_format,
|
|
1125
1132
|
cache_namespace: @cache_namespace,
|
|
1126
|
-
cache_ttl_secs: @cache_ttl_secs
|
|
1133
|
+
cache_ttl_secs: @cache_ttl_secs,
|
|
1134
|
+
extraction_timeout_secs: @extraction_timeout_secs
|
|
1127
1135
|
}
|
|
1128
1136
|
end
|
|
1129
1137
|
|
|
@@ -1250,6 +1258,8 @@ module Kreuzberg
|
|
|
1250
1258
|
@enable_quality_processing = value ? true : false
|
|
1251
1259
|
when :force_ocr
|
|
1252
1260
|
@force_ocr = value ? true : false
|
|
1261
|
+
when :force_ocr_pages
|
|
1262
|
+
@force_ocr_pages = value
|
|
1253
1263
|
when :include_document_structure
|
|
1254
1264
|
@include_document_structure = value ? true : false
|
|
1255
1265
|
when :ocr
|
|
@@ -1286,6 +1296,8 @@ module Kreuzberg
|
|
|
1286
1296
|
@cache_namespace = value
|
|
1287
1297
|
when :cache_ttl_secs
|
|
1288
1298
|
@cache_ttl_secs = value&.to_i
|
|
1299
|
+
when :extraction_timeout_secs
|
|
1300
|
+
@extraction_timeout_secs = value&.to_i
|
|
1289
1301
|
else
|
|
1290
1302
|
raise ArgumentError, "Unknown configuration key: #{key}"
|
|
1291
1303
|
end
|
|
@@ -1345,6 +1357,7 @@ module Kreuzberg
|
|
|
1345
1357
|
@use_cache = merged.use_cache
|
|
1346
1358
|
@enable_quality_processing = merged.enable_quality_processing
|
|
1347
1359
|
@force_ocr = merged.force_ocr
|
|
1360
|
+
@force_ocr_pages = merged.force_ocr_pages
|
|
1348
1361
|
@include_document_structure = merged.include_document_structure
|
|
1349
1362
|
@ocr = merged.ocr
|
|
1350
1363
|
@chunking = merged.chunking
|
|
@@ -1369,6 +1382,7 @@ module Kreuzberg
|
|
|
1369
1382
|
@result_format = merged.result_format
|
|
1370
1383
|
@cache_namespace = merged.cache_namespace
|
|
1371
1384
|
@cache_ttl_secs = merged.cache_ttl_secs
|
|
1385
|
+
@extraction_timeout_secs = merged.extraction_timeout_secs
|
|
1372
1386
|
end
|
|
1373
1387
|
end
|
|
1374
1388
|
end
|
|
@@ -319,6 +319,43 @@ module Kreuzberg
|
|
|
319
319
|
results
|
|
320
320
|
end
|
|
321
321
|
|
|
322
|
+
# Render a single PDF page as a PNG image.
|
|
323
|
+
#
|
|
324
|
+
# @param path [String, Pathname] Path to the PDF file
|
|
325
|
+
# @param page_index [Integer] Zero-based page index
|
|
326
|
+
# @param dpi [Integer] Rendering resolution (default 150)
|
|
327
|
+
# @return [String] PNG-encoded binary string
|
|
328
|
+
# @raise [Errors::IOError] If the file cannot be read
|
|
329
|
+
# @raise [Errors::ParsingError] If rendering fails
|
|
330
|
+
def render_pdf_page(path, page_index, dpi: 150)
|
|
331
|
+
path_str = path.to_s
|
|
332
|
+
raise ArgumentError, 'page_index must be non-negative' if page_index.negative?
|
|
333
|
+
raise Errors::IOError, "File not found: #{path_str}" unless File.exist?(path_str)
|
|
334
|
+
|
|
335
|
+
native_render_pdf_page(path_str, page_index, dpi)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Iterate over pages of a PDF lazily, yielding each page as it is rendered.
|
|
339
|
+
#
|
|
340
|
+
# Each page is rendered via the native FFI iterator, so only one page is in
|
|
341
|
+
# memory at a time.
|
|
342
|
+
#
|
|
343
|
+
# @param path [String, Pathname] Path to the PDF file
|
|
344
|
+
# @param dpi [Integer] Rendering resolution (default 150)
|
|
345
|
+
# @yieldparam page_index [Integer] Zero-based page index
|
|
346
|
+
# @yieldparam png_bytes [String] PNG-encoded binary string for the page
|
|
347
|
+
# @return [Enumerator] if no block is given
|
|
348
|
+
# @raise [Errors::IOError] If the file cannot be read
|
|
349
|
+
# @raise [Errors::ParsingError] If rendering fails
|
|
350
|
+
def render_pdf_pages_iter(path, dpi: 150, &block)
|
|
351
|
+
path_str = path.to_s
|
|
352
|
+
raise Errors::IOError, "File not found: #{path_str}" unless File.exist?(path_str)
|
|
353
|
+
|
|
354
|
+
return enum_for(:render_pdf_pages_iter, path, dpi: dpi) unless block
|
|
355
|
+
|
|
356
|
+
native_render_pdf_pages_iter(path_str, dpi, &block)
|
|
357
|
+
end
|
|
358
|
+
|
|
322
359
|
def normalize_config(config)
|
|
323
360
|
return {} if config.nil?
|
|
324
361
|
return config if config.is_a?(Hash)
|
data/lib/kreuzberg/version.rb
CHANGED
data/lib/kreuzberg_rb.so
CHANGED
|
Binary file
|
data/sig/kreuzberg.rbs
CHANGED
|
@@ -481,7 +481,9 @@ module Kreuzberg
|
|
|
481
481
|
attr_reader enable_quality_processing: bool
|
|
482
482
|
attr_reader cache_namespace: String?
|
|
483
483
|
attr_reader cache_ttl_secs: Integer?
|
|
484
|
+
attr_reader extraction_timeout_secs: Integer?
|
|
484
485
|
attr_reader force_ocr: bool
|
|
486
|
+
attr_reader force_ocr_pages: Array[Integer]?
|
|
485
487
|
attr_reader include_document_structure: bool
|
|
486
488
|
attr_reader ocr: OCR?
|
|
487
489
|
attr_reader chunking: Chunking?
|
|
@@ -508,6 +510,7 @@ module Kreuzberg
|
|
|
508
510
|
?use_cache: bool,
|
|
509
511
|
?enable_quality_processing: bool,
|
|
510
512
|
?force_ocr: bool,
|
|
513
|
+
?force_ocr_pages: Array[Integer]?,
|
|
511
514
|
?include_document_structure: bool,
|
|
512
515
|
?ocr: (OCR | Hash[Symbol, untyped])?,
|
|
513
516
|
?chunking: (Chunking | Hash[Symbol, untyped])?,
|
|
@@ -525,7 +528,8 @@ module Kreuzberg
|
|
|
525
528
|
?output_format: String?,
|
|
526
529
|
?result_format: String?,
|
|
527
530
|
?cache_namespace: String?,
|
|
528
|
-
?cache_ttl_secs: Integer
|
|
531
|
+
?cache_ttl_secs: Integer?,
|
|
532
|
+
?extraction_timeout_secs: Integer?
|
|
529
533
|
) -> void
|
|
530
534
|
def to_h: () -> Hash[Symbol, untyped]
|
|
531
535
|
def to_json: (*untyped) -> String
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Hand-written binding-specific edge case tests for PDF rendering.
|
|
2
|
+
# Happy-path render tests are auto-generated from fixtures in e2e/.
|
|
3
|
+
# These tests cover error handling, validation, and lifecycle patterns
|
|
4
|
+
# that vary per language and can't be generated uniformly.
|
|
5
|
+
|
|
6
|
+
# frozen_string_literal: true
|
|
7
|
+
|
|
8
|
+
require 'spec_helper'
|
|
9
|
+
|
|
10
|
+
RSpec.describe 'PDF Rendering' do
|
|
11
|
+
it 'exposes rendering methods' do
|
|
12
|
+
expect(Kreuzberg).to respond_to(:render_pdf_page)
|
|
13
|
+
expect(Kreuzberg).to respond_to(:render_pdf_pages_iter)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe '.render_pdf_page' do
|
|
17
|
+
it 'raises an error for a nonexistent file' do
|
|
18
|
+
expect do
|
|
19
|
+
Kreuzberg.render_pdf_page('/nonexistent/path/to/document.pdf', 0)
|
|
20
|
+
end.to raise_error(Kreuzberg::Errors::IOError)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'raises an error for an out-of-bounds page index' do
|
|
24
|
+
pdf_path = test_document_path('pdf/tiny.pdf')
|
|
25
|
+
skip 'Test PDF not available' unless File.exist?(pdf_path)
|
|
26
|
+
|
|
27
|
+
expect do
|
|
28
|
+
Kreuzberg.render_pdf_page(pdf_path, 9999)
|
|
29
|
+
end.to raise_error(StandardError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '.render_pdf_page with negative index' do
|
|
34
|
+
it 'raises ArgumentError for a negative page index' do
|
|
35
|
+
pdf_path = test_document_path('pdf/tiny.pdf')
|
|
36
|
+
skip 'Test PDF not available' unless File.exist?(pdf_path)
|
|
37
|
+
|
|
38
|
+
expect do
|
|
39
|
+
Kreuzberg.render_pdf_page(pdf_path, -1)
|
|
40
|
+
end.to raise_error(ArgumentError)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '.render_pdf_pages_iter' do
|
|
45
|
+
it 'raises an error for a nonexistent file' do
|
|
46
|
+
expect do
|
|
47
|
+
Kreuzberg.render_pdf_pages_iter('/nonexistent/path/to/document.pdf') { |_, _| nil }
|
|
48
|
+
end.to raise_error(Kreuzberg::Errors::IOError)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '.render_pdf_page with empty path' do
|
|
53
|
+
it 'raises an error for an empty path' do
|
|
54
|
+
expect do
|
|
55
|
+
Kreuzberg.render_pdf_page('', 0)
|
|
56
|
+
end.to raise_error(StandardError)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '.render_pdf_pages_iter cleanup' do
|
|
61
|
+
it 'handles iterator cleanup without fully consuming' do
|
|
62
|
+
pdf_path = test_document_path('pdf/tiny.pdf')
|
|
63
|
+
skip 'Test PDF not available' unless File.exist?(pdf_path)
|
|
64
|
+
|
|
65
|
+
# Iterate but stop immediately — no crash
|
|
66
|
+
Kreuzberg.render_pdf_pages_iter(pdf_path) do |_page_index, _png_data|
|
|
67
|
+
break
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe '.render_pdf_pages_iter early termination' do
|
|
73
|
+
it 'returns valid PNG for the first page then stops' do
|
|
74
|
+
pdf_path = test_document_path('pdf/tiny.pdf')
|
|
75
|
+
skip 'Test PDF not available' unless File.exist?(pdf_path)
|
|
76
|
+
|
|
77
|
+
first_png = nil
|
|
78
|
+
Kreuzberg.render_pdf_pages_iter(pdf_path) do |page_index, png_data|
|
|
79
|
+
expect(page_index).to eq(0)
|
|
80
|
+
expect(png_data).to be_a(String)
|
|
81
|
+
expect(png_data.bytesize).to be > 8
|
|
82
|
+
# PNG magic bytes
|
|
83
|
+
expect(png_data.bytes[0..3]).to eq([0x89, 0x50, 0x4E, 0x47])
|
|
84
|
+
first_png = png_data
|
|
85
|
+
break
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
expect(first_png).not_to be_nil
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kreuzberg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.6.
|
|
4
|
+
version: 4.6.2
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Na'aman Hirschfeld
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -220,6 +220,7 @@ files:
|
|
|
220
220
|
- spec/binding/plugins/ocr_backend_spec.rb
|
|
221
221
|
- spec/binding/plugins/postprocessor_spec.rb
|
|
222
222
|
- spec/binding/plugins/validator_spec.rb
|
|
223
|
+
- spec/binding/render_spec.rb
|
|
223
224
|
- spec/binding/tables_spec.rb
|
|
224
225
|
- spec/serialization_spec.rb
|
|
225
226
|
- spec/smoke/package_spec.rb
|