-
Notifications
You must be signed in to change notification settings - Fork 13
chore: Add CLAUDE.md #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
chore: Add CLAUDE.md #113
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Ruby SDK for the [CloudEvents](https://cloudevents.io/) specification (CNCF). Gem name: `cloud_events`. Supports CloudEvents spec versions 0.3 and 1.0. Zero runtime dependencies; Ruby 2.7+. | ||
|
|
||
| ## Development Commands | ||
|
|
||
| This project uses [Toys](https://github.com/dazuma/toys) as the task runner (not Rake). | ||
|
|
||
| ```bash | ||
| bundle install # Install dependencies | ||
| gem install toys # Install task runner (required) | ||
|
|
||
| toys test # Run minitest unit tests | ||
| toys cucumber # Run Cucumber conformance tests | ||
| toys rubocop # Run linter | ||
| toys yardoc # Generate YARD documentation | ||
| toys build # Build .gem file into pkg/ | ||
| toys install # Build and install gem locally | ||
| toys ci # Run full CI suite (test + cucumber + rubocop + yard + build) | ||
| toys ci --only --test # Run only minitest | ||
| toys ci --only --cucumber # Run only Cucumber tests | ||
| toys ci --only --rubocop # Run only linter | ||
| ``` | ||
|
|
||
| To focus a single test, add `focus` before a test method (requires `minitest-focus` gem from the bundle). | ||
|
|
||
| ## Code Style | ||
|
|
||
| Enforced by Rubocop (`.rubocop.yml`): | ||
| - Double-quoted strings | ||
| - Trailing commas in multiline arrays/hashes | ||
| - 120 character line limit | ||
| - `[:symbol]` array style (not `%i`) | ||
| - `["word"]` array style (not `%w`) | ||
| - All source files require `# frozen_string_literal: true` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Event Model | ||
|
|
||
| `CloudEvents::Event` is both a module (included by all event classes) and a factory via `Event.create(spec_version:, **attrs)`. | ||
|
|
||
| - **`Event::V1`** — CloudEvents 1.0 (primary). Immutable (frozen), Ractor-shareable on Ruby 3+. | ||
| - **`Event::V0`** — CloudEvents 0.3 (legacy). | ||
| - **`Event::Opaque`** — Wrapper for events that couldn't be fully decoded. | ||
|
|
||
| V1 has a dual data model: `data` holds the decoded Ruby object, `data_encoded` holds the serialized string/bytes. Formatters use `data_encoded` if present, otherwise encode `data`. | ||
|
|
||
| ### HTTP Binding (`HttpBinding`) | ||
|
|
||
| Handles encoding/decoding CloudEvents to/from HTTP (Rack env hashes). Supports: | ||
| - **Binary content mode** — event attributes as `CE-*` headers, data in body | ||
| - **Structured content mode** — entire event serialized in body (e.g., JSON) | ||
| - **Batch mode** — array of events in body | ||
|
|
||
| `HttpBinding.default` returns a singleton with `JsonFormat` and `TextFormat` pre-registered. Custom formatters are registered via `register_formatter`. | ||
|
|
||
| ### Format Layer | ||
|
|
||
| - **`JsonFormat`** — Encodes/decodes `application/cloudevents+json` and batch format. Also handles JSON data encoding/decoding for binary mode. | ||
| - **`TextFormat`** — Handles `text/*` data. | ||
| - **`Format::Multi`** — Composite that tries multiple formatters in registration order. | ||
|
|
||
| Formatters implement up to four methods: `decode_event`, `encode_event`, `decode_data`, `encode_data`. Return `nil` to decline handling (next formatter is tried). | ||
|
|
||
| ### Content-Type Parser (`ContentType`) | ||
|
|
||
| RFC 2045 compliant parser. Handles charset defaults: `text/plain` defaults to `us-ascii`, other `text/*` and JSON types default to `utf-8`. | ||
|
|
||
| ### Error Hierarchy | ||
|
|
||
| All errors inherit from `CloudEventsError`: `NotCloudEventError`, `UnsupportedFormatError`, `FormatSyntaxError`, `SpecVersionError`, `AttributeError`. | ||
|
|
||
| ## Contributing | ||
|
|
||
| - Conventional Commits format required (`fix:`, `feat:`, `docs:`, etc.) | ||
| - Commits must be signed off (`git commit --signoff`) | ||
| - Run `toys ci` before submitting PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.