Skip to content

Commit a77e8cc

Browse files
author
蔡耀賢
committed
Merge branch 'update-packages' into 'master'
Update packages See merge request kdanmobile/shared-code-base/gems/error_response!38
2 parents 8717469 + 319274b commit a77e8cc

13 files changed

Lines changed: 122 additions & 74 deletions

.gitlab-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ stages:
1111

1212
rspec:
1313
stage: rspec
14-
image: ruby:3.2.2
14+
image: ruby:3.4.5
1515
tags:
1616
- arm64
1717
script:
18-
- bundle install
18+
- bundle install
1919
- rspec spec
2020
only:
2121
- master
2222

2323
to_gem:
2424
stage: publish
25-
image: ruby:3.2.2
25+
image: ruby:3.4.5
2626
tags:
2727
- arm64
2828
script:
@@ -35,4 +35,4 @@ to_gem:
3535
- gem build error_response.gemspec
3636
- gem push $GEM_NAME
3737
only:
38-
- master
38+
- /release-\d+\.\d+\.\d+(\.\d+)?/

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.2
1+
3.4.5

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [1.1.5] - 2025-07-16
2+
- Update development_dependency.
3+
- Update require `active_support/concern` instead of `active_support/all`.
4+
- Optimize rspec test.
5+
- Update CI to use Ruby 3.4.5.
6+
- Fix Deserialization of untrusted data [CWE-502](https://cwe.mitre.org/data/definitions/502.html) by using `YAML.safe_load`.
17
## [1.1.4] - 2023-11-06
28
- Update Gemfile.lock, fix Active Support security issue [CVE-2023-38037](https://github.com/advisories/GHSA-cr5q-6q9f-rq6q).
39
## [1.1.3] - 2023-05-18

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
gem 'irb'
6-
gem 'rspec'
5+
gem 'irb', '~> 1.15.2'
6+
gem 'rspec', '~> 3.13.1'

Gemfile.lock

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,72 @@
11
PATH
22
remote: .
33
specs:
4-
error_response (1.1.4)
4+
error_response (1.1.5)
55

66
GEM
77
remote: https://rubygems.org/
88
specs:
9-
activesupport (6.1.7.6)
9+
activesupport (7.1.5.1)
10+
base64
11+
benchmark (>= 0.3)
12+
bigdecimal
1013
concurrent-ruby (~> 1.0, >= 1.0.2)
14+
connection_pool (>= 2.2.5)
15+
drb
1116
i18n (>= 1.6, < 2)
17+
logger (>= 1.4.2)
1218
minitest (>= 5.1)
19+
mutex_m
20+
securerandom (>= 0.3)
1321
tzinfo (~> 2.0)
14-
zeitwerk (~> 2.3)
15-
concurrent-ruby (1.2.2)
16-
diff-lcs (1.5.0)
17-
i18n (1.14.1)
22+
base64 (0.3.0)
23+
benchmark (0.4.1)
24+
bigdecimal (3.2.2)
25+
concurrent-ruby (1.3.5)
26+
connection_pool (2.5.3)
27+
diff-lcs (1.6.2)
28+
drb (2.2.3)
29+
i18n (1.14.7)
1830
concurrent-ruby (~> 1.0)
19-
io-console (0.5.11)
20-
irb (1.4.1)
21-
reline (>= 0.3.0)
22-
minitest (5.20.0)
23-
reline (0.3.1)
31+
io-console (0.8.1)
32+
irb (1.15.2)
33+
pp (>= 0.6.0)
34+
rdoc (>= 4.0.0)
35+
reline (>= 0.4.2)
36+
logger (1.7.0)
37+
minitest (5.25.5)
38+
mutex_m (0.3.0)
39+
pp (0.6.2)
40+
prettyprint
41+
prettyprint (0.2.0)
42+
rdoc (6.3.4.1)
43+
reline (0.6.1)
2444
io-console (~> 0.5)
25-
rspec (3.11.0)
26-
rspec-core (~> 3.11.0)
27-
rspec-expectations (~> 3.11.0)
28-
rspec-mocks (~> 3.11.0)
29-
rspec-core (3.11.0)
30-
rspec-support (~> 3.11.0)
31-
rspec-expectations (3.11.0)
45+
rspec (3.13.1)
46+
rspec-core (~> 3.13.0)
47+
rspec-expectations (~> 3.13.0)
48+
rspec-mocks (~> 3.13.0)
49+
rspec-core (3.13.5)
50+
rspec-support (~> 3.13.0)
51+
rspec-expectations (3.13.5)
3252
diff-lcs (>= 1.2.0, < 2.0)
33-
rspec-support (~> 3.11.0)
34-
rspec-mocks (3.11.1)
53+
rspec-support (~> 3.13.0)
54+
rspec-mocks (3.13.5)
3555
diff-lcs (>= 1.2.0, < 2.0)
36-
rspec-support (~> 3.11.0)
37-
rspec-support (3.11.0)
56+
rspec-support (~> 3.13.0)
57+
rspec-support (3.13.4)
58+
securerandom (0.4.1)
3859
tzinfo (2.0.6)
3960
concurrent-ruby (~> 1.0)
40-
zeitwerk (2.6.12)
4161

4262
PLATFORMS
4363
ruby
4464

4565
DEPENDENCIES
46-
activesupport (~> 6.1.7.6)
66+
activesupport (~> 7.1.5.1)
4767
error_response!
48-
irb
49-
rspec
68+
irb (~> 1.15.2)
69+
rspec (~> 3.13.1, ~> 3.0)
5070

5171
BUNDLED WITH
52-
2.4.21
72+
2.7.0

README.md

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ end
5757

5858
### Success Response
5959

60-
The success response is used when the request is success.
60+
The success response is used when the request is success. The response body is a hash with a `data` key.
6161

6262
```ruby
6363
# in controller actions
6464
data = { a: 1, b: 2 }
6565
return success_response(data) if success?
6666
```
6767

68+
> response status: 200
69+
> response body:
70+
6871
```json
6972
{
70-
"status": 200,
71-
"json": {
72-
"data": {
73-
"a": 1,
74-
"b": 2
75-
}
76-
}
73+
"data": {
74+
"a": 1,
75+
"b": 2
76+
}
7777
}
7878
```
7979

@@ -86,38 +86,34 @@ The error response is used when the request is not valid. Therefore, you need to
8686
return error_response(:bad_request_1) if failed?
8787
```
8888

89+
> response status: 400
90+
> response body:
91+
8992
```json
9093
{
91-
"status": 400,
92-
"json":
93-
{
94-
"error_code": 400001,
95-
"error_message": "bad request 1",
96-
"error_key": "bad_request_1",
97-
"a": 1,
98-
"b": 2
99-
}
94+
"error_code": 400_001,
95+
"error_message": "bad request 1",
96+
"error_key": "bad_request_1"
10097
}
10198
```
10299

103-
You can also provide your custom error message and error data. If error data is a hash, it will be merged into the json response; if it is an array, it will be merged into the json response with an `error_data` key.
100+
You can also provide your custom error message and error data. If error data is a hash, it will be merged into the json response; If it is an array, it will be merged into the json response with an `error_data` key.
104101

105102
```ruby
106103
# in controller actions
107-
return error_response(:bad_request_1, 'no required data', { a: 1, b: 2}) if failed?
104+
return error_response(:bad_request_1, 'no required data', { a: 1, b: 2 }) if failed?
108105
```
109106

107+
> response status: 400
108+
> response body:
109+
110110
```json
111111
{
112-
"status": 400,
113-
"json":
114-
{
115-
"error_code": 400001,
116-
"error_message": "bad request 1",
117-
"error_key": "bad_request_1",
118-
"a": 1,
119-
"b": 2
120-
}
112+
"error_code": 400_001,
113+
"error_message": "bad request 1: no required data",
114+
"error_key": "bad_request_1",
115+
"a": 1,
116+
"b": 2
121117
}
122118
```
123119

@@ -147,9 +143,12 @@ ErrorResponse.to_hash(:bad_request_1)
147143

148144
gives you
149145

146+
> response status: 400
147+
> response body:
148+
150149
```json
151150
{
152-
"error_code": 400001,
151+
"error_code": 400_001,
153152
"error_message": "bad request 1",
154153
"error_key": "bad_request_1"
155154
}

VERSION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.4
1+
1.1.5

config/error_response.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source:
22
local:
3-
- config/error_4xx.yml
3+
- config/local_error_404.yml
44
remote:
55
- https://raw.githubusercontent.com/kdan-mobile-software-ltd/error_response/master/config/error_4xx.yml

config/local_error_404.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resource_not_found:
2+
error_code: 404_001
3+
error_message: resource not found

error_response.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ Gem::Specification.new do |s|
1616
"changelog_uri" => "https://github.com/kdan-mobile-software-ltd/error_response/blob/master/CHANGELOG.md"
1717
}
1818

19-
s.add_development_dependency 'activesupport', '~> 6.1.7.6'
19+
s.add_development_dependency 'activesupport', '~> 7.1.5.1'
20+
s.add_development_dependency 'rspec', '~> 3.0'
2021
end

0 commit comments

Comments
 (0)