documentrix 0.3.2 → 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 +4 -4
- data/CHANGES.md +18 -0
- data/documentrix.gemspec +2 -2
- data/lib/documentrix/documents.rb +16 -0
- data/lib/documentrix/version.rb +1 -1
- data/spec/documents_spec.rb +27 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e32a72c0a1f93a96f7c3cecd185f13a0f17a2629b2dc509ec3a29fd2d7b51a41
|
|
4
|
+
data.tar.gz: 3f2c21125adf7061dcba94f1843456064245222839de0df6ddbcd8743a1aea13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91dbf3ddfdeb124661ff78a4cbc1635dbb8bdf6606078aeeef77b4f9d14688d073261ad08b59f0333895c7391d83eff8a6c76467f19af4f04ca55172c1d934a5
|
|
7
|
+
data.tar.gz: d40e5a53ceeda71c7a2be37d3bfb718ffc2ddb0fddc0c6eb2346c295d06713c895493854fab5f768af075bec2595e2f23c40e893d7f7266c6f61cd95c534d733
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-05-22 v0.4.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added introspection methods to `Documents`:
|
|
8
|
+
- Implemented `sources` to return an array of unique source identifiers.
|
|
9
|
+
- Implemented `each_record` to iterate over records, returning an
|
|
10
|
+
`Enumerator` if no block is provided.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Updated CI images from Alpine to Debian:
|
|
15
|
+
- Switched Ruby **4.0**, **3.4**, **3.3**, and **3.2** images to the
|
|
16
|
+
`trixie` distribution.
|
|
17
|
+
- Switched Ruby **3.1** image to the `bookworm` distribution.
|
|
18
|
+
- Updated the `dockerfile` in `.all_images.yml` to use `apt-get` instead of
|
|
19
|
+
`apk` for installing build dependencies.
|
|
20
|
+
|
|
3
21
|
## 2026-05-20 v0.3.2
|
|
4
22
|
|
|
5
23
|
### Performance Improvements
|
data/documentrix.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: documentrix 0.
|
|
2
|
+
# stub: documentrix 0.4.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "documentrix".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.4.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -409,6 +409,22 @@ class Documentrix::Documents
|
|
|
409
409
|
@cache.tags
|
|
410
410
|
end
|
|
411
411
|
|
|
412
|
+
# Returns an array of all unique sources stored in the cache.
|
|
413
|
+
#
|
|
414
|
+
# @return [Array<String>] An array of unique source identifiers.
|
|
415
|
+
def sources
|
|
416
|
+
@cache.each_source.to_a
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
# The each_record method iterates over all records stored in the cache.
|
|
420
|
+
#
|
|
421
|
+
# @yield [record] The record being iterated over.
|
|
422
|
+
# @return [ Enumerator ] an enumerator if no block is provided.
|
|
423
|
+
def each_record(&block)
|
|
424
|
+
block or return enum_for(__method__)
|
|
425
|
+
@cache.each { |_key, record| block.(record) }
|
|
426
|
+
end
|
|
427
|
+
|
|
412
428
|
private
|
|
413
429
|
|
|
414
430
|
# Resets the memoized list of collections.
|
data/lib/documentrix/version.rb
CHANGED
data/spec/documents_spec.rb
CHANGED
|
@@ -226,6 +226,32 @@ describe Documentrix::Documents do
|
|
|
226
226
|
from(:default).
|
|
227
227
|
to(:new_collection)
|
|
228
228
|
end
|
|
229
|
+
|
|
230
|
+
it 'returns unique sources' do
|
|
231
|
+
allow(ollama).to receive(:embed).and_return(double(embeddings: [ [ 0.1 ] ]))
|
|
232
|
+
documents.add('foo', source: 's1')
|
|
233
|
+
documents.add('bar', source: 's1')
|
|
234
|
+
documents.add('baz', source: 's2')
|
|
235
|
+
expect(documents.sources).to match_array %w[ s1 s2 ]
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it 'can iterate over records' do
|
|
239
|
+
allow(ollama).to receive(:embed).and_return(double(embeddings: [ [ 0.1 ] ]))
|
|
240
|
+
documents.add('foo')
|
|
241
|
+
documents.add('bar')
|
|
242
|
+
records = []
|
|
243
|
+
documents.each_record { |r| records << r }
|
|
244
|
+
expect(records.size).to eq 2
|
|
245
|
+
expect(records.map(&:text)).to match_array %w[ foo bar ]
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it 'returns an enumerator for each_record' do
|
|
249
|
+
allow(ollama).to receive(:embed).and_return(double(embeddings: [ [ 0.1 ] ]))
|
|
250
|
+
documents.add('foo')
|
|
251
|
+
documents.add('bar')
|
|
252
|
+
expect(documents.each_record).to be_a Enumerator
|
|
253
|
+
expect(documents.each_record.map(&:text)).to match_array %w[ foo bar ]
|
|
254
|
+
end
|
|
229
255
|
end
|
|
230
256
|
|
|
231
257
|
context 'source management' do
|
|
@@ -233,7 +259,7 @@ describe Documentrix::Documents do
|
|
|
233
259
|
allow(documents).to receive(:compute_file_digest).and_return('d1')
|
|
234
260
|
allow(documents.cache).to receive(:compute_file_digest).and_return('d1')
|
|
235
261
|
|
|
236
|
-
allow(ollama).to receive(:embed).and_return(double(embeddings: [[0.1]]))
|
|
262
|
+
allow(ollama).to receive(:embed).and_return(double(embeddings: [ [ 0.1 ] ]))
|
|
237
263
|
end
|
|
238
264
|
|
|
239
265
|
it 'can check if a source exists' do
|