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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aa6126addfe563121bc5cfe65df2e82b3e85dfa7418b1cb4895879c07a7f6f9
4
- data.tar.gz: 550c25f558569a2f4c27f52a2ae6ac4c968e2a86812ae3dcfb706ce4682bc4ce
3
+ metadata.gz: 689430b84d46027bb3dfe7d7ab30c6ffd6a8627fdce5ca1540f718d41a384c18
4
+ data.tar.gz: 6a27144a61b00a3581f7495f3662c714df05ead4bf280fc83b5c3edb6a0ff3f1
5
5
  SHA512:
6
- metadata.gz: 3ebc8961118671953db2abb961a0c7568b001416fa533483135403fd6c7e9e470c27feb815f00d530c1419cdadf81fefc39e46e40a4e82231724592172691c5c
7
- data.tar.gz: 1a039f756c61eab714f9ed3864acdea33a3479ee7167514daac0bb4b709af34fe610c22a8414776c6eade626d6956f19236a2a2555440e83ebd76547ee6d72b4
6
+ metadata.gz: 19e417b45e70c624c5103a767effe4359678e20053c162738ad27c5065cdd574f0a003f8c615badd82a953bb53288922aaba7df434f234f020b02a5d0c717423
7
+ data.tar.gz: 68bc215c350bb6ec0c6926936ac8bd57ce523e56de73be505da920c8f80026af6ae1e19aa376cc03fe2f23e67de1e33588bc6fb76aa37cfdf18fb253f4aa49e3
@@ -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?
@@ -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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Summarize
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
+ MINIMUM_CLI_VERSION = "0.11.1"
5
6
  end
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.2.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-19 00:00:00.000000000 Z
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.