Skip to content

Commit 98ac47f

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 98ac47f

File tree

17 files changed

+352
-0
lines changed

17 files changed

+352
-0
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby }}
25+
bundler-cache: true
26+
- name: Run the default task
27+
env:
28+
TURBOPUFFER_API_KEY: ${{ secrets.TURBOPUFFER_API_KEY }}
29+
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# For available configuration options, see:
2+
# https://github.com/standardrb/standard
3+
ruby_version: 3.0
4+
fix: true

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