Skip to content

Commit b22a9b2

Browse files
committed
Initial commit
Set up a Ruby gem project structure with a basic client for the Turbopuffer API and one test hitting the production API. The goal is to have a working gem that can be used to try the service and evaluate it.
0 parents  commit b22a9b2

File tree

17 files changed

+342
-0
lines changed

17 files changed

+342
-0
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
name: Ruby ${{ matrix.ruby }}
14+
strategy:
15+
matrix:
16+
ruby:
17+
- '3.3.6'
18+
- '3.4.1'
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: ${{ matrix.ruby }}
26+
bundler-cache: true
27+
- name: Run the default task
28+
env:
29+
TURBOPUFFER_API_KEY: ${{ secrets.TURBOPUFFER_API_KEY }}
30+
run: bundle exec rake

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
Gemfile.lock
10+
*.gem

.standard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# For available configuration options, see:
2+
# https://github.com/standardrb/standard
3+
ruby_version: 3.3

Gemfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# Specify your gem's dependencies in turbopuffer.gemspec
6+
gemspec
7+
8+
gem "rake", "~> 13.0"
9+
10+
gem "minitest", "~> 5.16"
11+
12+
gem "standard", "~> 1.3"

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Adrián Mugnolo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Turbopuffer
2+
3+
A Ruby client for accessing the Turbopuffer API.
4+
5+
## Installation
6+
7+
Install the gem and add to the application's Gemfile by executing:
8+
9+
```bash
10+
bundle add turbopuffer
11+
```
12+
13+
If bundler is not being used to manage dependencies, install the gem by
14+
executing:
15+
16+
```bash
17+
gem install turbopuffer
18+
```
19+
20+
## Usage
21+
22+
```ruby
23+
tpuf = Turbopuffer::Client.new("your-token")
24+
25+
ns = tpuf.namespace("namespace-name")
26+
27+
ns.upsert(
28+
ids: [1, 2],
29+
vectors: [[0.1, 0.2], [0.3, 0.4]],
30+
attributes: {name: ["foo", "bar"]}
31+
)
32+
33+
results = ns.query(
34+
vector: [0.15, 0.22],
35+
top_k: 10
36+
)
37+
38+
ns.delete_all
39+
```
40+
41+
## Development
42+
43+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
44+
`rake test` to run the tests. You can also run `bin/console` for an interactive
45+
prompt that will allow you to experiment.
46+
47+
To install this gem onto your local machine, run `bundle exec rake install`. To
48+
release a new version, update the version number in `version.rb`, and then run
49+
`bundle exec rake release`, which will create a git tag for the version, push
50+
git commits and the created tag, and push the `.gem` file to
51+
[rubygems.org](https://rubygems.org).
52+
53+
## Contributing
54+
55+
Bug reports and pull requests are welcome on GitHub at
56+
https://github.com/xymbol/turbopuffer-ruby.
57+
58+
## License
59+
60+
The gem is available as open source under the terms of the [MIT
61+
License](https://opensource.org/licenses/MIT).

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "minitest/test_task"
5+
6+
Minitest::TestTask.create
7+
8+
require "standard/rake"
9+
10+
task default: %i[test standard]

bin/console

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "turbopuffer"
6+
7+
# You can add fixtures and/or initialization code here to make experimenting
8+
# with your gem easier. You can also use a different console, if you like.
9+
10+
require "irb"
11+
IRB.start(__FILE__)

bin/setup

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
set -vx
5+
6+
bundle install
7+
8+
# Do any other automated setup that you need to do here

lib/turbopuffer.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "turbopuffer/version"
4+
require_relative "turbopuffer/client"
5+
require_relative "turbopuffer/namespace"
6+
7+
module Turbopuffer
8+
class Error < StandardError; end
9+
end

0 commit comments

Comments
 (0)