repres-dosser 1.9 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38dd3e21bae4516608b6615d6450f603b31a176d2e79930a71928a04d70262bb
|
4
|
+
data.tar.gz: 1b88c040c9289b231cb89782f1ff2dfdc76b768e5ac6d4fa00d21713c97d50da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fb70cddbb1f1f53aefee5a0a5d8b0149dee901e6f7ac9a3ad8b7f5c77c981eda4883694b8595dcafd981ab1d9955307856d675d0ec3d90077b3dd09592a887d
|
7
|
+
data.tar.gz: fc56d86c9757fefd47af674fae896216a309de406a86642a3fe5cb39c4e0f032d5be17e01186b302e4df68891d4e8cf5cab638de12f76782a22567c269d39264
|
@@ -22,7 +22,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
22
22
|
attr_writer :criteria
|
23
23
|
|
24
24
|
##
|
25
|
-
# 返回 HTTP 状态码 200
|
25
|
+
# 返回 HTTP 状态码 200 OK 。
|
26
26
|
def render_ok(
|
27
27
|
success: true,
|
28
28
|
code: self.class::CODE_SUCCESS,
|
@@ -40,7 +40,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
40
40
|
end
|
41
41
|
|
42
42
|
##
|
43
|
-
# 返回 HTTP 状态码 201 。
|
43
|
+
# 返回 HTTP 状态码 201 Created 。
|
44
44
|
def render_created(
|
45
45
|
success: true,
|
46
46
|
code: self.class::CODE_SUCCESS,
|
@@ -58,7 +58,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
58
58
|
end
|
59
59
|
|
60
60
|
##
|
61
|
-
# 返回 HTTP 状态码 202 。
|
61
|
+
# 返回 HTTP 状态码 202 Accepted 。
|
62
62
|
def render_accepted(
|
63
63
|
success: true,
|
64
64
|
code: self.class::CODE_SUCCESS,
|
@@ -76,7 +76,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
79
|
-
# 返回 HTTP 状态码 204 。
|
79
|
+
# 返回 HTTP 状态码 204 No Content 。
|
80
80
|
def render_no_content(
|
81
81
|
success: true,
|
82
82
|
code: self.class::CODE_SUCCESS,
|
@@ -94,7 +94,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
94
94
|
end
|
95
95
|
|
96
96
|
##
|
97
|
-
# 返回 HTTP 状态码 400 。
|
97
|
+
# 返回 HTTP 状态码 400 Bad Request 。
|
98
98
|
def render_bad_request(
|
99
99
|
success: false,
|
100
100
|
code: self.class::CODE_FAILURE_WRONG_PARAMETER,
|
@@ -112,7 +112,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
112
112
|
end
|
113
113
|
|
114
114
|
##
|
115
|
-
# 返回 HTTP 状态码 401 。
|
115
|
+
# 返回 HTTP 状态码 401 Unauthorized 。
|
116
116
|
def render_unauthorized(
|
117
117
|
success: false,
|
118
118
|
code: self.class::CODE_FAILURE,
|
@@ -130,7 +130,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
130
130
|
end
|
131
131
|
|
132
132
|
##
|
133
|
-
# 返回 HTTP 状态码 403
|
133
|
+
# 返回 HTTP 状态码 403 Forbidden 。
|
134
134
|
def render_forbidden(
|
135
135
|
success: false,
|
136
136
|
code: self.class::CODE_FAILURE_FORBIDDEN,
|
@@ -148,7 +148,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
148
148
|
end
|
149
149
|
|
150
150
|
##
|
151
|
-
# 返回 HTTP 状态码 404 。
|
151
|
+
# 返回 HTTP 状态码 404 Not Found 。
|
152
152
|
def render_not_found(
|
153
153
|
success: false,
|
154
154
|
code: self.class::CODE_FAILURE_NOT_FOUND,
|
@@ -181,7 +181,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
181
181
|
=end
|
182
182
|
|
183
183
|
##
|
184
|
-
# 返回 HTTP 状态码 409 。
|
184
|
+
# 返回 HTTP 状态码 409 Conflict 。
|
185
185
|
def render_conflict(
|
186
186
|
success: false,
|
187
187
|
code: self.class::CODE_FAILURE_WRONG_STATE,
|
@@ -199,7 +199,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
199
199
|
end
|
200
200
|
|
201
201
|
##
|
202
|
-
# 返回 HTTP 状态码 500
|
202
|
+
# 返回 HTTP 状态码 500 Internal Server Error 。如:
|
203
|
+
# render_internal_server_error
|
203
204
|
def render_internal_server_error(
|
204
205
|
success: false,
|
205
206
|
code: self.class::CODE_FAILURE,
|
@@ -216,6 +217,11 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
216
217
|
errors: errors
|
217
218
|
end
|
218
219
|
|
220
|
+
##
|
221
|
+
# 根据参数,计算分页结果。如:
|
222
|
+
# paginate total_items: 88, per_page: 10, current_page: 9
|
223
|
+
# 返回
|
224
|
+
# { total_items: 88, per_page: 10, current_page: 9, total_pages: 9, min_item_on_current_page: 80, max_item_on_current_page: 87, items_on_current_page: 8 }
|
219
225
|
def paginate(total_items: 0, per_page: 0, current_page: 1)
|
220
226
|
total_items = total_items.to_i
|
221
227
|
per_page = per_page.to_i
|
@@ -235,6 +241,15 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
235
241
|
|
236
242
|
end
|
237
243
|
|
244
|
+
##
|
245
|
+
# 按照给定的参数响应结果。此为内部方法。如:
|
246
|
+
# respond_result :ok,
|
247
|
+
# success: true,
|
248
|
+
# code: 'success',
|
249
|
+
# message: '成功',
|
250
|
+
# collection: [ { id: 'id-1', name: 'name-1' }, { id: 'id-2', name: 'name-2' } ],
|
251
|
+
# size: 2,
|
252
|
+
# errors: {}
|
238
253
|
def respond_result(status, result)
|
239
254
|
result[:meta] = { criteria: @criteria, request_id: request.uuid, timestamp: Time.now.to_i }
|
240
255
|
result[:meta][:pagination] = @pagination if @pagination.present?
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repres-dosser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
description: Repres (REsource PRESentation) is a series of resource presentation engines.
|
28
28
|
The Dosser (DOmain-Specific SEmantic Representation) resource presentation engine
|
29
29
|
includes JSON and XML resource presentation templates. Repres (资源表现)是一系列的资源表现引擎。Dosser
|
@@ -84,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.6.4
|
87
|
+
rubygems_version: 3.1.2
|
89
88
|
signing_key:
|
90
89
|
specification_version: 4
|
91
90
|
summary: Dosser Resource Presentation Engine 领域特定语意表现资源表现引擎
|