summarize-ruby 0.2.0 → 0.3.0
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/lib/summarize/client.rb +15 -0
- data/lib/summarize/configuration.rb +20 -1
- data/lib/summarize/errors.rb +13 -0
- data/lib/summarize/version.rb +2 -1
- data/lib/summarize.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 689430b84d46027bb3dfe7d7ab30c6ffd6a8627fdce5ca1540f718d41a384c18
|
|
4
|
+
data.tar.gz: 6a27144a61b00a3581f7495f3662c714df05ead4bf280fc83b5c3edb6a0ff3f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19e417b45e70c624c5103a767effe4359678e20053c162738ad27c5065cdd574f0a003f8c615badd82a953bb53288922aaba7df434f234f020b02a5d0c717423
|
|
7
|
+
data.tar.gz: 68bc215c350bb6ec0c6926936ac8bd57ce523e56de73be505da920c8f80026af6ae1e19aa376cc03fe2f23e67de1e33588bc6fb76aa37cfdf18fb253f4aa49e3
|
data/lib/summarize/client.rb
CHANGED
|
@@ -68,6 +68,8 @@ module Summarize
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def stream(input, **opts, &block)
|
|
71
|
+
validate_binary!
|
|
72
|
+
validate_version!
|
|
71
73
|
args = build_args(input, stream: true, json: false, **opts)
|
|
72
74
|
|
|
73
75
|
full_output = +""
|
|
@@ -134,6 +136,7 @@ module Summarize
|
|
|
134
136
|
|
|
135
137
|
def execute(args)
|
|
136
138
|
validate_binary!
|
|
139
|
+
validate_version!
|
|
137
140
|
|
|
138
141
|
Open3.capture3(command_env, *args)
|
|
139
142
|
end
|
|
@@ -146,6 +149,18 @@ module Summarize
|
|
|
146
149
|
raise BinaryNotFoundError, path
|
|
147
150
|
end
|
|
148
151
|
|
|
152
|
+
def validate_version!
|
|
153
|
+
return if config.skip_version_check
|
|
154
|
+
|
|
155
|
+
installed = config.cli_version
|
|
156
|
+
return unless installed # can't detect — skip gracefully
|
|
157
|
+
|
|
158
|
+
required = Summarize::MINIMUM_CLI_VERSION
|
|
159
|
+
if Gem::Version.new(installed) < Gem::Version.new(required)
|
|
160
|
+
raise VersionMismatchError.new(installed, required)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
149
164
|
def handle_error!(status, stderr)
|
|
150
165
|
case status.exitstatus
|
|
151
166
|
when 130
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
module Summarize
|
|
4
4
|
class Configuration
|
|
5
5
|
attr_accessor :default_model, :default_length, :default_language,
|
|
6
|
-
:default_cli, :timeout, :retries, :env
|
|
6
|
+
:default_cli, :timeout, :retries, :env,
|
|
7
|
+
:skip_version_check
|
|
7
8
|
attr_writer :binary_path
|
|
8
9
|
|
|
9
10
|
def initialize
|
|
@@ -15,14 +16,32 @@ module Summarize
|
|
|
15
16
|
@timeout = nil
|
|
16
17
|
@retries = nil
|
|
17
18
|
@env = {}
|
|
19
|
+
@skip_version_check = false
|
|
20
|
+
@cli_version = nil
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
def binary_path
|
|
21
24
|
@binary_path ||= find_binary
|
|
22
25
|
end
|
|
23
26
|
|
|
27
|
+
def cli_version
|
|
28
|
+
@cli_version ||= detect_cli_version
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def reset_cli_version!
|
|
32
|
+
@cli_version = nil
|
|
33
|
+
end
|
|
34
|
+
|
|
24
35
|
private
|
|
25
36
|
|
|
37
|
+
def detect_cli_version
|
|
38
|
+
output = `#{binary_path} --version 2>/dev/null`.strip
|
|
39
|
+
return nil if output.empty?
|
|
40
|
+
|
|
41
|
+
# Extract semver part — CLI may output "0.11.1 (ae52818b)"
|
|
42
|
+
output[/\d+\.\d+\.\d+/]
|
|
43
|
+
end
|
|
44
|
+
|
|
26
45
|
def find_binary
|
|
27
46
|
path = `which summarize 2>/dev/null`.strip
|
|
28
47
|
return path unless path.empty?
|
data/lib/summarize/errors.rb
CHANGED
|
@@ -28,4 +28,17 @@ module Summarize
|
|
|
28
28
|
super("summarize exited with code #{exit_code}: #{stderr}")
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
class VersionMismatchError < Error
|
|
33
|
+
attr_reader :installed_version, :required_version
|
|
34
|
+
|
|
35
|
+
def initialize(installed_version, required_version)
|
|
36
|
+
@installed_version = installed_version
|
|
37
|
+
@required_version = required_version
|
|
38
|
+
super(
|
|
39
|
+
"summarize CLI #{installed_version} is too old (requires >= #{required_version}). " \
|
|
40
|
+
"Update via: npm i -g @steipete/summarize"
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
31
44
|
end
|
data/lib/summarize/version.rb
CHANGED
data/lib/summarize.rb
CHANGED
|
@@ -46,5 +46,28 @@ module Summarize
|
|
|
46
46
|
def extract(input, **opts)
|
|
47
47
|
Client.new.extract(input, **opts)
|
|
48
48
|
end
|
|
49
|
+
|
|
50
|
+
# Eagerly check CLI version. Returns the version string or raises
|
|
51
|
+
# VersionMismatchError / BinaryNotFoundError.
|
|
52
|
+
#
|
|
53
|
+
# Summarize.check_version! # => "0.10.0"
|
|
54
|
+
#
|
|
55
|
+
def check_version!
|
|
56
|
+
config = configuration
|
|
57
|
+
path = config.binary_path
|
|
58
|
+
|
|
59
|
+
unless path == "summarize" || File.executable?(path)
|
|
60
|
+
raise BinaryNotFoundError, path
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
installed = config.cli_version
|
|
64
|
+
required = MINIMUM_CLI_VERSION
|
|
65
|
+
|
|
66
|
+
if installed && Gem::Version.new(installed) < Gem::Version.new(required)
|
|
67
|
+
raise VersionMismatchError.new(installed, required)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
installed
|
|
71
|
+
end
|
|
49
72
|
end
|
|
50
73
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: summarize-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martiano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A Ruby gem that wraps the summarize CLI tool, providing a clean Ruby
|
|
14
14
|
API for summarizing URLs, files, and text using various LLM providers.
|