respondo 1.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbb9a42fee14d341990b700fd36592d17757abccb2c1a7cac406177a0eee259f
4
- data.tar.gz: 31885b2ddb68d296998f82900273e36a76ec896c4ca691291544db0242932508
3
+ metadata.gz: fb5118a5648863ec54d68805d897485f40da5b81b9b628b9b9a08d6ee2f735d7
4
+ data.tar.gz: 4282b491b0bd587ba668e7accaf19f6dfb879cc61261d64d744de69c803ae8a0
5
5
  SHA512:
6
- metadata.gz: 6be63c0f45ece4fd72f6a4880f624cc875616e77fda1321474c59ba8f8709fc20a2187a8989661ce21d1d59a6815084020b7f570e7c1d3e4809191c32bfa3dd7
7
- data.tar.gz: 8fc37dd22d9052f5d7a4fb85de3e607053358bc4ad00a7fb2cb5c991aabb77726cb35c4aef8a68ad9459ec9229ccf8e5a3a16a7b16d97dc4f3c54d35d00d7735
6
+ metadata.gz: 4ae4daae47ef9c2c66388fc6d8f3a915b66439208fafa25b7046234813229704de0e53863921f2b4e2100817218b2a315ef40a564c5f672a9848194e55814906
7
+ data.tar.gz: 86a9ecb6864c1bba75dc4d47941bd0f80c837f4dbc72ed424526e1dad3f05ead92b738a417a239f3fb160e7043fc465418fe6670948be147399ea90ee3ce85d8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,224 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.0] — Interactive Install Generator
4
+
5
+ ### Added
6
+
7
+ #### `rails generate respondo:install` — interactive setup wizard
8
+ A new generator that walks developers through configuration interactively at
9
+ install time, writing a fully commented `config/initializers/respondo.rb` so
10
+ they never have to read the README to get started.
11
+
12
+ **Usage:**
13
+ ```bash
14
+ rails generate respondo:install
15
+ ```
16
+
17
+ **What the wizard collects:**
18
+
19
+ | Prompt | Config written |
20
+ |--------|---------------|
21
+ | Project / app name | Comment header in initializer |
22
+ | API version | Auto-added to `config.default_meta` |
23
+ | Default success message | `config.default_success_message` |
24
+ | Default error message | `config.default_error_message` |
25
+ | Include request ID? | `config.include_request_id` |
26
+ | Camelize keys? | `config.camelize_keys` |
27
+ | Extra global meta fields | `config.default_meta` (merged with api_version) |
28
+ | Custom serializer stub? | Commented example added to initializer |
29
+
30
+ **Example output — `config/initializers/respondo.rb`:**
31
+ ```ruby
32
+ # frozen_string_literal: true
33
+
34
+ # Respondo initializer — MyApp
35
+ # Generated by: rails generate respondo:install
36
+ # Respondo version: 2.1.0
37
+
38
+ Respondo.configure do |config|
39
+
40
+ # ── Messages ─────────────────────────────────────────────────────────
41
+ config.default_success_message = "Success"
42
+ config.default_error_message = "Something went wrong"
43
+
44
+ # ── Request ID ───────────────────────────────────────────────────────
45
+ config.include_request_id = true
46
+
47
+ # ── Key Format ───────────────────────────────────────────────────────
48
+ config.camelize_keys = true
49
+
50
+ # ── Global Meta ──────────────────────────────────────────────────────
51
+ config.default_meta = {
52
+ api_version: "v1",
53
+ platform: "mobile"
54
+ }
55
+
56
+ # ── Custom Serializer ────────────────────────────────────────────────
57
+ # config.serializer = ->(obj) { MySerializer.new(obj).as_json }
58
+
59
+ end
60
+ ```
61
+
62
+ **Generator file location:**
63
+ ```
64
+ lib/generators/respondo/install/install_generator.rb
65
+ ```
66
+
67
+ Rails auto-discovers this path — no manual require needed. Re-running the
68
+ generator overwrites the existing initializer with fresh answers.
69
+
70
+ ---
71
+
72
+ ## [2.0.0] — Full HTTP Coverage
73
+
74
+ ### Breaking Changes
75
+
76
+ #### Pagination API completely redesigned
77
+ The old approach auto-detected Kaminari, Pagy, and WillPaginate collections and
78
+ extracted pagination metadata silently. This was over-engineered — Respondo is a
79
+ **response formatter**, not a pagination library.
80
+
81
+ **Before (1.x):**
82
+ ```ruby
83
+ # Kaminari / WillPaginate — auto-detected from collection
84
+ render_ok(data: @users)
85
+
86
+ # Pagy — required a separate pagy: argument
87
+ render_ok(data: @users, pagy: @pagy)
88
+
89
+ # Suppress pagination
90
+ render_ok(data: @users, pagination: false)
91
+ ```
92
+
93
+ **After (2.x):**
94
+ ```ruby
95
+ # All libraries — you build the hash, Respondo places it in meta
96
+ render_ok(
97
+ data: @users,
98
+ pagination: {
99
+ current_page: @users.current_page,
100
+ per_page: @users.limit_value, # Kaminari
101
+ total_pages: @users.total_pages,
102
+ total_count: @users.total_count,
103
+ next_page: @users.next_page,
104
+ prev_page: @users.prev_page
105
+ }
106
+ )
107
+
108
+ # No pagination — just omit the param
109
+ render_ok(data: @user)
110
+ ```
111
+
112
+ **Why:** The caller already has the paginated data in hand. Building the hash
113
+ themselves is one extra step, but it makes the behavior completely explicit,
114
+ works with any library (or no library), and removes a hidden dependency from
115
+ the gem's internals.
116
+
117
+ **Migration steps:**
118
+ 1. Delete any `pagy:` arguments — replace with `pagination: { ... }` hash
119
+ 2. Delete any `pagination: false` arguments — just omit `pagination:` instead
120
+ 3. Remove `pagination.rb` from your gem if you vendored it
121
+
122
+ #### `render_success` signature change
123
+ - `pagy:` parameter removed
124
+ - `pagination:` parameter type changed from `Boolean` → `Hash | nil`
125
+
126
+ **Before:** `render_success(data:, message:, meta:, code:, pagy:, pagination: Boolean, status:)`
127
+ **After:** `render_success(data:, message:, meta:, code:, pagination: Hash | nil, status:)`
128
+
129
+ ---
130
+
131
+ ### Added
132
+
133
+ #### 1xx — Informational helpers (all new)
134
+ These return a JSON body for API consistency. Note that 1xx responses are
135
+ protocol-level and most HTTP clients will not receive them as normal responses.
136
+
137
+ | Helper | Code |
138
+ |--------|------|
139
+ | `render_continue` | 100 |
140
+ | `render_switching_protocols` | 101 |
141
+ | `render_processing` | 102 |
142
+ | `render_early_hints` | 103 |
143
+
144
+ #### 2xx — Additional success helpers
145
+ | Helper | Code |
146
+ |--------|------|
147
+ | `render_non_authoritative` | 203 |
148
+ | `render_reset_content` | 205 |
149
+ | `render_already_reported` | 208 |
150
+ | `render_im_used` | 226 |
151
+
152
+ #### 3xx — Redirect helpers (all new)
153
+ Pass the target URL via `meta: { redirect_url: "..." }`.
154
+
155
+ | Helper | Code |
156
+ |--------|------|
157
+ | `render_multiple_choices` | 300 |
158
+ | `render_moved_permanently` | 301 |
159
+ | `render_found` | 302 |
160
+ | `render_see_other` | 303 |
161
+ | `render_not_modified` | 304 |
162
+ | `render_temporary_redirect` | 307 |
163
+ | `render_permanent_redirect` | 308 |
164
+
165
+ #### 4xx — Additional client error helpers
166
+ | Helper | Code |
167
+ |--------|------|
168
+ | `render_proxy_auth_required` | 407 |
169
+ | `render_length_required` | 411 |
170
+ | `render_payload_too_large` | 413 |
171
+ | `render_uri_too_long` | 414 |
172
+ | `render_range_not_satisfiable` | 416 |
173
+ | `render_expectation_failed` | 417 |
174
+ | `render_im_a_teapot` | 418 |
175
+ | `render_misdirected_request` | 421 |
176
+ | `render_failed_dependency` | 424 |
177
+ | `render_too_early` | 425 |
178
+ | `render_upgrade_required` | 426 |
179
+ | `render_precondition_required` | 428 |
180
+ | `render_request_header_fields_too_large` | 431 |
181
+ | `render_unavailable_for_legal_reasons` | 451 |
182
+
183
+ #### 5xx — Additional server error helpers
184
+ | Helper | Code |
185
+ |--------|------|
186
+ | `render_http_version_not_supported` | 505 |
187
+ | `render_variant_also_negotiates` | 506 |
188
+ | `render_insufficient_storage` | 507 |
189
+ | `render_loop_detected` | 508 |
190
+ | `render_not_extended` | 510 |
191
+ | `render_network_authentication_required` | 511 |
192
+
193
+ #### `pagination:` on all 2xx and 3xx helpers
194
+ Previously only `render_ok` exposed a pagination parameter. Now every 2xx and
195
+ 3xx helper accepts `pagination: Hash | nil` so you can include pagination meta
196
+ from any success response type, not just 200.
197
+
198
+ ---
199
+
200
+ ### Removed
201
+
202
+ - `pagination.rb` — entire file deleted. Auto-detection of Kaminari, Pagy, and
203
+ WillPaginate is no longer part of the gem. Respondo has zero pagination
204
+ library dependencies.
205
+ - `pagy:` parameter from `render_success` and `render_ok`
206
+ - `pagination: Boolean` flag — no longer needed since passing `nil` (the default)
207
+ simply omits the key from meta
208
+
209
+ ---
210
+
211
+ ### Stats
212
+
213
+ | | v1.0.0 | v2.0.0 |
214
+ |---|---|---|
215
+ | Total helpers | 7 | 57 |
216
+ | HTTP codes covered | 13 | 52 |
217
+ | Files | 7 | 6 (pagination.rb removed) |
218
+ | Pagination gem dependencies | 3 (optional) | 0 |
219
+
220
+ ---
221
+
3
222
  ## [1.0.0] — Production Ready
4
223
 
5
224
  ### Breaking Changes