respondo 2.1.1 → 2.1.3

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: fbe7751852587a50eb66e9d18128db0f0b98295f6e309ea1db812d2c6802827e
4
- data.tar.gz: d59797929ccbf67f507eba232a36c04f5642318b1f3992aa0251f3949b4ed284
3
+ metadata.gz: eac53474dd61508e20d695e46cc364e3bf9ebdb0b89a6e1b4ae93eda15ebc7b7
4
+ data.tar.gz: 8f1035182c1795269fe3266473bdf4b67bcfa56fcdaf10d6593c5e56739a955c
5
5
  SHA512:
6
- metadata.gz: d3d210ee9413164b2d0b80b4c84e8f238ffac624145704dbabfb4a09242d655460e18ecd0591cd010a43a5a9c37d1b0a1ad6086ac0ab8f0a7e36536f0d6b16c3
7
- data.tar.gz: 8683372f8e107d696b62d6f5e69e9f693638ce3dc50f21775d54820781c987fae14e924bce00c126b83747ce8ef14857652582a7a1e0d1c881c1536c7c4bbfe5
6
+ metadata.gz: b9540985dd09e11ee39c87cccccc13b9056f07cb762a8b6523a5e1a1666cdb4e0e8ca1ab6dfd9305706c5d48386c73bd5dfbabc070b05c7a1d92d08877fd5ba4
7
+ data.tar.gz: 53bdf553e918de4f9b4e0a3df8fc3fb894fcbe0efaae7a2daeaa97990a18974b8b80d18b094d2fa2f8f10c7098fae0c01067394c3b6be6fb45766e5f68dd04b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,123 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.3] — Docs & Dependency Updates
4
+
5
+ ### Changed
6
+ - README updated (add a one-line summary of what you changed)
7
+ - Development dependencies updated to patched versions, fixing CVEs in
8
+ `concurrent-ruby`, `erb` and `rails-html-sanitizer`. These are test-only
9
+ dependencies, so there is no change to the gem's runtime behavior.
10
+
11
+ ## [2.1.2] — Code Quality & Test Coverage
12
+
13
+ ### Fixed
14
+
15
+ #### `controller_helpers.rb` — `render_success` and `render_error` made private
16
+ Previously `render_success` and `render_error` were public methods, meaning any
17
+ controller could call them directly — bypassing the semantic named helpers
18
+ (`render_ok`, `render_created`, `render_forbidden`, etc.) and undermining the
19
+ gem's design intent.
20
+
21
+ **Before (public — bypassable):**
22
+ ```ruby
23
+ # Any controller could do this, skipping semantic intent entirely
24
+ render_success(data: @user, status: :created)
25
+ render_error(message: "bad", status: :not_found)
26
+ ```
27
+
28
+ **After (private — enforced through named helpers only):**
29
+ ```ruby
30
+ # Correct usage — callers must use the named helpers
31
+ render_created(data: @user)
32
+ render_not_found(message: "User not found")
33
+ ```
34
+
35
+ **Why:** The named helpers encode the correct HTTP status code, default
36
+ message, and meta code for each scenario. Allowing direct calls to
37
+ `render_success` / `render_error` lets callers set arbitrary status/code
38
+ combinations that break the consistency guarantee.
39
+
40
+ **Migration:** Replace any direct `render_success` / `render_error` calls in
41
+ your controllers with the appropriate named helper. All named helpers remain
42
+ public and their signatures are unchanged.
43
+
44
+ ---
45
+
46
+ #### `response_builder.rb` — replaced `defined?(Time.current)` with `Time.respond_to?(:current)`
47
+ The original guard used Ruby's `defined?` keyword to check for Rails'
48
+ `Time.current`. However, `defined?(Time.current)` always returns `"method"`
49
+ as long as the `Time` constant exists — making the `else` branch permanently
50
+ unreachable even in non-Rails environments.
51
+
52
+ **Before (broken guard — else branch unreachable):**
53
+ ```ruby
54
+ def current_timestamp
55
+ if defined?(Time.current) # always truthy — else never runs
56
+ Time.current.iso8601
57
+ else
58
+ Time.now.utc.iso8601 # dead code
59
+ end
60
+ end
61
+ ```
62
+
63
+ **After (correct guard — both branches reachable):**
64
+ ```ruby
65
+ def current_timestamp
66
+ if Time.respond_to?(:current) # false outside Rails
67
+ Time.current.iso8601
68
+ else
69
+ Time.now.utc.iso8601 # correctly used in plain Ruby
70
+ end
71
+ end
72
+ ```
73
+
74
+ **Why:** `respond_to?` correctly returns `false` in plain Ruby environments
75
+ where ActiveSupport is not loaded, allowing the `Time.now.utc` fallback to
76
+ actually execute. Behaviour in Rails is identical since `Time.respond_to?(:current)`
77
+ returns `true` when ActiveSupport is present.
78
+
79
+ ---
80
+
81
+ #### `install_generator.rb` — blank `api_version` no longer writes empty key to initializer
82
+ Previously, if a user entered a blank api_version at the prompt, the generator
83
+ would write `api_version: ""` into the initializer's `default_meta` block —
84
+ a meaningless empty string that would be sent in every API response.
85
+
86
+ **Before (wrote empty key):**
87
+ ```ruby
88
+ meta = { "api_version" => @cfg[:api_version] }.merge(@cfg[:default_meta])
89
+ # If api_version is "" → writes: api_version: ""
90
+ ```
91
+
92
+ **After (omits blank api_version):**
93
+ ```ruby
94
+ meta = @cfg[:default_meta].dup
95
+ meta["api_version"] = @cfg[:api_version] unless @cfg[:api_version].to_s.empty?
96
+ # If api_version is "" → key is cleanly omitted
97
+ # If no extra meta either → writes: config.default_meta = {}
98
+ ```
99
+
100
+ **Why:** An empty `api_version` key adds noise to every response's meta block
101
+ with no value. The generator now omits it cleanly, and the previously
102
+ unreachable `config.default_meta = {}` branch is now correctly written when
103
+ both `api_version` is blank and no extra meta fields were added.
104
+
105
+ ---
106
+
107
+ ### Changed
108
+
109
+ #### Test coverage improved from 97.92% → 100%
110
+ All previously uncovered branches are now exercised:
111
+
112
+ | File | Branch previously missed | Fix |
113
+ |------|--------------------------|-----|
114
+ | `controller_helpers.rb` | `extract_errors` — `ActiveModel::Errors`, `Array`, `String`, and unknown-type paths | Added `send(:extract_errors, ...)` specs |
115
+ | `response_builder.rb` | `else` branch of `current_timestamp` (non-Rails fallback) | Fixed guard + added branch specs |
116
+ | `install_generator.rb` | `if meta.empty?` branch in `build_content` | Fixed generator logic + added spec |
117
+ | `serializer.rb` | `serialize_record` — `elsif respond_to?(:to_h)` and `else` (bare record) | Added `serialize_record` branch specs |
118
+
119
+ ---
120
+
3
121
  ## [2.1.1] — Bug Fix
4
122
 
5
123
  ### Fixed