steppe 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 48833f95d08ddb49a1a8e620c9d78ac4e2281232abfc6a57acd5a7bdfd99fe15
4
+ data.tar.gz: 3b6315a44c3492c35fc22a408b6b907ae056bbe2c1d1dadb32211a9883be787e
5
+ SHA512:
6
+ metadata.gz: 99e9ca81d25178bf93cafa20d12bc4735dc0da54fe36ac38ca5c09cd0f7911edf45233be624202c9051ef9578d9476dd0f99fa106119677cf5f8a5fde51b77dd
7
+ data.tar.gz: 6ead736e90a6b063203ebb29f41e6af8376ff1e69db20af99172b1839c2e99f2a4263abb9350bcf134a6301ed49dad7f32848178042c534752f40f3410db5db5
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.6
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-09-06
4
+
5
+ - Initial release
data/CLAUDE.md ADDED
@@ -0,0 +1,88 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ Steppe is a Ruby gem for building composable, self-documenting REST APIs. It provides a DSL for defining endpoints with built-in request validation, response serialization, and OpenAPI documentation generation.
8
+
9
+ ## Development Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ bundle install
14
+
15
+ # Run tests
16
+ rake spec
17
+ # or
18
+ bundle exec rspec
19
+
20
+ # Run specific test file
21
+ bundle exec rspec spec/endpoint_spec.rb
22
+
23
+ # Run console for experimentation
24
+ bin/console
25
+
26
+ # Install gem locally
27
+ bundle exec rake install
28
+
29
+ # Release new version (updates version, creates git tag, pushes to rubygems)
30
+ bundle exec rake release
31
+ ```
32
+
33
+ ## Architecture
34
+
35
+ ### Core Components
36
+
37
+ - **Service** (`lib/steppe/service.rb`): Main container that holds multiple endpoints. Defines API metadata like title, description, servers, and tags.
38
+
39
+ - **Endpoint** (`lib/steppe/endpoint.rb`): Individual API endpoints that inherit from `Plumb::Pipeline`. Each endpoint defines:
40
+ - HTTP verb and path (with Mustermann pattern matching)
41
+ - Query parameter validation via `query_schema`
42
+ - Request body validation via `payload_schema`
43
+ - Response serialization via `respond`/`serialize`
44
+ - Processing steps via `step`
45
+
46
+ - **Responder** (`lib/steppe/responder.rb`): Handles response formatting for specific status codes and content types. Uses ResponderRegistry for resolution.
47
+
48
+ - **Serializer** (`lib/steppe/serializer.rb`): Base class for response serialization using Plumb types.
49
+
50
+ - **Request** (`lib/steppe/request.rb`): Wrapper around Rack::Request with additional Steppe-specific functionality.
51
+
52
+ - **Result** (`lib/steppe/result.rb`): Represents processing state (Continue/Halt) with params, errors, and response data.
53
+
54
+ ### Key Dependencies
55
+
56
+ - **Plumb**: Type validation and coercion library (used for schemas and pipelines)
57
+ - **Mustermann**: Pattern matching for URL routes
58
+ - **Rack**: Web server interface
59
+ - **MIME Types**: Content type handling
60
+
61
+ ### Request Processing Flow
62
+
63
+ 1. Request hits Service endpoint
64
+ 2. URL parameters extracted via Mustermann
65
+ 3. Query parameters validated against `query_schema`
66
+ 4. Request body parsed and validated against `payload_schema`
67
+ 5. Business logic steps executed via `step` blocks
68
+ 6. Response serialized via matching Responder
69
+ 7. Rack response returned
70
+
71
+ ### Testing
72
+
73
+ Tests use RSpec and are located in `spec/`. The main test files are:
74
+ - `spec/endpoint_spec.rb` - Endpoint functionality
75
+ - `spec/service_spec.rb` - Service container
76
+ - `spec/responder_spec.rb` - Response handling
77
+ - `spec/openapi_visitor_spec.rb` - OpenAPI generation
78
+
79
+ ### Example Usage
80
+
81
+ See `examples/sinatra.rb` for a complete working example that integrates Steppe with Sinatra and demonstrates:
82
+ - Defining a Service with multiple endpoints
83
+ - Query parameter validation
84
+ - Request body validation
85
+ - Custom serializers
86
+ - OpenAPI documentation generation
87
+
88
+ The gem follows standard Ruby gem conventions with lib/ containing source code and spec/ containing tests.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Ismael Celis
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.