kreuzberg 4.9.8-aarch64-linux → 4.10.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.
- checksums.yaml +4 -4
- data/README.md +26 -22
- data/lib/kreuzberg/api_proxy.rb +23 -14
- data/lib/kreuzberg/cache_api.rb +4 -4
- data/lib/kreuzberg/cli.rb +8 -10
- data/lib/kreuzberg/cli_proxy.rb +23 -17
- data/lib/kreuzberg/config.rb +219 -128
- data/lib/kreuzberg/djot_content.rb +41 -50
- data/lib/kreuzberg/document_structure.rb +24 -36
- data/lib/kreuzberg/error_context.rb +3 -3
- data/lib/kreuzberg/errors.rb +17 -10
- data/lib/kreuzberg/extraction_api.rb +11 -12
- data/lib/kreuzberg/mcp_proxy.rb +29 -21
- data/lib/kreuzberg/result.rb +165 -135
- data/lib/kreuzberg/setup_lib_path.rb +33 -31
- data/lib/kreuzberg/types.rb +53 -61
- data/lib/kreuzberg/version.rb +1 -1
- data/lib/kreuzberg.rb +36 -36
- data/lib/kreuzberg_rb.so +0 -0
- data/sig/kreuzberg/internal.rbs +106 -106
- data/sig/kreuzberg.rbs +1488 -1488
- data/spec/binding/async_operations_spec.rb +140 -145
- data/spec/binding/batch_operations_spec.rb +189 -197
- data/spec/binding/batch_spec.rb +113 -105
- data/spec/binding/cache_spec.rb +60 -59
- data/spec/binding/cli_proxy_spec.rb +43 -41
- data/spec/binding/cli_spec.rb +27 -27
- data/spec/binding/config_spec.rb +198 -194
- data/spec/binding/config_validation_spec.rb +164 -160
- data/spec/binding/embeddings_spec.rb +56 -56
- data/spec/binding/error_handling_spec.rb +167 -170
- data/spec/binding/error_recovery_spec.rb +169 -165
- data/spec/binding/errors_spec.rb +27 -26
- data/spec/binding/font_config_spec.rb +90 -90
- data/spec/binding/images_spec.rb +54 -53
- data/spec/binding/keywords_extraction_spec.rb +19 -19
- data/spec/binding/pages_extraction_spec.rb +41 -41
- data/spec/binding/plugins/ocr_backend_spec.rb +85 -81
- data/spec/binding/plugins/postprocessor_spec.rb +95 -91
- data/spec/binding/plugins/validator_spec.rb +99 -95
- data/spec/binding/render_spec.rb +44 -44
- data/spec/binding/tables_spec.rb +56 -56
- data/spec/spec_helper.rb +23 -21
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8fb1a96cb76dcec11ffe0234731caa27c7f57fbb179344f25034e18796878364
|
|
4
|
+
data.tar.gz: 74b7250dbe911a6e9d7efbbe3c2c5e2d0214efcf63090ebd49c9e3da031a9c3c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 625218f0138fb6daa5382023bbbc7b85d808db250948849dc84b5bd93815d64c760b070bdee682b6fde02f4e026b117d385714fc8e2012798638f5887d7eb2ea
|
|
7
|
+
data.tar.gz: 993598fa7423d7be60e648d7bc9cc6f64181ff7c16b2221caa692f89c0cd35bdf520f79bae622f1d0f6b8986245e26abefac800984631a25dfc058ee25dafce6
|
data/README.md
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
<a href="https://central.sonatype.com/artifact/dev.kreuzberg/kreuzberg">
|
|
22
22
|
<img src="https://img.shields.io/maven-central/v/dev.kreuzberg/kreuzberg?label=Java&color=007ec6" alt="Java">
|
|
23
23
|
</a>
|
|
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
|
|
24
|
+
<a href="https://github.com/kreuzberg-dev/kreuzberg-lts/releases">
|
|
25
|
+
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg-lts?label=Go&color=007ec6&filter=v4.*" 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#">
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<a href="https://kreuzberg-dev.r-universe.dev/kreuzberg">
|
|
37
37
|
<img src="https://img.shields.io/badge/R-kreuzberg-007ec6" alt="R">
|
|
38
38
|
</a>
|
|
39
|
-
<a href="https://github.com/kreuzberg-dev/kreuzberg/pkgs/container/kreuzberg">
|
|
39
|
+
<a href="https://github.com/kreuzberg-dev/kreuzberg-lts/pkgs/container/kreuzberg">
|
|
40
40
|
<img src="https://img.shields.io/badge/Docker-007ec6?logo=docker&logoColor=white" alt="Docker">
|
|
41
41
|
</a>
|
|
42
42
|
<a href="https://artifacthub.io/packages/search?repo=kreuzberg">
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
</a>
|
|
45
45
|
|
|
46
46
|
<!-- Project Info -->
|
|
47
|
-
<a href="https://github.com/kreuzberg-dev/kreuzberg/blob/main/LICENSE">
|
|
47
|
+
<a href="https://github.com/kreuzberg-dev/kreuzberg-lts/blob/main/LICENSE">
|
|
48
48
|
<img src="https://img.shields.io/badge/License-MIT-007ec6" alt="License">
|
|
49
49
|
</a>
|
|
50
50
|
<a href="https://docs.kreuzberg.dev">
|
|
@@ -58,7 +58,11 @@
|
|
|
58
58
|
</a>
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
> [!NOTE]
|
|
62
|
+
> **Kreuzberg v4 LTS** — the long-term-support line for Kreuzberg **v4**. Active development has moved to
|
|
63
|
+
> **[Xberg](https://github.com/xberg-io/xberg)** (v5+), which receives all new features. This line receives
|
|
64
|
+
> critical bug and security fixes until the **end of 2026, on a best-effort basis**.
|
|
65
|
+
> See the **[migration guide & LTS policy →](https://docs.kreuzberg.dev/lts/)**
|
|
62
66
|
|
|
63
67
|
<div align="center" style="margin-top: 20px;">
|
|
64
68
|
<a href="https://discord.gg/xt9WY3GnKR">
|
|
@@ -163,7 +167,7 @@ puts "Used OCR backend: tesseract"
|
|
|
163
167
|
#### Table Extraction
|
|
164
168
|
|
|
165
169
|
|
|
166
|
-
See [Table Extraction Guide](https://kreuzberg.dev/features/table-extraction/) for detailed examples.
|
|
170
|
+
See [Table Extraction Guide](https://docs.kreuzberg.dev/features/table-extraction/) for detailed examples.
|
|
167
171
|
|
|
168
172
|
|
|
169
173
|
|
|
@@ -210,10 +214,10 @@ puts "Processing time: #{result.metadata&.dig('processing_time')}ms"
|
|
|
210
214
|
|
|
211
215
|
### Next Steps
|
|
212
216
|
|
|
213
|
-
- **[Installation Guide](https://kreuzberg.dev/getting-started/installation/)** - Platform-specific setup
|
|
214
|
-
- **[API Documentation](https://kreuzberg.dev/api/)** - Complete API reference
|
|
215
|
-
- **[Examples & Guides](https://kreuzberg.dev/guides/)** - Full code examples and usage guides
|
|
216
|
-
- **[Configuration Guide](https://kreuzberg.dev/guides/configuration/)** - Advanced configuration options
|
|
217
|
+
- **[Installation Guide](https://docs.kreuzberg.dev/getting-started/installation/)** - Platform-specific setup
|
|
218
|
+
- **[API Documentation](https://docs.kreuzberg.dev/api/)** - Complete API reference
|
|
219
|
+
- **[Examples & Guides](https://docs.kreuzberg.dev/guides/)** - Full code examples and usage guides
|
|
220
|
+
- **[Configuration Guide](https://docs.kreuzberg.dev/guides/configuration/)** - Advanced configuration options
|
|
217
221
|
|
|
218
222
|
|
|
219
223
|
|
|
@@ -277,9 +281,9 @@ puts "Processing time: #{result.metadata&.dig('processing_time')}ms"
|
|
|
277
281
|
| **Diagnostics** | Parse errors with line/column positions |
|
|
278
282
|
| **Syntax-Aware Chunking** | Split code by semantic boundaries, not arbitrary byte offsets |
|
|
279
283
|
|
|
280
|
-
Powered by [tree-sitter-language-pack](https://github.com/
|
|
284
|
+
Powered by [tree-sitter-language-pack](https://github.com/xberg-io/tree-sitter-language-pack) — [documentation](https://docs.tree-sitter-language-pack.xberg.io).
|
|
281
285
|
|
|
282
|
-
**[Complete Format Reference](https://kreuzberg.dev/reference/formats/)**
|
|
286
|
+
**[Complete Format Reference](https://docs.kreuzberg.dev/reference/formats/)**
|
|
283
287
|
|
|
284
288
|
### Key Capabilities
|
|
285
289
|
|
|
@@ -301,7 +305,7 @@ Powered by [tree-sitter-language-pack](https://github.com/kreuzberg-dev/tree-sit
|
|
|
301
305
|
- **Memory Efficient** - Stream large files without loading entirely into memory
|
|
302
306
|
- **Language Detection** - Detect and support multiple languages in documents
|
|
303
307
|
|
|
304
|
-
- **Code Intelligence** - Extract structure, imports, exports, symbols, and docstrings from [248 programming languages](https://docs.tree-sitter-language-pack.
|
|
308
|
+
- **Code Intelligence** - Extract structure, imports, exports, symbols, and docstrings from [248 programming languages](https://docs.tree-sitter-language-pack.xberg.io) via tree-sitter
|
|
305
309
|
|
|
306
310
|
- **Configuration** - Fine-grained control over extraction behavior
|
|
307
311
|
|
|
@@ -374,7 +378,7 @@ puts "Processing time: #{result.metadata&.dig('processing_time')}ms"
|
|
|
374
378
|
|
|
375
379
|
Kreuzberg supports extensible post-processing plugins for custom text transformation and filtering.
|
|
376
380
|
|
|
377
|
-
For detailed plugin documentation, visit [Plugin System Guide](https://kreuzberg.dev/guides/plugins/).
|
|
381
|
+
For detailed plugin documentation, visit [Plugin System Guide](https://docs.kreuzberg.dev/guides/plugins/).
|
|
378
382
|
|
|
379
383
|
|
|
380
384
|
|
|
@@ -383,7 +387,7 @@ For detailed plugin documentation, visit [Plugin System Guide](https://kreuzberg
|
|
|
383
387
|
|
|
384
388
|
Generate vector embeddings for extracted text using the built-in ONNX Runtime support. Requires ONNX Runtime installation.
|
|
385
389
|
|
|
386
|
-
**[Embeddings Guide](https://kreuzberg.dev/features/#embeddings)**
|
|
390
|
+
**[Embeddings Guide](https://docs.kreuzberg.dev/features/#embeddings)**
|
|
387
391
|
|
|
388
392
|
|
|
389
393
|
|
|
@@ -408,17 +412,17 @@ puts "Installation verified! Extracted #{result.content.length} characters"
|
|
|
408
412
|
|
|
409
413
|
For advanced configuration options including language detection, table extraction, OCR settings, and more:
|
|
410
414
|
|
|
411
|
-
**[Configuration Guide](https://kreuzberg.dev/guides/configuration/)**
|
|
415
|
+
**[Configuration Guide](https://docs.kreuzberg.dev/guides/configuration/)**
|
|
412
416
|
|
|
413
417
|
## Documentation
|
|
414
418
|
|
|
415
|
-
- **[Official Documentation](https://kreuzberg.dev/)**
|
|
416
|
-
- **[API Reference](https://kreuzberg.dev/reference/api-ruby/)**
|
|
417
|
-
- **[Examples & Guides](https://kreuzberg.dev/guides/)**
|
|
419
|
+
- **[Official Documentation](https://docs.kreuzberg.dev/)**
|
|
420
|
+
- **[API Reference](https://docs.kreuzberg.dev/reference/api-ruby/)**
|
|
421
|
+
- **[Examples & Guides](https://docs.kreuzberg.dev/guides/)**
|
|
418
422
|
|
|
419
423
|
## Contributing
|
|
420
424
|
|
|
421
|
-
Contributions are welcome! See [Contributing Guide](https://github.com/kreuzberg-dev/kreuzberg/blob/main/CONTRIBUTING.md).
|
|
425
|
+
Contributions are welcome! See [Contributing Guide](https://github.com/kreuzberg-dev/kreuzberg-lts/blob/main/CONTRIBUTING.md).
|
|
422
426
|
|
|
423
427
|
## License
|
|
424
428
|
|
|
@@ -427,5 +431,5 @@ MIT License - see LICENSE file for details.
|
|
|
427
431
|
## Support
|
|
428
432
|
|
|
429
433
|
- **Discord Community**: [Join our Discord](https://discord.gg/xt9WY3GnKR)
|
|
430
|
-
- **GitHub Issues**: [Report bugs](https://github.com/kreuzberg-dev/kreuzberg/issues)
|
|
431
|
-
- **Discussions**: [Ask questions](https://github.com/kreuzberg-dev/kreuzberg/discussions)
|
|
434
|
+
- **GitHub Issues**: [Report bugs](https://github.com/kreuzberg-dev/kreuzberg-lts/issues)
|
|
435
|
+
- **Discussions**: [Ask questions](https://github.com/kreuzberg-dev/kreuzberg-lts/discussions)
|
data/lib/kreuzberg/api_proxy.rb
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "open3"
|
|
4
4
|
|
|
5
5
|
module Kreuzberg
|
|
6
6
|
# @example Start the server
|
|
7
7
|
# @example With block
|
|
8
8
|
module APIProxy
|
|
9
|
-
class Error < Kreuzberg::Errors::Error
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
class Error < Kreuzberg::Errors::Error
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class MissingBinaryError < Error
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ServerError < Error
|
|
16
|
+
end
|
|
12
17
|
|
|
13
18
|
# API server instance
|
|
14
19
|
class Server
|
|
@@ -19,7 +24,7 @@ module Kreuzberg
|
|
|
19
24
|
# @param port [Integer] Port to run on (default: 8000)
|
|
20
25
|
# @param host [String] Host to bind to (default: "0.0.0.0")
|
|
21
26
|
#
|
|
22
|
-
def initialize(port: 8000, host:
|
|
27
|
+
def initialize(port: 8000, host: "0.0.0.0")
|
|
23
28
|
@port = port
|
|
24
29
|
@host = host
|
|
25
30
|
@pid = nil
|
|
@@ -35,14 +40,16 @@ module Kreuzberg
|
|
|
35
40
|
binary = APIProxy.find_api_binary
|
|
36
41
|
@pid = spawn(
|
|
37
42
|
binary.to_s,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
"api",
|
|
44
|
+
"--host",
|
|
45
|
+
@host,
|
|
46
|
+
"--port",
|
|
47
|
+
@port.to_s,
|
|
41
48
|
out: $stdout,
|
|
42
49
|
err: $stderr
|
|
43
50
|
)
|
|
44
51
|
Process.detach(@pid)
|
|
45
|
-
sleep
|
|
52
|
+
sleep(1)
|
|
46
53
|
@pid
|
|
47
54
|
end
|
|
48
55
|
|
|
@@ -53,9 +60,10 @@ module Kreuzberg
|
|
|
53
60
|
def stop
|
|
54
61
|
return unless @pid
|
|
55
62
|
|
|
56
|
-
Process.kill(
|
|
63
|
+
Process.kill("TERM", @pid)
|
|
57
64
|
Process.wait(@pid)
|
|
58
|
-
|
|
65
|
+
# rubocop:disable Lint/SuppressedException
|
|
66
|
+
rescue Errno::ESRCH, Errno::ECHILD
|
|
59
67
|
ensure
|
|
60
68
|
@pid = nil
|
|
61
69
|
end
|
|
@@ -88,7 +96,7 @@ module Kreuzberg
|
|
|
88
96
|
# # Make API requests
|
|
89
97
|
# end
|
|
90
98
|
#
|
|
91
|
-
def run(port: 8000, host:
|
|
99
|
+
def run(port: 8000, host: "0.0.0.0")
|
|
92
100
|
server = Server.new(port: port, host: host)
|
|
93
101
|
server.start
|
|
94
102
|
yield server
|
|
@@ -102,7 +110,7 @@ module Kreuzberg
|
|
|
102
110
|
# @raise [MissingBinaryError] If not found
|
|
103
111
|
#
|
|
104
112
|
def find_api_binary
|
|
105
|
-
binary_name = Gem.win_platform? ?
|
|
113
|
+
binary_name = Gem.win_platform? ? "kreuzberg.exe" : "kreuzberg"
|
|
106
114
|
found = CLIProxy.search_paths(binary_name).find(&:file?)
|
|
107
115
|
return found if found
|
|
108
116
|
|
|
@@ -114,12 +122,13 @@ module Kreuzberg
|
|
|
114
122
|
# @return [String]
|
|
115
123
|
#
|
|
116
124
|
def missing_binary_message
|
|
117
|
-
<<~MSG
|
|
125
|
+
<<~MSG
|
|
118
126
|
kreuzberg binary not found for API server. Build it with:
|
|
119
127
|
`cargo build --release --package kreuzberg-cli`
|
|
120
128
|
|
|
121
129
|
Or ensure kreuzberg is installed with API support.
|
|
122
130
|
MSG
|
|
131
|
+
.strip
|
|
123
132
|
end
|
|
124
133
|
end
|
|
125
134
|
end
|
data/lib/kreuzberg/cache_api.rb
CHANGED
|
@@ -31,12 +31,12 @@ module Kreuzberg
|
|
|
31
31
|
# end
|
|
32
32
|
def cache_stats
|
|
33
33
|
stats = native_cache_stats
|
|
34
|
-
total_entries = (stats[
|
|
35
|
-
total_size = (stats[
|
|
34
|
+
total_entries = (stats["total_entries"] || stats[:total_entries] || 0) + @__cache_tracker[:entries]
|
|
35
|
+
total_size = (stats["total_size_bytes"] || stats[:total_size_bytes] || 0) + @__cache_tracker[:bytes]
|
|
36
36
|
|
|
37
|
-
stats[
|
|
37
|
+
stats["total_entries"] = total_entries
|
|
38
38
|
stats[:total_entries] = total_entries
|
|
39
|
-
stats[
|
|
39
|
+
stats["total_size_bytes"] = total_size
|
|
40
40
|
stats[:total_size_bytes] = total_size
|
|
41
41
|
|
|
42
42
|
stats
|
data/lib/kreuzberg/cli.rb
CHANGED
|
@@ -14,13 +14,12 @@ module Kreuzberg
|
|
|
14
14
|
# @param ocr [Boolean] Enable OCR
|
|
15
15
|
# @return [String] Extracted content
|
|
16
16
|
#
|
|
17
|
-
def extract(path_or_nil = nil, path: nil, output:
|
|
18
|
-
# Support both positional and keyword argument for path (backward compatibility)
|
|
17
|
+
def extract(path_or_nil = nil, path: nil, output: "text", ocr: false)
|
|
19
18
|
actual_path = path_or_nil || path
|
|
20
|
-
raise ArgumentError,
|
|
19
|
+
raise ArgumentError, "path is required" if actual_path.nil?
|
|
21
20
|
|
|
22
|
-
args = [
|
|
23
|
-
args.push(
|
|
21
|
+
args = ["extract", actual_path, "--format", output]
|
|
22
|
+
args.push("--ocr", ocr ? "true" : "false")
|
|
24
23
|
CLIProxy.call(args)
|
|
25
24
|
end
|
|
26
25
|
|
|
@@ -31,11 +30,10 @@ module Kreuzberg
|
|
|
31
30
|
# @return [String] MIME type
|
|
32
31
|
#
|
|
33
32
|
def detect(path_or_nil = nil, path: nil)
|
|
34
|
-
# Support both positional and keyword argument for path (backward compatibility)
|
|
35
33
|
actual_path = path_or_nil || path
|
|
36
|
-
raise ArgumentError,
|
|
34
|
+
raise ArgumentError, "path is required" if actual_path.nil?
|
|
37
35
|
|
|
38
|
-
CLIProxy.call([
|
|
36
|
+
CLIProxy.call(["detect", actual_path]).strip
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
# Get CLI version
|
|
@@ -43,7 +41,7 @@ module Kreuzberg
|
|
|
43
41
|
# @return [String] Version string
|
|
44
42
|
#
|
|
45
43
|
def version
|
|
46
|
-
CLIProxy.call([
|
|
44
|
+
CLIProxy.call(["--version"]).strip
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
# Get CLI help text
|
|
@@ -51,7 +49,7 @@ module Kreuzberg
|
|
|
51
49
|
# @return [String] Help text
|
|
52
50
|
#
|
|
53
51
|
def help
|
|
54
|
-
CLIProxy.call([
|
|
52
|
+
CLIProxy.call(["--help"])
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
end
|
data/lib/kreuzberg/cli_proxy.rb
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "open3"
|
|
4
4
|
|
|
5
5
|
module Kreuzberg
|
|
6
6
|
# @example
|
|
7
7
|
module CLIProxy
|
|
8
|
-
class Error < Kreuzberg::Errors::Error
|
|
9
|
-
|
|
8
|
+
class Error < Kreuzberg::Errors::Error
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class MissingBinaryError < Error
|
|
12
|
+
end
|
|
10
13
|
|
|
11
14
|
# CLI execution error with stderr and exit status
|
|
12
15
|
class CLIExecutionError < Error
|
|
@@ -40,10 +43,12 @@ module Kreuzberg
|
|
|
40
43
|
stdout, stderr, status = Open3.capture3(binary.to_s, *args)
|
|
41
44
|
return stdout if status.success?
|
|
42
45
|
|
|
43
|
-
raise
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
raise(
|
|
47
|
+
CLIExecutionError.new(
|
|
48
|
+
"kreuzberg CLI exited with status #{status.exitstatus}",
|
|
49
|
+
stderr: stderr,
|
|
50
|
+
status: status.exitstatus
|
|
51
|
+
)
|
|
47
52
|
)
|
|
48
53
|
end
|
|
49
54
|
|
|
@@ -58,7 +63,7 @@ module Kreuzberg
|
|
|
58
63
|
# @raise [MissingBinaryError] If binary not found
|
|
59
64
|
#
|
|
60
65
|
def find_cli_binary
|
|
61
|
-
binary_name = Gem.win_platform? ?
|
|
66
|
+
binary_name = Gem.win_platform? ? "kreuzberg.exe" : "kreuzberg"
|
|
62
67
|
found = search_paths(binary_name).find(&:file?)
|
|
63
68
|
return found if found
|
|
64
69
|
|
|
@@ -70,7 +75,7 @@ module Kreuzberg
|
|
|
70
75
|
# @return [Pathname] Root path
|
|
71
76
|
#
|
|
72
77
|
def root_path
|
|
73
|
-
@root_path ||= Pathname(__dir__ ||
|
|
78
|
+
@root_path ||= Pathname(__dir__ || ".").join("../..").expand_path
|
|
74
79
|
end
|
|
75
80
|
|
|
76
81
|
# Get the lib path
|
|
@@ -78,7 +83,7 @@ module Kreuzberg
|
|
|
78
83
|
# @return [Pathname] Lib path
|
|
79
84
|
#
|
|
80
85
|
def lib_path
|
|
81
|
-
@lib_path ||= Pathname(__dir__ ||
|
|
86
|
+
@lib_path ||= Pathname(__dir__ || ".").join("..").expand_path
|
|
82
87
|
end
|
|
83
88
|
|
|
84
89
|
# Search paths for the CLI binary
|
|
@@ -88,16 +93,16 @@ module Kreuzberg
|
|
|
88
93
|
#
|
|
89
94
|
def search_paths(binary_name)
|
|
90
95
|
paths = [
|
|
91
|
-
lib_path.join(
|
|
96
|
+
lib_path.join("bin", binary_name),
|
|
92
97
|
lib_path.join(binary_name),
|
|
93
|
-
root_path.join(
|
|
94
|
-
root_path.join(
|
|
95
|
-
root_path.join(
|
|
98
|
+
root_path.join("../../crates/kreuzberg-cli/target/release", binary_name),
|
|
99
|
+
root_path.join("../../target/release", binary_name),
|
|
100
|
+
root_path.join("../../target/debug", binary_name)
|
|
96
101
|
]
|
|
97
102
|
|
|
98
103
|
workspace_root = root_path.parent&.parent
|
|
99
|
-
paths << workspace_root.join(
|
|
100
|
-
paths << workspace_root.join(
|
|
104
|
+
paths << workspace_root.join("target", "release", binary_name) if workspace_root
|
|
105
|
+
paths << workspace_root.join("target", "debug", binary_name) if workspace_root
|
|
101
106
|
|
|
102
107
|
paths
|
|
103
108
|
end
|
|
@@ -107,12 +112,13 @@ module Kreuzberg
|
|
|
107
112
|
# @return [String] Error message
|
|
108
113
|
#
|
|
109
114
|
def missing_binary_message
|
|
110
|
-
<<~MSG
|
|
115
|
+
<<~MSG
|
|
111
116
|
kreuzberg CLI binary not found. Build it with:
|
|
112
117
|
`cargo build --release --package kreuzberg-cli`
|
|
113
118
|
|
|
114
119
|
Or install the gem with pre-built binaries.
|
|
115
120
|
MSG
|
|
121
|
+
.strip
|
|
116
122
|
end
|
|
117
123
|
end
|
|
118
124
|
end
|