vowpalwabbit 0.3.0 → 0.4.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: 75746e7efe8fd978814c5b22deff8bb496e45f43dbc05e23d54b120396fd271c
4
- data.tar.gz: 8d69b63c36598da996bdd9753ea7b693cedc709da0fb35603e24ad7ecd60d0ba
3
+ metadata.gz: a7b187c7b0c8d3fd4b5f4473c14e9f47fbd80375bc63ead8907b2a51b946cda0
4
+ data.tar.gz: dbd111a8baa38a41504c8945528b237334679cb8c277359e09ba5bfdb624fa62
5
5
  SHA512:
6
- metadata.gz: 6b82a3d0f584466db539656c2e987fe40721b5cb9e7a6c10d4fcd3ff5350475a4d4d22ce0192efe15f6737a8d5526de61c5a85ff142eea31b32ec7129302371e
7
- data.tar.gz: eab978e6734ff3e53f48ad8beb3435ef74c24e1c8615c9ec10863fc03e3b33e0dbf88a673cc578dc1f8b7389f84d7e21528625dd9188cd35b38ad2b5f586f8a3
6
+ metadata.gz: 94a54904710fb651b0f9d1be9a41869439221568352e44faa1f5731685ff3ba00cd99c4e0066e6a6ffc2ab24ffe5423527471615d4c9502cbaa8e23652b23bed
7
+ data.tar.gz: e3a6f921f6815e601d13f05640caeb4fb9c589237213773acfc283fb6347dc8d1ba02e3f4d9b0c74e8d427b30d56ae160ec56d36e2994f0b4b68fd402b227abf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.0 (2026-04-07)
2
+
3
+ - Dropped support for Ruby < 3.3
4
+
1
5
  ## 0.3.0 (2024-10-23)
2
6
 
3
7
  - Dropped support for Ruby < 3.1
data/LICENSE.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  BSD 3-Clause License
2
2
 
3
3
  Copyright (c) Microsoft Corp 2012-2014, Yahoo! Inc. 2007-2012, and many individual contributors
4
- Copyright (c) 2019-2021, Andrew Kane
4
+ Copyright (c) 2019-2026, Andrew Kane
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
@@ -52,7 +52,7 @@ module VowpalWabbit
52
52
  bin_str = File.binread(filename)
53
53
  model_data = ::FFI::MemoryPointer.new(:char, bin_str.bytesize)
54
54
  model_data.put_bytes(0, bin_str)
55
- @handle = FFI.VW_InitializeWithModel(param_str(@params), model_data, bin_str.bytesize)
55
+ @handle = wrap_handle(FFI.VW_InitializeWithModel(param_str(@params), model_data, bin_str.bytesize))
56
56
  nil
57
57
  end
58
58
 
@@ -64,9 +64,12 @@ module VowpalWabbit
64
64
 
65
65
  private
66
66
 
67
- # TODO clean-up handle
68
67
  def handle
69
- @handle ||= FFI.VW_InitializeA(param_str(@params))
68
+ @handle ||= wrap_handle(FFI.VW_InitializeA(param_str(@params)))
69
+ end
70
+
71
+ def wrap_handle(handle)
72
+ ::FFI::AutoPointer.new(handle, FFI.method(:VW_Finish))
70
73
  end
71
74
 
72
75
  def param_str(params)
@@ -120,16 +123,21 @@ module VowpalWabbit
120
123
  if x.is_a?(String)
121
124
  raise ArgumentError, "Cannot pass y with file" if y
122
125
 
123
- file_handle = FFI.VW_InitializeA(param_str(data: x, quiet: true))
126
+ file_handle = wrap_handle(FFI.VW_InitializeA(param_str(data: x, quiet: true)))
124
127
  FFI.VW_StartParser(file_handle)
125
- loop do
126
- example = FFI.VW_GetExample(file_handle)
127
- break if example.read_pointer.null?
128
- yield example
129
- FFI.VW_FinishExample(file_handle, example)
128
+ begin
129
+ loop do
130
+ example = FFI.VW_GetExample(file_handle)
131
+ begin
132
+ break if example.read_pointer.null?
133
+ yield example
134
+ ensure
135
+ FFI.VW_FinishExample(file_handle, example)
136
+ end
137
+ end
138
+ ensure
139
+ FFI.VW_EndParser(file_handle)
130
140
  end
131
- FFI.VW_EndParser(file_handle)
132
- FFI.VW_Finish(file_handle)
133
141
  else
134
142
  x = x.to_a
135
143
  if y
@@ -146,8 +154,11 @@ module VowpalWabbit
146
154
  end
147
155
 
148
156
  example = FFI.VW_ReadExampleA(handle, line)
149
- yield example
150
- FFI.VW_FinishExample(handle, example)
157
+ begin
158
+ yield example
159
+ ensure
160
+ FFI.VW_FinishExample(handle, example)
161
+ end
151
162
  end
152
163
  end
153
164
  end
@@ -1,3 +1,3 @@
1
1
  module VowpalWabbit
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vowpalwabbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-10-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ffi
@@ -24,7 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- description:
28
26
  email: andrew@ankane.org
29
27
  executables: []
30
28
  extensions: []
@@ -43,7 +41,6 @@ homepage: https://github.com/ankane/vowpalwabbit-ruby
43
41
  licenses:
44
42
  - BSD-3-Clause
45
43
  metadata: {}
46
- post_install_message:
47
44
  rdoc_options: []
48
45
  require_paths:
49
46
  - lib
@@ -51,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
48
  requirements:
52
49
  - - ">="
53
50
  - !ruby/object:Gem::Version
54
- version: '3.1'
51
+ version: '3.3'
55
52
  required_rubygems_version: !ruby/object:Gem::Requirement
56
53
  requirements:
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
56
  version: '0'
60
57
  requirements: []
61
- rubygems_version: 3.5.16
62
- signing_key:
58
+ rubygems_version: 4.0.6
63
59
  specification_version: 4
64
60
  summary: Fast online machine learning for Ruby
65
61
  test_files: []