kreuzberg 4.0.0.pre.rc.29 → 4.0.0.rc1
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/.gitignore +0 -6
- data/.rubocop.yaml +534 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +28 -116
- data/README.md +269 -629
- data/Rakefile +0 -9
- data/Steepfile +4 -8
- data/examples/async_patterns.rb +58 -1
- data/ext/kreuzberg_rb/extconf.rb +5 -35
- data/ext/kreuzberg_rb/native/Cargo.toml +16 -55
- data/ext/kreuzberg_rb/native/build.rs +14 -12
- data/ext/kreuzberg_rb/native/include/ieeefp.h +1 -1
- data/ext/kreuzberg_rb/native/include/msvc_compat/strings.h +1 -1
- data/ext/kreuzberg_rb/native/include/strings.h +2 -2
- data/ext/kreuzberg_rb/native/include/unistd.h +1 -1
- data/ext/kreuzberg_rb/native/src/lib.rs +34 -897
- data/extconf.rb +6 -38
- data/kreuzberg.gemspec +20 -114
- data/lib/kreuzberg/api_proxy.rb +18 -2
- data/lib/kreuzberg/cache_api.rb +0 -22
- data/lib/kreuzberg/cli.rb +10 -2
- data/lib/kreuzberg/cli_proxy.rb +10 -0
- data/lib/kreuzberg/config.rb +22 -274
- data/lib/kreuzberg/errors.rb +7 -73
- data/lib/kreuzberg/extraction_api.rb +8 -237
- data/lib/kreuzberg/mcp_proxy.rb +11 -2
- data/lib/kreuzberg/ocr_backend_protocol.rb +73 -0
- data/lib/kreuzberg/post_processor_protocol.rb +71 -0
- data/lib/kreuzberg/result.rb +33 -151
- data/lib/kreuzberg/setup_lib_path.rb +2 -22
- data/lib/kreuzberg/validator_protocol.rb +73 -0
- data/lib/kreuzberg/version.rb +1 -1
- data/lib/kreuzberg.rb +13 -27
- data/pkg/kreuzberg-4.0.0.rc1.gem +0 -0
- data/sig/kreuzberg.rbs +12 -105
- data/spec/binding/cache_spec.rb +22 -22
- data/spec/binding/cli_proxy_spec.rb +4 -2
- data/spec/binding/cli_spec.rb +11 -12
- data/spec/binding/config_spec.rb +0 -74
- data/spec/binding/config_validation_spec.rb +6 -100
- data/spec/binding/error_handling_spec.rb +97 -283
- data/spec/binding/plugins/ocr_backend_spec.rb +8 -8
- data/spec/binding/plugins/postprocessor_spec.rb +11 -11
- data/spec/binding/plugins/validator_spec.rb +13 -12
- data/spec/examples.txt +104 -0
- data/spec/fixtures/config.toml +1 -0
- data/spec/fixtures/config.yaml +1 -0
- data/spec/fixtures/invalid_config.toml +1 -0
- data/spec/smoke/package_spec.rb +3 -2
- data/spec/spec_helper.rb +3 -1
- data/vendor/kreuzberg/Cargo.toml +67 -192
- data/vendor/kreuzberg/README.md +9 -97
- data/vendor/kreuzberg/build.rs +194 -516
- data/vendor/kreuzberg/src/api/handlers.rs +9 -130
- data/vendor/kreuzberg/src/api/mod.rs +3 -18
- data/vendor/kreuzberg/src/api/server.rs +71 -236
- data/vendor/kreuzberg/src/api/types.rs +7 -43
- data/vendor/kreuzberg/src/bin/profile_extract.rs +455 -0
- data/vendor/kreuzberg/src/cache/mod.rs +3 -27
- data/vendor/kreuzberg/src/chunking/mod.rs +79 -1705
- data/vendor/kreuzberg/src/core/batch_mode.rs +0 -60
- data/vendor/kreuzberg/src/core/config.rs +23 -905
- data/vendor/kreuzberg/src/core/extractor.rs +106 -403
- data/vendor/kreuzberg/src/core/io.rs +2 -4
- data/vendor/kreuzberg/src/core/mime.rs +12 -2
- data/vendor/kreuzberg/src/core/mod.rs +3 -22
- data/vendor/kreuzberg/src/core/pipeline.rs +78 -395
- data/vendor/kreuzberg/src/embeddings.rs +21 -169
- data/vendor/kreuzberg/src/error.rs +2 -2
- data/vendor/kreuzberg/src/extraction/archive.rs +31 -36
- data/vendor/kreuzberg/src/extraction/docx.rs +1 -365
- data/vendor/kreuzberg/src/extraction/email.rs +11 -12
- data/vendor/kreuzberg/src/extraction/excel.rs +129 -138
- data/vendor/kreuzberg/src/extraction/html.rs +170 -1447
- data/vendor/kreuzberg/src/extraction/image.rs +14 -138
- data/vendor/kreuzberg/src/extraction/libreoffice.rs +3 -13
- data/vendor/kreuzberg/src/extraction/mod.rs +5 -21
- data/vendor/kreuzberg/src/extraction/office_metadata/mod.rs +0 -2
- data/vendor/kreuzberg/src/extraction/pandoc/batch.rs +275 -0
- data/vendor/kreuzberg/src/extraction/pandoc/mime_types.rs +178 -0
- data/vendor/kreuzberg/src/extraction/pandoc/mod.rs +491 -0
- data/vendor/kreuzberg/src/extraction/pandoc/server.rs +496 -0
- data/vendor/kreuzberg/src/extraction/pandoc/subprocess.rs +1188 -0
- data/vendor/kreuzberg/src/extraction/pandoc/version.rs +162 -0
- data/vendor/kreuzberg/src/extraction/pptx.rs +94 -196
- data/vendor/kreuzberg/src/extraction/structured.rs +4 -5
- data/vendor/kreuzberg/src/extraction/table.rs +1 -2
- data/vendor/kreuzberg/src/extraction/text.rs +10 -18
- data/vendor/kreuzberg/src/extractors/archive.rs +0 -22
- data/vendor/kreuzberg/src/extractors/docx.rs +148 -69
- data/vendor/kreuzberg/src/extractors/email.rs +9 -37
- data/vendor/kreuzberg/src/extractors/excel.rs +40 -81
- data/vendor/kreuzberg/src/extractors/html.rs +173 -182
- data/vendor/kreuzberg/src/extractors/image.rs +8 -32
- data/vendor/kreuzberg/src/extractors/mod.rs +10 -171
- data/vendor/kreuzberg/src/extractors/pandoc.rs +201 -0
- data/vendor/kreuzberg/src/extractors/pdf.rs +64 -329
- data/vendor/kreuzberg/src/extractors/pptx.rs +34 -79
- data/vendor/kreuzberg/src/extractors/structured.rs +0 -16
- data/vendor/kreuzberg/src/extractors/text.rs +7 -30
- data/vendor/kreuzberg/src/extractors/xml.rs +8 -27
- data/vendor/kreuzberg/src/keywords/processor.rs +1 -9
- data/vendor/kreuzberg/src/keywords/rake.rs +1 -0
- data/vendor/kreuzberg/src/language_detection/mod.rs +51 -94
- data/vendor/kreuzberg/src/lib.rs +5 -17
- data/vendor/kreuzberg/src/mcp/mod.rs +1 -4
- data/vendor/kreuzberg/src/mcp/server.rs +21 -145
- data/vendor/kreuzberg/src/ocr/mod.rs +0 -2
- data/vendor/kreuzberg/src/ocr/processor.rs +8 -19
- data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +0 -2
- data/vendor/kreuzberg/src/pdf/error.rs +1 -93
- data/vendor/kreuzberg/src/pdf/metadata.rs +100 -263
- data/vendor/kreuzberg/src/pdf/mod.rs +2 -33
- data/vendor/kreuzberg/src/pdf/rendering.rs +12 -12
- data/vendor/kreuzberg/src/pdf/table.rs +64 -61
- data/vendor/kreuzberg/src/pdf/text.rs +24 -416
- data/vendor/kreuzberg/src/plugins/extractor.rs +8 -40
- data/vendor/kreuzberg/src/plugins/mod.rs +0 -3
- data/vendor/kreuzberg/src/plugins/ocr.rs +14 -22
- data/vendor/kreuzberg/src/plugins/processor.rs +1 -10
- data/vendor/kreuzberg/src/plugins/registry.rs +0 -15
- data/vendor/kreuzberg/src/plugins/validator.rs +8 -20
- data/vendor/kreuzberg/src/stopwords/mod.rs +2 -2
- data/vendor/kreuzberg/src/text/mod.rs +0 -8
- data/vendor/kreuzberg/src/text/quality.rs +15 -28
- data/vendor/kreuzberg/src/text/string_utils.rs +10 -22
- data/vendor/kreuzberg/src/text/token_reduction/core.rs +50 -86
- data/vendor/kreuzberg/src/text/token_reduction/filters.rs +16 -37
- data/vendor/kreuzberg/src/text/token_reduction/simd_text.rs +1 -2
- data/vendor/kreuzberg/src/types.rs +67 -907
- data/vendor/kreuzberg/src/utils/mod.rs +0 -14
- data/vendor/kreuzberg/src/utils/quality.rs +3 -12
- data/vendor/kreuzberg/tests/api_tests.rs +0 -506
- data/vendor/kreuzberg/tests/archive_integration.rs +0 -2
- data/vendor/kreuzberg/tests/batch_orchestration.rs +12 -57
- data/vendor/kreuzberg/tests/batch_processing.rs +8 -32
- data/vendor/kreuzberg/tests/chunking_offset_demo.rs +92 -0
- data/vendor/kreuzberg/tests/concurrency_stress.rs +8 -40
- data/vendor/kreuzberg/tests/config_features.rs +1 -33
- data/vendor/kreuzberg/tests/config_loading_tests.rs +39 -16
- data/vendor/kreuzberg/tests/core_integration.rs +9 -35
- data/vendor/kreuzberg/tests/csv_integration.rs +81 -71
- data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +25 -23
- data/vendor/kreuzberg/tests/email_integration.rs +1 -3
- data/vendor/kreuzberg/tests/error_handling.rs +34 -43
- data/vendor/kreuzberg/tests/format_integration.rs +1 -7
- data/vendor/kreuzberg/tests/helpers/mod.rs +0 -60
- data/vendor/kreuzberg/tests/image_integration.rs +0 -2
- data/vendor/kreuzberg/tests/mime_detection.rs +16 -17
- data/vendor/kreuzberg/tests/ocr_configuration.rs +0 -4
- data/vendor/kreuzberg/tests/ocr_errors.rs +0 -22
- data/vendor/kreuzberg/tests/ocr_quality.rs +0 -2
- data/vendor/kreuzberg/tests/pandoc_integration.rs +503 -0
- data/vendor/kreuzberg/tests/pdf_integration.rs +0 -2
- data/vendor/kreuzberg/tests/pipeline_integration.rs +2 -36
- data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +0 -5
- data/vendor/kreuzberg/tests/plugin_postprocessor_test.rs +1 -17
- data/vendor/kreuzberg/tests/plugin_system.rs +0 -6
- data/vendor/kreuzberg/tests/registry_integration_tests.rs +22 -2
- data/vendor/kreuzberg/tests/security_validation.rs +1 -13
- data/vendor/kreuzberg/tests/test_fastembed.rs +23 -45
- metadata +25 -171
- data/.rubocop.yml +0 -543
- data/ext/kreuzberg_rb/native/.cargo/config.toml +0 -23
- data/ext/kreuzberg_rb/native/Cargo.lock +0 -7619
- data/lib/kreuzberg/error_context.rb +0 -136
- data/lib/kreuzberg/types.rb +0 -170
- data/lib/libpdfium.so +0 -0
- data/spec/binding/async_operations_spec.rb +0 -473
- data/spec/binding/batch_operations_spec.rb +0 -595
- data/spec/binding/batch_spec.rb +0 -359
- data/spec/binding/config_result_spec.rb +0 -377
- data/spec/binding/embeddings_spec.rb +0 -816
- data/spec/binding/error_recovery_spec.rb +0 -488
- data/spec/binding/font_config_spec.rb +0 -220
- data/spec/binding/images_spec.rb +0 -738
- data/spec/binding/keywords_extraction_spec.rb +0 -600
- data/spec/binding/metadata_types_spec.rb +0 -1228
- data/spec/binding/pages_extraction_spec.rb +0 -471
- data/spec/binding/tables_spec.rb +0 -641
- data/spec/unit/config/chunking_config_spec.rb +0 -213
- data/spec/unit/config/embedding_config_spec.rb +0 -343
- data/spec/unit/config/extraction_config_spec.rb +0 -438
- data/spec/unit/config/font_config_spec.rb +0 -285
- data/spec/unit/config/hierarchy_config_spec.rb +0 -314
- data/spec/unit/config/image_extraction_config_spec.rb +0 -209
- data/spec/unit/config/image_preprocessing_config_spec.rb +0 -249
- data/spec/unit/config/keyword_config_spec.rb +0 -229
- data/spec/unit/config/language_detection_config_spec.rb +0 -258
- data/spec/unit/config/ocr_config_spec.rb +0 -171
- data/spec/unit/config/page_config_spec.rb +0 -221
- data/spec/unit/config/pdf_config_spec.rb +0 -267
- data/spec/unit/config/postprocessor_config_spec.rb +0 -290
- data/spec/unit/config/tesseract_config_spec.rb +0 -181
- data/spec/unit/config/token_reduction_config_spec.rb +0 -251
- data/test/metadata_types_test.rb +0 -959
- data/vendor/Cargo.toml +0 -61
- data/vendor/kreuzberg/examples/bench_fixes.rs +0 -71
- data/vendor/kreuzberg/examples/test_pdfium_fork.rs +0 -62
- data/vendor/kreuzberg/src/chunking/processor.rs +0 -219
- data/vendor/kreuzberg/src/core/batch_optimizations.rs +0 -385
- data/vendor/kreuzberg/src/core/config_validation.rs +0 -949
- data/vendor/kreuzberg/src/core/formats.rs +0 -235
- data/vendor/kreuzberg/src/core/server_config.rs +0 -1220
- data/vendor/kreuzberg/src/extraction/capacity.rs +0 -263
- data/vendor/kreuzberg/src/extraction/markdown.rs +0 -216
- data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -284
- data/vendor/kreuzberg/src/extractors/bibtex.rs +0 -470
- data/vendor/kreuzberg/src/extractors/docbook.rs +0 -504
- data/vendor/kreuzberg/src/extractors/epub.rs +0 -696
- data/vendor/kreuzberg/src/extractors/fictionbook.rs +0 -492
- data/vendor/kreuzberg/src/extractors/jats.rs +0 -1054
- data/vendor/kreuzberg/src/extractors/jupyter.rs +0 -368
- data/vendor/kreuzberg/src/extractors/latex.rs +0 -653
- data/vendor/kreuzberg/src/extractors/markdown.rs +0 -701
- data/vendor/kreuzberg/src/extractors/odt.rs +0 -628
- data/vendor/kreuzberg/src/extractors/opml.rs +0 -635
- data/vendor/kreuzberg/src/extractors/orgmode.rs +0 -529
- data/vendor/kreuzberg/src/extractors/rst.rs +0 -577
- data/vendor/kreuzberg/src/extractors/rtf.rs +0 -809
- data/vendor/kreuzberg/src/extractors/security.rs +0 -484
- data/vendor/kreuzberg/src/extractors/security_tests.rs +0 -367
- data/vendor/kreuzberg/src/extractors/typst.rs +0 -651
- data/vendor/kreuzberg/src/language_detection/processor.rs +0 -218
- data/vendor/kreuzberg/src/ocr/language_registry.rs +0 -520
- data/vendor/kreuzberg/src/panic_context.rs +0 -154
- data/vendor/kreuzberg/src/pdf/bindings.rs +0 -306
- data/vendor/kreuzberg/src/pdf/bundled.rs +0 -408
- data/vendor/kreuzberg/src/pdf/fonts.rs +0 -358
- data/vendor/kreuzberg/src/pdf/hierarchy.rs +0 -903
- data/vendor/kreuzberg/src/text/quality_processor.rs +0 -231
- data/vendor/kreuzberg/src/text/utf8_validation.rs +0 -193
- data/vendor/kreuzberg/src/utils/pool.rs +0 -503
- data/vendor/kreuzberg/src/utils/pool_sizing.rs +0 -364
- data/vendor/kreuzberg/src/utils/string_pool.rs +0 -761
- data/vendor/kreuzberg/tests/api_embed.rs +0 -360
- data/vendor/kreuzberg/tests/api_extract_multipart.rs +0 -52
- data/vendor/kreuzberg/tests/api_large_pdf_extraction.rs +0 -471
- data/vendor/kreuzberg/tests/api_large_pdf_extraction_diagnostics.rs +0 -289
- data/vendor/kreuzberg/tests/batch_pooling_benchmark.rs +0 -154
- data/vendor/kreuzberg/tests/bibtex_parity_test.rs +0 -421
- data/vendor/kreuzberg/tests/config_integration_test.rs +0 -753
- data/vendor/kreuzberg/tests/data/hierarchy_ground_truth.json +0 -294
- data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +0 -500
- data/vendor/kreuzberg/tests/docx_vs_pandoc_comparison.rs +0 -370
- data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +0 -275
- data/vendor/kreuzberg/tests/fictionbook_extractor_tests.rs +0 -228
- data/vendor/kreuzberg/tests/html_table_test.rs +0 -551
- data/vendor/kreuzberg/tests/instrumentation_test.rs +0 -139
- data/vendor/kreuzberg/tests/jats_extractor_tests.rs +0 -639
- data/vendor/kreuzberg/tests/jupyter_extractor_tests.rs +0 -704
- data/vendor/kreuzberg/tests/latex_extractor_tests.rs +0 -496
- data/vendor/kreuzberg/tests/markdown_extractor_tests.rs +0 -490
- data/vendor/kreuzberg/tests/ocr_language_registry.rs +0 -191
- data/vendor/kreuzberg/tests/odt_extractor_tests.rs +0 -674
- data/vendor/kreuzberg/tests/opml_extractor_tests.rs +0 -616
- data/vendor/kreuzberg/tests/orgmode_extractor_tests.rs +0 -822
- data/vendor/kreuzberg/tests/page_markers.rs +0 -297
- data/vendor/kreuzberg/tests/pdf_hierarchy_detection.rs +0 -301
- data/vendor/kreuzberg/tests/pdf_hierarchy_quality.rs +0 -589
- data/vendor/kreuzberg/tests/pdf_ocr_triggering.rs +0 -301
- data/vendor/kreuzberg/tests/pdf_text_merging.rs +0 -475
- data/vendor/kreuzberg/tests/pdfium_linking.rs +0 -340
- data/vendor/kreuzberg/tests/rst_extractor_tests.rs +0 -694
- data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -775
- data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +0 -1260
- data/vendor/kreuzberg/tests/typst_extractor_tests.rs +0 -648
- data/vendor/kreuzberg-ffi/Cargo.toml +0 -67
- data/vendor/kreuzberg-ffi/README.md +0 -851
- data/vendor/kreuzberg-ffi/benches/result_view_benchmark.rs +0 -227
- data/vendor/kreuzberg-ffi/build.rs +0 -168
- data/vendor/kreuzberg-ffi/cbindgen.toml +0 -37
- data/vendor/kreuzberg-ffi/kreuzberg-ffi.pc.in +0 -12
- data/vendor/kreuzberg-ffi/kreuzberg.h +0 -3012
- data/vendor/kreuzberg-ffi/src/batch_streaming.rs +0 -588
- data/vendor/kreuzberg-ffi/src/config.rs +0 -1341
- data/vendor/kreuzberg-ffi/src/error.rs +0 -901
- data/vendor/kreuzberg-ffi/src/extraction.rs +0 -555
- data/vendor/kreuzberg-ffi/src/helpers.rs +0 -879
- data/vendor/kreuzberg-ffi/src/lib.rs +0 -977
- data/vendor/kreuzberg-ffi/src/memory.rs +0 -493
- data/vendor/kreuzberg-ffi/src/mime.rs +0 -329
- data/vendor/kreuzberg-ffi/src/panic_shield.rs +0 -265
- data/vendor/kreuzberg-ffi/src/plugins/document_extractor.rs +0 -442
- data/vendor/kreuzberg-ffi/src/plugins/mod.rs +0 -14
- data/vendor/kreuzberg-ffi/src/plugins/ocr_backend.rs +0 -628
- data/vendor/kreuzberg-ffi/src/plugins/post_processor.rs +0 -438
- data/vendor/kreuzberg-ffi/src/plugins/validator.rs +0 -329
- data/vendor/kreuzberg-ffi/src/result.rs +0 -510
- data/vendor/kreuzberg-ffi/src/result_pool.rs +0 -639
- data/vendor/kreuzberg-ffi/src/result_view.rs +0 -773
- data/vendor/kreuzberg-ffi/src/string_intern.rs +0 -568
- data/vendor/kreuzberg-ffi/src/types.rs +0 -363
- data/vendor/kreuzberg-ffi/src/util.rs +0 -210
- data/vendor/kreuzberg-ffi/src/validation.rs +0 -848
- data/vendor/kreuzberg-ffi/tests.disabled/README.md +0 -48
- data/vendor/kreuzberg-ffi/tests.disabled/config_loading_tests.rs +0 -299
- data/vendor/kreuzberg-ffi/tests.disabled/config_tests.rs +0 -346
- data/vendor/kreuzberg-ffi/tests.disabled/extractor_tests.rs +0 -232
- data/vendor/kreuzberg-ffi/tests.disabled/plugin_registration_tests.rs +0 -470
- data/vendor/kreuzberg-tesseract/.commitlintrc.json +0 -13
- data/vendor/kreuzberg-tesseract/.crate-ignore +0 -2
- data/vendor/kreuzberg-tesseract/Cargo.lock +0 -2933
- data/vendor/kreuzberg-tesseract/Cargo.toml +0 -57
- data/vendor/kreuzberg-tesseract/LICENSE +0 -22
- data/vendor/kreuzberg-tesseract/README.md +0 -399
- data/vendor/kreuzberg-tesseract/build.rs +0 -1127
- data/vendor/kreuzberg-tesseract/patches/README.md +0 -71
- data/vendor/kreuzberg-tesseract/patches/tesseract.diff +0 -199
- data/vendor/kreuzberg-tesseract/src/api.rs +0 -1371
- data/vendor/kreuzberg-tesseract/src/choice_iterator.rs +0 -77
- data/vendor/kreuzberg-tesseract/src/enums.rs +0 -297
- data/vendor/kreuzberg-tesseract/src/error.rs +0 -81
- data/vendor/kreuzberg-tesseract/src/lib.rs +0 -145
- data/vendor/kreuzberg-tesseract/src/monitor.rs +0 -57
- data/vendor/kreuzberg-tesseract/src/mutable_iterator.rs +0 -197
- data/vendor/kreuzberg-tesseract/src/page_iterator.rs +0 -253
- data/vendor/kreuzberg-tesseract/src/result_iterator.rs +0 -286
- data/vendor/kreuzberg-tesseract/src/result_renderer.rs +0 -183
- data/vendor/kreuzberg-tesseract/tests/integration_test.rs +0 -211
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'json'
|
|
4
|
-
|
|
5
|
-
module Kreuzberg
|
|
6
|
-
module ErrorContext
|
|
7
|
-
class << self
|
|
8
|
-
# @return [Integer] Error code constant (ERROR_CODE_* values), or 0 on success
|
|
9
|
-
# @example Check last error
|
|
10
|
-
def last_error_code
|
|
11
|
-
Kreuzberg._last_error_code_native
|
|
12
|
-
rescue StandardError
|
|
13
|
-
0
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Get panic context information from the last error.
|
|
17
|
-
#
|
|
18
|
-
# Returns a {Errors::PanicContext} object containing detailed information about
|
|
19
|
-
# the last panic that occurred in the Rust core. Includes file path, line number,
|
|
20
|
-
# function name, error message, and timestamp.
|
|
21
|
-
#
|
|
22
|
-
# @return [Errors::PanicContext, nil] Panic context if a panic occurred, nil otherwise
|
|
23
|
-
#
|
|
24
|
-
# @example Get panic details
|
|
25
|
-
# panic = Kreuzberg::ErrorContext.last_panic_context
|
|
26
|
-
# if panic
|
|
27
|
-
# puts "Panic at #{panic.file}:#{panic.line} in #{panic.function}"
|
|
28
|
-
# puts "Message: #{panic.message}"
|
|
29
|
-
# puts "Time: #{panic.timestamp_secs}"
|
|
30
|
-
# end
|
|
31
|
-
def last_panic_context
|
|
32
|
-
json_str = Kreuzberg._last_panic_context_json_native
|
|
33
|
-
return nil unless json_str
|
|
34
|
-
|
|
35
|
-
Errors::PanicContext.from_json(json_str)
|
|
36
|
-
rescue StandardError
|
|
37
|
-
nil
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Get panic context as raw JSON string.
|
|
41
|
-
#
|
|
42
|
-
# Returns the panic context information as a JSON string for raw access or
|
|
43
|
-
# custom parsing. Returns nil if no panic has occurred.
|
|
44
|
-
#
|
|
45
|
-
# @return [String, nil] JSON-serialized panic context, or nil if no panic
|
|
46
|
-
#
|
|
47
|
-
# @example Get raw JSON panic context
|
|
48
|
-
# json = Kreuzberg::ErrorContext.last_panic_context_json
|
|
49
|
-
# if json
|
|
50
|
-
# panic_data = JSON.parse(json)
|
|
51
|
-
# puts panic_data
|
|
52
|
-
# end
|
|
53
|
-
def last_panic_context_json
|
|
54
|
-
Kreuzberg._last_panic_context_json_native
|
|
55
|
-
rescue StandardError
|
|
56
|
-
nil
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Get detailed error information from the last operation.
|
|
60
|
-
#
|
|
61
|
-
# Returns comprehensive error details including message, code, type, source location,
|
|
62
|
-
# and panic information.
|
|
63
|
-
#
|
|
64
|
-
# @return [Hash] Hash with keys: :message, :error_code, :error_type, :source_file,
|
|
65
|
-
# :source_function, :source_line, :context_info, :is_panic
|
|
66
|
-
#
|
|
67
|
-
# @example Get error details
|
|
68
|
-
# details = Kreuzberg::ErrorContext.error_details
|
|
69
|
-
# puts "Error: #{details[:message]}"
|
|
70
|
-
# puts "Code: #{details[:error_code]}"
|
|
71
|
-
# puts "Type: #{details[:error_type]}"
|
|
72
|
-
def error_details
|
|
73
|
-
Kreuzberg._get_error_details_native
|
|
74
|
-
rescue StandardError
|
|
75
|
-
{}
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Classify an error message into a Kreuzberg error code.
|
|
79
|
-
#
|
|
80
|
-
# Analyzes an error message and returns the most likely error code (0-7).
|
|
81
|
-
# Useful for converting third-party error messages into Kreuzberg categories.
|
|
82
|
-
#
|
|
83
|
-
# @param message [String] The error message to classify
|
|
84
|
-
# @return [Integer] Error code (0-7)
|
|
85
|
-
#
|
|
86
|
-
# Error code mapping:
|
|
87
|
-
# - 0: Validation
|
|
88
|
-
# - 1: Parsing
|
|
89
|
-
# - 2: OCR
|
|
90
|
-
# - 3: MissingDependency
|
|
91
|
-
# - 4: IO
|
|
92
|
-
# - 5: Plugin
|
|
93
|
-
# - 6: UnsupportedFormat
|
|
94
|
-
# - 7: Internal
|
|
95
|
-
#
|
|
96
|
-
# @example Classify an error
|
|
97
|
-
# code = Kreuzberg::ErrorContext.classify_error("File not found")
|
|
98
|
-
# if code == 4
|
|
99
|
-
# puts "This is an I/O error"
|
|
100
|
-
# end
|
|
101
|
-
def classify_error(message)
|
|
102
|
-
Kreuzberg._classify_error_native(message)
|
|
103
|
-
rescue StandardError
|
|
104
|
-
7
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# Get the human-readable name of an error code.
|
|
108
|
-
#
|
|
109
|
-
# @param code [Integer] Numeric error code (0-7)
|
|
110
|
-
# @return [String] Human-readable error code name (e.g., "validation", "io")
|
|
111
|
-
#
|
|
112
|
-
# @example Get error code name
|
|
113
|
-
# name = Kreuzberg::ErrorContext.error_code_name(0)
|
|
114
|
-
# puts name # => "validation"
|
|
115
|
-
def error_code_name(code)
|
|
116
|
-
Kreuzberg._error_code_name_native(code)
|
|
117
|
-
rescue StandardError
|
|
118
|
-
'unknown'
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# Get the description of an error code.
|
|
122
|
-
#
|
|
123
|
-
# @param code [Integer] Numeric error code (0-7)
|
|
124
|
-
# @return [String] Description of the error code
|
|
125
|
-
#
|
|
126
|
-
# @example Get error code description
|
|
127
|
-
# desc = Kreuzberg::ErrorContext.error_code_description(0)
|
|
128
|
-
# puts desc # => "Input validation error"
|
|
129
|
-
def error_code_description(code)
|
|
130
|
-
Kreuzberg._error_code_description_native(code)
|
|
131
|
-
rescue StandardError
|
|
132
|
-
'Unknown error code'
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
data/lib/kreuzberg/types.rb
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'sorbet-runtime'
|
|
4
|
-
|
|
5
|
-
module Kreuzberg
|
|
6
|
-
# @example
|
|
7
|
-
class HtmlMetadata < T::Struct
|
|
8
|
-
extend T::Sig
|
|
9
|
-
|
|
10
|
-
const :title, T.nilable(String)
|
|
11
|
-
|
|
12
|
-
const :description, T.nilable(String)
|
|
13
|
-
|
|
14
|
-
const :author, T.nilable(String)
|
|
15
|
-
|
|
16
|
-
const :copyright, T.nilable(String)
|
|
17
|
-
|
|
18
|
-
const :keywords, T::Array[String]
|
|
19
|
-
|
|
20
|
-
const :canonical_url, T.nilable(String)
|
|
21
|
-
|
|
22
|
-
const :language, T.nilable(String)
|
|
23
|
-
|
|
24
|
-
const :text_direction, T.nilable(String)
|
|
25
|
-
|
|
26
|
-
const :mime_type, T.nilable(String)
|
|
27
|
-
|
|
28
|
-
const :charset, T.nilable(String)
|
|
29
|
-
|
|
30
|
-
const :generator, T.nilable(String)
|
|
31
|
-
|
|
32
|
-
const :viewport, T.nilable(String)
|
|
33
|
-
|
|
34
|
-
const :theme_color, T.nilable(String)
|
|
35
|
-
|
|
36
|
-
const :application_name, T.nilable(String)
|
|
37
|
-
|
|
38
|
-
const :robots, T.nilable(String)
|
|
39
|
-
|
|
40
|
-
const :open_graph, T::Hash[String, String]
|
|
41
|
-
|
|
42
|
-
const :twitter_card, T::Hash[String, String]
|
|
43
|
-
|
|
44
|
-
const :meta_tags, T::Hash[String, String]
|
|
45
|
-
|
|
46
|
-
const :headers, T::Array[HeaderMetadata]
|
|
47
|
-
|
|
48
|
-
const :links, T::Array[LinkMetadata]
|
|
49
|
-
|
|
50
|
-
const :images, T::Array[ImageMetadata]
|
|
51
|
-
|
|
52
|
-
const :structured_data, T::Array[StructuredData]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Header/Heading metadata
|
|
56
|
-
#
|
|
57
|
-
# Represents a heading element found in the HTML document
|
|
58
|
-
#
|
|
59
|
-
# @example
|
|
60
|
-
# header = Kreuzberg::HeaderMetadata.new(
|
|
61
|
-
# level: 1,
|
|
62
|
-
# text: "Main Title",
|
|
63
|
-
# id: "main-title",
|
|
64
|
-
# depth: 0,
|
|
65
|
-
# html_offset: 245
|
|
66
|
-
# )
|
|
67
|
-
# puts "#{header.text} (H#{header.level})"
|
|
68
|
-
#
|
|
69
|
-
class HeaderMetadata < T::Struct
|
|
70
|
-
extend T::Sig
|
|
71
|
-
|
|
72
|
-
const :level, Integer
|
|
73
|
-
|
|
74
|
-
const :text, String
|
|
75
|
-
|
|
76
|
-
const :id, T.nilable(String)
|
|
77
|
-
|
|
78
|
-
const :depth, Integer
|
|
79
|
-
|
|
80
|
-
const :html_offset, Integer
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Link metadata
|
|
84
|
-
#
|
|
85
|
-
# Represents a link element found in the HTML document
|
|
86
|
-
#
|
|
87
|
-
# @example
|
|
88
|
-
# link = Kreuzberg::LinkMetadata.new(
|
|
89
|
-
# href: "https://example.com",
|
|
90
|
-
# text: "Example",
|
|
91
|
-
# title: "Example Site",
|
|
92
|
-
# link_type: "external",
|
|
93
|
-
# rel: ["noopener", "noreferrer"],
|
|
94
|
-
# attributes: { "data-id" => "123" }
|
|
95
|
-
# )
|
|
96
|
-
# puts "#{link.text} -> #{link.href}"
|
|
97
|
-
#
|
|
98
|
-
class LinkMetadata < T::Struct
|
|
99
|
-
extend T::Sig
|
|
100
|
-
|
|
101
|
-
const :href, String
|
|
102
|
-
|
|
103
|
-
const :text, String
|
|
104
|
-
|
|
105
|
-
const :title, T.nilable(String)
|
|
106
|
-
|
|
107
|
-
const :link_type, String
|
|
108
|
-
|
|
109
|
-
const :rel, T::Array[String]
|
|
110
|
-
|
|
111
|
-
const :attributes, T::Hash[String, String]
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# Image metadata
|
|
115
|
-
#
|
|
116
|
-
# Represents an image element found in the HTML document
|
|
117
|
-
#
|
|
118
|
-
# @example
|
|
119
|
-
# image = Kreuzberg::ImageMetadata.new(
|
|
120
|
-
# src: "images/logo.png",
|
|
121
|
-
# alt: "Company Logo",
|
|
122
|
-
# title: nil,
|
|
123
|
-
# dimensions: [200, 100],
|
|
124
|
-
# image_type: "png",
|
|
125
|
-
# attributes: { "loading" => "lazy" }
|
|
126
|
-
# )
|
|
127
|
-
# if image.dimensions
|
|
128
|
-
# width, height = image.dimensions
|
|
129
|
-
# puts "#{width}x#{height}"
|
|
130
|
-
# end
|
|
131
|
-
#
|
|
132
|
-
class ImageMetadata < T::Struct
|
|
133
|
-
extend T::Sig
|
|
134
|
-
|
|
135
|
-
const :src, String
|
|
136
|
-
|
|
137
|
-
const :alt, T.nilable(String)
|
|
138
|
-
|
|
139
|
-
const :title, T.nilable(String)
|
|
140
|
-
|
|
141
|
-
const :dimensions, T.nilable(T::Array[Integer])
|
|
142
|
-
|
|
143
|
-
const :image_type, String
|
|
144
|
-
|
|
145
|
-
const :attributes, T::Hash[String, String]
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
# Structured data metadata
|
|
149
|
-
#
|
|
150
|
-
# Represents structured data (JSON-LD, microdata, etc.) found in the HTML document
|
|
151
|
-
#
|
|
152
|
-
# @example
|
|
153
|
-
# structured = Kreuzberg::StructuredData.new(
|
|
154
|
-
# data_type: "json-ld",
|
|
155
|
-
# raw_json: '{"@context":"https://schema.org","@type":"Article",...}',
|
|
156
|
-
# schema_type: "Article"
|
|
157
|
-
# )
|
|
158
|
-
# data = JSON.parse(structured.raw_json)
|
|
159
|
-
# puts data['@type']
|
|
160
|
-
#
|
|
161
|
-
class StructuredData < T::Struct
|
|
162
|
-
extend T::Sig
|
|
163
|
-
|
|
164
|
-
const :data_type, String
|
|
165
|
-
|
|
166
|
-
const :raw_json, String
|
|
167
|
-
|
|
168
|
-
const :schema_type, T.nilable(String)
|
|
169
|
-
end
|
|
170
|
-
end
|
data/lib/libpdfium.so
DELETED
|
Binary file
|