respondo 2.0.0 → 2.1.1
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 +4 -4
- data/CHANGELOG.md +127 -0
- data/README.md +272 -31
- data/lib/generators/respondo/install/install_generator.rb +350 -0
- data/lib/respondo/controller_helpers.rb +1 -1
- data/lib/respondo/response_builder.rb +0 -22
- data/lib/respondo/version.rb +1 -1
- data/respondo.gemspec +13 -4
- metadata +25 -6
- data/lib/respondo/pagination.rb +0 -152
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbe7751852587a50eb66e9d18128db0f0b98295f6e309ea1db812d2c6802827e
|
|
4
|
+
data.tar.gz: d59797929ccbf67f507eba232a36c04f5642318b1f3992aa0251f3949b4ed284
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3d210ee9413164b2d0b80b4c84e8f238ffac624145704dbabfb4a09242d655460e18ecd0591cd010a43a5a9c37d1b0a1ad6086ac0ab8f0a7e36536f0d6b16c3
|
|
7
|
+
data.tar.gz: 8683372f8e107d696b62d6f5e69e9f693638ce3dc50f21775d54820781c987fae14e924bce00c126b83747ce8ef14857652582a7a1e0d1c881c1536c7c4bbfe5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,132 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.1] — Bug Fix
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
#### `render_no_content` — status mismatch corrected
|
|
8
|
+
Previously `render_no_content` was sending `status: :ok` (200) while setting
|
|
9
|
+
`code: 204` in the meta block. This meant the HTTP response status was 200
|
|
10
|
+
but the meta claimed 204 — inconsistent and misleading to clients.
|
|
11
|
+
|
|
12
|
+
**Before (buggy):**
|
|
13
|
+
```ruby
|
|
14
|
+
def render_no_content(message: "Deleted successfully", meta: {}, pagination: nil)
|
|
15
|
+
render_success(data: nil, message: message, meta: meta, pagination: pagination, code: 204, status: :ok)
|
|
16
|
+
# ^^^^^^^^^^
|
|
17
|
+
# wrong — sends 200
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**After (fixed):**
|
|
22
|
+
```ruby
|
|
23
|
+
def render_no_content(message: "Deleted successfully", meta: {}, pagination: nil)
|
|
24
|
+
render_success(data: nil, message: message, meta: meta, pagination: pagination, code: 204, status: :no_content)
|
|
25
|
+
# ^^^^^^^^^^^^^^^^^^
|
|
26
|
+
# correct — sends 204
|
|
27
|
+
end
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Why body is kept:** HTTP spec discourages a body on 204 but does not
|
|
31
|
+
strictly forbid it. Respondo keeps the JSON body so FE clients can display
|
|
32
|
+
the `message` field on delete confirmations. Rails and all major HTTP clients
|
|
33
|
+
(Axios, Fetch, OkHttp) handle this correctly.
|
|
34
|
+
|
|
35
|
+
**Migration:** No changes needed — method signature is identical. If you were
|
|
36
|
+
relying on the incorrect 200 status in tests, update your assertions to
|
|
37
|
+
expect 204.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
#### `respondo.gemspec` — corrected `bug_tracker_uri`
|
|
42
|
+
A stray `auditron/` path segment was present in the `bug_tracker_uri` metadata
|
|
43
|
+
field, producing a broken link on RubyGems.
|
|
44
|
+
|
|
45
|
+
**Before:**
|
|
46
|
+
```ruby
|
|
47
|
+
"bug_tracker_uri" => "#{spec.homepage}/auditron/issues"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**After:**
|
|
51
|
+
```ruby
|
|
52
|
+
"bug_tracker_uri" => "#{spec.homepage}/issues"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### `response_builder.rb` — removed stale commented-out code
|
|
56
|
+
A dead `build_meta` implementation was left commented out from a previous
|
|
57
|
+
refactor. Removed to keep the file clean and readable.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## [2.1.0] — Interactive Install Generator
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
#### `rails generate respondo:install` — interactive setup wizard
|
|
66
|
+
A new generator that walks developers through configuration interactively at
|
|
67
|
+
install time, writing a fully commented `config/initializers/respondo.rb` so
|
|
68
|
+
they never have to read the README to get started.
|
|
69
|
+
|
|
70
|
+
**Usage:**
|
|
71
|
+
```bash
|
|
72
|
+
rails generate respondo:install
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**What the wizard collects:**
|
|
76
|
+
|
|
77
|
+
| Prompt | Config written |
|
|
78
|
+
|--------|---------------|
|
|
79
|
+
| Project / app name | Comment header in initializer |
|
|
80
|
+
| API version | Auto-added to `config.default_meta` |
|
|
81
|
+
| Default success message | `config.default_success_message` |
|
|
82
|
+
| Default error message | `config.default_error_message` |
|
|
83
|
+
| Include request ID? | `config.include_request_id` |
|
|
84
|
+
| Camelize keys? | `config.camelize_keys` |
|
|
85
|
+
| Extra global meta fields | `config.default_meta` (merged with api_version) |
|
|
86
|
+
| Custom serializer stub? | Commented example added to initializer |
|
|
87
|
+
|
|
88
|
+
**Example output — `config/initializers/respondo.rb`:**
|
|
89
|
+
```ruby
|
|
90
|
+
# frozen_string_literal: true
|
|
91
|
+
|
|
92
|
+
# Respondo initializer — MyApp
|
|
93
|
+
# Generated by: rails generate respondo:install
|
|
94
|
+
# Respondo version: 2.1.0
|
|
95
|
+
|
|
96
|
+
Respondo.configure do |config|
|
|
97
|
+
|
|
98
|
+
# ── Messages ─────────────────────────────────────────────────────────
|
|
99
|
+
config.default_success_message = "Success"
|
|
100
|
+
config.default_error_message = "Something went wrong"
|
|
101
|
+
|
|
102
|
+
# ── Request ID ───────────────────────────────────────────────────────
|
|
103
|
+
config.include_request_id = true
|
|
104
|
+
|
|
105
|
+
# ── Key Format ───────────────────────────────────────────────────────
|
|
106
|
+
config.camelize_keys = true
|
|
107
|
+
|
|
108
|
+
# ── Global Meta ──────────────────────────────────────────────────────
|
|
109
|
+
config.default_meta = {
|
|
110
|
+
api_version: "v1",
|
|
111
|
+
platform: "mobile"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# ── Custom Serializer ────────────────────────────────────────────────
|
|
115
|
+
# config.serializer = ->(obj) { MySerializer.new(obj).as_json }
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Generator file location:**
|
|
121
|
+
```
|
|
122
|
+
lib/generators/respondo/install/install_generator.rb
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Rails auto-discovers this path — no manual require needed. Re-running the
|
|
126
|
+
generator overwrites the existing initializer with fresh answers.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
3
130
|
## [2.0.0] — Full HTTP Coverage
|
|
4
131
|
|
|
5
132
|
### Breaking Changes
|