Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/publish-gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to rubygems.org in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/Hexlet/tilda-ruby/actions/workflows/publish-gem.yml
name: Publish Gem
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- run: |-
bundle install

- name: Publish to RubyGems.org
run: |
bash ./bin/publish-gem
env:
# `RUBYGEMS_HOST` is only required for private gem repositories, not https://rubygems.org
RUBYGEMS_HOST: ${{ secrets.TILDA_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }}
GEM_HOST_API_KEY: ${{ secrets.TILDA_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}
22 changes: 22 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'Hexlet/tilda-ruby' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v6

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
RUBYGEMS_HOST: ${{ secrets.TILDA_RUBYGEMS_HOST || secrets.RUBYGEMS_HOST }}
GEM_HOST_API_KEY: ${{ secrets.TILDA_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.2"
}
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Layout/LineLength:
AllowedPatterns:
- "^\\s*#.*$"
- ^require(_relative)?
- "Tilda::Internal::Type::BaseModel$"
- "TildaRuby::Internal::Type::BaseModel$"
- "^\\s*[A-Z0-9_]+ = :"
- "Tilda::(Models|Resources|Test)::"
- "TildaRuby::(Models|Resources|Test)::"
Max: 110

Layout/MultilineArrayLineBreaks:
Expand Down
4 changes: 2 additions & 2 deletions .solargraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include:
- 'Rakefile'
- 'examples/**/*.rb'
- 'lib/**/*.rb'
- 'test/tilda/resource_namespaces.rb'
- 'test/tilda/test_helper.rb'
- 'test/tilda_ruby/resource_namespaces.rb'
- 'test/tilda_ruby/test_helper.rb'
exclude:
- 'rbi/**/*'
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Ftilda-d06441794bcf349b37439e4084aa5accb40ad16d553d5013cd33b9379f183dc1.yml
openapi_spec_hash: 231389205a35d2d6c56bd1cac4091e81
config_hash: e9e27aada148c323a3b3fc7a44f0b53f
config_hash: 02a97d1e54040f9bd1eeef26fc735da7
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

## 0.0.2 (2026-02-14)

Full Changelog: [v0.0.1...v0.0.2](https://github.com/Hexlet/tilda-ruby/compare/v0.0.1...v0.0.2)

### Chores

* update SDK settings ([fb564fe](https://github.com/Hexlet/tilda-ruby/commit/fb564fe80dbc114998b4a2cc1aaaeaaf5e8c127c))
* update SDK settings ([5ee0a1f](https://github.com/Hexlet/tilda-ruby/commit/5ee0a1f307b5e5a9884b39061d6a409ff014db13))
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This will install all the required dependencies.

## Modifying/Adding code

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/tilda/helpers/` and `examples/` directory.
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents of `lib/tilda_ruby/helpers/` and `examples/` directory.

## Adding and running examples

Expand All @@ -24,7 +24,7 @@ All files in the `examples/` directory are not modified by the generator and can
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/tilda"
require_relative "../lib/tilda_ruby"

# ...
```
Expand All @@ -43,17 +43,17 @@ If you’d like to use the repository from source, you can either install from g
To install via git in your `Gemfile`:

```ruby
gem "tilda", git: "https://github.com/stainless-sdks/tilda-ruby"
gem "tilda-ruby", git: "https://github.com/Hexlet/tilda-ruby"
```

Alternatively, reference local copy of the repo:

```bash
$ git clone -- 'https://github.com/stainless-sdks/tilda-ruby' '<path-to-repo>'
$ git clone -- 'https://github.com/Hexlet/tilda-ruby' '<path-to-repo>'
```

```ruby
gem "tilda", path: "<path-to-repo>"
gem "tilda-ruby", path: "<path-to-repo>"
```

## Running commands
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
tilda (0.0.1)
tilda-ruby (0.0.2)
cgi
connection_pool

Expand Down Expand Up @@ -219,7 +219,7 @@ DEPENDENCIES
syntax_tree
syntax_tree-rbs!
tapioca
tilda!
tilda-ruby!
webmock
webrick
yard
Expand Down
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Tilda Ruby API library

The Tilda Ruby library provides convenient access to the Tilda REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/stainless-sdks/tilda-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
The Tilda Ruby library provides convenient access to the Tilda REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/Hexlet/tilda-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.

It is generated with [Stainless](https://www.stainless.com/).

## Documentation

Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/tilda).
Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/tilda-ruby).

## Installation

To use this gem, install via Bundler by adding the following to your application's `Gemfile`:

<!-- x-release-please-start-version -->

```ruby
gem "tilda", "~> 0.0.1"
gem "tilda-ruby", "~> 0.0.2"
```

<!-- x-release-please-end -->

## Usage

```ruby
require "bundler/setup"
require "tilda"
require "tilda_ruby"

tilda = Tilda::Client.new(
tilda = TildaRuby::Client.new(
api_key: ENV["TILDA_API_KEY"] # This is the default and can be omitted
)

Expand All @@ -33,17 +37,17 @@ puts(getpage)

### Handling errors

When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Tilda::Errors::APIError` will be thrown:
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `TildaRuby::Errors::APIError` will be thrown:

```ruby
begin
getpage = tilda.getpage.retrieve(pageid: "REPLACE_ME")
rescue Tilda::Errors::APIConnectionError => e
rescue TildaRuby::Errors::APIConnectionError => e
puts("The server could not be reached")
puts(e.cause) # an underlying Exception, likely raised within `net/http`
rescue Tilda::Errors::RateLimitError => e
rescue TildaRuby::Errors::RateLimitError => e
puts("A 429 status code was received; we should back off a bit.")
rescue Tilda::Errors::APIStatusError => e
rescue TildaRuby::Errors::APIStatusError => e
puts("Another non-200-range status code was received")
puts(e.status)
end
Expand Down Expand Up @@ -75,7 +79,7 @@ You can use the `max_retries` option to configure or disable this:

```ruby
# Configure the default for all requests:
tilda = Tilda::Client.new(
tilda = TildaRuby::Client.new(
max_retries: 0 # default is 2
)

Expand All @@ -89,23 +93,23 @@ By default, requests will time out after 60 seconds. You can use the timeout opt

```ruby
# Configure the default for all requests:
tilda = Tilda::Client.new(
tilda = TildaRuby::Client.new(
timeout: nil # default is 60
)

# Or, configure per-request:
tilda.getpage.retrieve(pageid: "REPLACE_ME", request_options: {timeout: 5})
```

On timeout, `Tilda::Errors::APITimeoutError` is raised.
On timeout, `TildaRuby::Errors::APITimeoutError` is raised.

Note that requests that time out are retried by default.

## Advanced concepts

### BaseModel

All parameter and response objects inherit from `Tilda::Internal::Type::BaseModel`, which provides several conveniences, including:
All parameter and response objects inherit from `TildaRuby::Internal::Type::BaseModel`, which provides several conveniences, including:

1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.

Expand Down Expand Up @@ -157,9 +161,9 @@ response = client.request(

### Concurrency & connection pooling

The `Tilda::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
The `TildaRuby::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.

Each instance of `Tilda::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
Each instance of `TildaRuby::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.

When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.

Expand All @@ -182,7 +186,7 @@ Or, equivalently:
tilda.getpage.retrieve(pageid: "REPLACE_ME")

# You can also splat a full Params class:
params = Tilda::GetpageRetrieveParams.new(pageid: "REPLACE_ME")
params = TildaRuby::GetpageRetrieveParams.new(pageid: "REPLACE_ME")
tilda.getpage.retrieve(**params)
```

Expand All @@ -198,4 +202,4 @@ Ruby 3.2.0 or higher.

## Contributing

See [the contributing documentation](https://github.com/stainless-sdks/tilda-ruby/tree/main/CONTRIBUTING.md).
See [the contributing documentation](https://github.com/Hexlet/tilda-ruby/tree/main/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ multitask(:"build:gem") do
sig/*
GLOB

sh(*%w[gem build -- tilda.gemspec])
sh(*%w[gem build -- tilda_ruby.gemspec])
rm_rf(ignore_file)
end

Expand Down
21 changes: 21 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

errors=()

if [ -z "${GEM_HOST_API_KEY}" ]; then
errors+=("The GEM_HOST_API_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
78 changes: 0 additions & 78 deletions lib/tilda.rb

This file was deleted.

Loading
Loading