typesensual 1.0.0 → 1.1.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/CHANGELOG.md +15 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +30 -14
- data/README.md +9 -1
- data/lib/typesensual/collection.rb +25 -11
- data/lib/typesensual/index.rb +2 -1
- data/lib/typesensual/search.rb +1 -1
- data/lib/typesensual/version.rb +1 -1
- data/lib/typesensual.rb +3 -0
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29851530a5198bb6d1c6d22c50f59f21517f6a2fdb2f986a54788065310f7dd4
|
|
4
|
+
data.tar.gz: f20503d802197c17bc4577ca359018f3196f7cdf3c48523d4f2ad472c534bb78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7cc4b88c96e264b04f87ac36639662297c3c2befd55ba7300d5f48444ab69b067b9fb306667a8ec4ff2cbe29ef1b9c0b1c1027841abf126a51c5765ca29dc49
|
|
7
|
+
data.tar.gz: 0bd0ae98230789ade85e09b487183e1d0297dbd8eac12e44e1765e2a600646f7c41b4a87b5477347a01a3cc00dbdd51faa785510f47f63a205b848364b336ef0
|
data/CHANGELOG.md
CHANGED
|
@@ -2,4 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.1.0] - 2026-11-28
|
|
6
|
+
|
|
7
|
+
- Follow the alias when it moves: searches and document writes made through `Index.collection` are
|
|
8
|
+
now sent to the alias instead of to whichever collection it pointed at when the process first
|
|
9
|
+
used the index. Previously a running process stayed on the old collection after a reindex
|
|
10
|
+
elsewhere, and failed once that collection was deleted
|
|
11
|
+
- Add `Collection#lookup_name`, the name or alias a collection is reached by. `Collection#delete!`
|
|
12
|
+
still deletes the collection that was loaded, and `Collection#reload` loads whatever the alias
|
|
13
|
+
points to now
|
|
14
|
+
- Test against typesense-ruby 2.x through 5.x and Typesense 27 through 30
|
|
15
|
+
- Require `uri`, `time` and ActiveSupport's `blank` extensions explicitly instead of relying on
|
|
16
|
+
them being loaded by other gems
|
|
17
|
+
|
|
18
|
+
## [1.0.0] - 2024-10-06
|
|
19
|
+
|
|
5
20
|
- Initial release
|
data/Gemfile
CHANGED
|
@@ -5,6 +5,9 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in typesensual.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
+
# Lets CI test against a specific typesense-ruby version
|
|
9
|
+
gem 'typesense', ENV.fetch('TYPESENSE_GEM') if ENV.key?('TYPESENSE_GEM')
|
|
10
|
+
|
|
8
11
|
gem 'rake'
|
|
9
12
|
gem 'rspec'
|
|
10
13
|
gem 'rubocop'
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
typesensual (1.
|
|
4
|
+
typesensual (1.1.0)
|
|
5
5
|
activesupport (>= 6.1.5)
|
|
6
6
|
paint (>= 2.0.0)
|
|
7
7
|
typesense (>= 0.13.0)
|
|
@@ -15,20 +15,33 @@ GEM
|
|
|
15
15
|
minitest (>= 5.1)
|
|
16
16
|
tzinfo (~> 2.0)
|
|
17
17
|
ast (2.4.2)
|
|
18
|
-
|
|
18
|
+
base64 (0.3.0)
|
|
19
19
|
commonmarker (0.23.10)
|
|
20
20
|
concurrent-ruby (1.2.3)
|
|
21
|
+
connection_pool (3.0.3)
|
|
21
22
|
diff-lcs (1.5.0)
|
|
22
23
|
docile (1.4.0)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
faraday (2.15.1)
|
|
25
|
+
faraday-net_http (>= 2.0, < 3.6)
|
|
26
|
+
json
|
|
27
|
+
logger
|
|
28
|
+
faraday-net_http (3.5.0)
|
|
29
|
+
net-http (~> 0.5)
|
|
30
|
+
faraday-net_http_persistent (2.3.1)
|
|
31
|
+
faraday (~> 2.5)
|
|
32
|
+
net-http-persistent (>= 4.0.4, < 5)
|
|
26
33
|
i18n (1.14.1)
|
|
27
34
|
concurrent-ruby (~> 1.0)
|
|
28
|
-
json (2.
|
|
35
|
+
json (2.21.2)
|
|
36
|
+
logger (1.7.0)
|
|
29
37
|
minitest (5.22.3)
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
net-http (0.10.0)
|
|
39
|
+
net-protocol (>= 0.3.0)
|
|
40
|
+
uri (>= 0.11.1)
|
|
41
|
+
net-http-persistent (4.0.8)
|
|
42
|
+
connection_pool (>= 2.2.4, < 4)
|
|
43
|
+
net-protocol (0.4.0)
|
|
44
|
+
timeout
|
|
32
45
|
paint (2.3.0)
|
|
33
46
|
parallel (1.23.0)
|
|
34
47
|
parser (3.2.2.1)
|
|
@@ -81,14 +94,17 @@ GEM
|
|
|
81
94
|
simplecov_json_formatter (~> 0.1)
|
|
82
95
|
simplecov-html (0.12.3)
|
|
83
96
|
simplecov_json_formatter (0.1.4)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
timeout (0.6.1)
|
|
98
|
+
typesense (5.1.0)
|
|
99
|
+
base64 (~> 0.2)
|
|
100
|
+
faraday (~> 2.8)
|
|
101
|
+
faraday-net_http_persistent (~> 2.0)
|
|
102
|
+
json (>= 2.9, < 4)
|
|
103
|
+
net-http-persistent (~> 4.0)
|
|
89
104
|
tzinfo (2.0.6)
|
|
90
105
|
concurrent-ruby (~> 1.0)
|
|
91
106
|
unicode-display_width (2.4.2)
|
|
107
|
+
uri (1.1.2)
|
|
92
108
|
webrick (1.7.0)
|
|
93
109
|
yard (0.9.34)
|
|
94
110
|
|
|
@@ -112,4 +128,4 @@ DEPENDENCIES
|
|
|
112
128
|
yard
|
|
113
129
|
|
|
114
130
|
BUNDLED WITH
|
|
115
|
-
2.
|
|
131
|
+
2.6.7
|
data/README.md
CHANGED
|
@@ -129,6 +129,9 @@ collection.index_many(Movie.ids, collection: collection)
|
|
|
129
129
|
MoviesIndex.update_alias(collection)
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
Searches and writes made through the index go by way of its alias, so processes which are already
|
|
133
|
+
running pick up the new collection as soon as the alias moves. There's no need to restart them.
|
|
134
|
+
|
|
132
135
|
### Searching your index
|
|
133
136
|
|
|
134
137
|
Now that you have data in your index, you can search it! Typesensual provides a simple interface for
|
|
@@ -141,11 +144,16 @@ query.per(10).page(2).load
|
|
|
141
144
|
|
|
142
145
|
The full interface for this is documented in the `Search`, `Results`, and `Hit` classes.
|
|
143
146
|
|
|
147
|
+
## Compatibility
|
|
148
|
+
|
|
149
|
+
Typesensual is tested against typesense-ruby 2.x through 5.x and Typesense 27 through 30, paired
|
|
150
|
+
according to [typesense-ruby's compatibility table](https://github.com/typesense/typesense-ruby#compatibility).
|
|
151
|
+
|
|
144
152
|
## Development
|
|
145
153
|
|
|
146
154
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
147
155
|
|
|
148
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb
|
|
156
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb` and the changelog, then push a `v`-prefixed tag for it (or run the Release workflow by hand, which creates the tag). The [Release workflow](.github/workflows/release.yml) pushes the `.gem` file to [rubygems.org](https://rubygems.org) through [trusted publishing](https://guides.rubygems.org/trusted-publishing/).
|
|
149
157
|
|
|
150
158
|
## Contributing
|
|
151
159
|
|
|
@@ -36,23 +36,36 @@ class Typesensual
|
|
|
36
36
|
# @overload initialize(name)
|
|
37
37
|
# Initialize a new collection, loading info from Typesense
|
|
38
38
|
#
|
|
39
|
-
# @param name [String] the name of the collection
|
|
39
|
+
# @param name [String] the name of the collection, or of an alias pointing to it
|
|
40
40
|
# @raise [Typesense::Error::ObjectNotFound] if the collection doesn't exist
|
|
41
41
|
def initialize(collection_or_name)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if collection_or_name.is_a?(Hash)
|
|
43
|
+
@collection = collection_or_name.deep_stringify_keys
|
|
44
|
+
else
|
|
45
|
+
@lookup_name = collection_or_name
|
|
46
|
+
@collection = client.collections[collection_or_name].retrieve
|
|
47
|
+
end
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
# Reload the underlying collection data from Typesense
|
|
50
|
+
# Reload the underlying collection data from Typesense. If the collection was looked up through
|
|
51
|
+
# an alias which has since been pointed elsewhere, this loads the collection it points to now.
|
|
50
52
|
# @return [self]
|
|
51
53
|
def reload
|
|
52
|
-
@collection = client.collections[
|
|
54
|
+
@collection = client.collections[lookup_name].retrieve
|
|
55
|
+
@created_at = @parsed_name = nil
|
|
53
56
|
self
|
|
54
57
|
end
|
|
55
58
|
|
|
59
|
+
# The name this collection is reached by: the name or alias it was looked up with, or its own
|
|
60
|
+
# name if it was not looked up. Searches and document writes are sent here rather than to
|
|
61
|
+
# {#name}, so a collection which was looked up through an alias follows that alias when it is
|
|
62
|
+
# pointed at another collection, such as by a reindex in another process. The rest of what the
|
|
63
|
+
# collection reports about itself is as of when it was loaded; see {#reload}.
|
|
64
|
+
# @return [String] the name or alias used to reach the collection
|
|
65
|
+
def lookup_name
|
|
66
|
+
@lookup_name || name
|
|
67
|
+
end
|
|
68
|
+
|
|
56
69
|
# The time the collection was created, as tracked by Typesense
|
|
57
70
|
# @return [Time] the time the collection was created
|
|
58
71
|
def created_at
|
|
@@ -133,10 +146,11 @@ class Typesensual
|
|
|
133
146
|
self
|
|
134
147
|
end
|
|
135
148
|
|
|
136
|
-
# Deletes the collection in Typesense
|
|
149
|
+
# Deletes the collection in Typesense. This is always the collection that was loaded, even if
|
|
150
|
+
# it was looked up through an alias which now points to another one.
|
|
137
151
|
# @return [void]
|
|
138
152
|
def delete!
|
|
139
|
-
|
|
153
|
+
client.collections[name].delete
|
|
140
154
|
end
|
|
141
155
|
|
|
142
156
|
# Create a new collection using the given collection hash
|
|
@@ -204,7 +218,7 @@ class Typesensual
|
|
|
204
218
|
end
|
|
205
219
|
|
|
206
220
|
def typesense_collection
|
|
207
|
-
@typesense_collection ||= client.collections[
|
|
221
|
+
@typesense_collection ||= client.collections[lookup_name]
|
|
208
222
|
end
|
|
209
223
|
|
|
210
224
|
private
|
data/lib/typesensual/index.rb
CHANGED
|
@@ -91,7 +91,8 @@ class Typesensual
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
# Get the collection that the alias points to
|
|
94
|
+
# Get the collection that the alias points to. Searches and document writes made through it
|
|
95
|
+
# go by way of the alias, so they follow it if it is later pointed at another collection.
|
|
95
96
|
#
|
|
96
97
|
# @return [Collection] the collection that the alias points to
|
|
97
98
|
def self.collection
|
data/lib/typesensual/search.rb
CHANGED
data/lib/typesensual/version.rb
CHANGED
data/lib/typesensual.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
|
+
require 'time'
|
|
5
|
+
require 'uri'
|
|
4
6
|
|
|
5
7
|
require 'active_support/concern'
|
|
8
|
+
require 'active_support/core_ext/object/blank'
|
|
6
9
|
require 'active_support/core_ext/string/inflections'
|
|
7
10
|
require 'active_support/core_ext/class/subclasses'
|
|
8
11
|
require 'active_support/core_ext/module/delegation'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: typesensual
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emma Lejeck
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -52,7 +51,6 @@ dependencies:
|
|
|
52
51
|
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: 0.13.0
|
|
55
|
-
description:
|
|
56
54
|
email:
|
|
57
55
|
- nuck@kitsu.app
|
|
58
56
|
executables: []
|
|
@@ -94,7 +92,6 @@ metadata:
|
|
|
94
92
|
source_code_uri: https://github.com/hummingbird-me/typesensual
|
|
95
93
|
changelog_uri: https://github.com/hummingbird-me/typesensual/blob/main/CHANGELOG.md
|
|
96
94
|
rubygems_mfa_required: 'true'
|
|
97
|
-
post_install_message:
|
|
98
95
|
rdoc_options: []
|
|
99
96
|
require_paths:
|
|
100
97
|
- lib
|
|
@@ -109,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
106
|
- !ruby/object:Gem::Version
|
|
110
107
|
version: '0'
|
|
111
108
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
113
|
-
signing_key:
|
|
109
|
+
rubygems_version: 3.6.9
|
|
114
110
|
specification_version: 4
|
|
115
111
|
summary: A simple, sensual wrapper around Typesense for Ruby
|
|
116
112
|
test_files: []
|