repres-dosser 1.8.3 → 1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/app/controllers/repres/dosser/application_controller.rb +3 -0
- data/app/controllers/repres/dosser/concerns/resource_presentation.rb +27 -14
- data/app/jobs/repres/dosser/application_job.rb +3 -0
- data/app/mailers/repres/dosser/application_mailer.rb +3 -0
- data/app/models/repres/dosser/application_record.rb +3 -0
- data/app/views/layouts/repres/dosser/application.html.erb +1 -1
- data/lib/repres/dosser/models_rspec.rb +0 -0
- data/lib/repres/dosser/types_rspec.rb +0 -0
- data/lib/repres/dosser/validators_rspec.rb +0 -0
- data/lib/repres/dosser/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6225ace816757924b0affa10b971289536da5842
|
4
|
+
data.tar.gz: 936f844a42e192bec54e3b55bf1d7864052ca664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa35156c795e372b4d71a3858413f7d954c7631264bf686e0c895ace7b83c2dd7cc28ee1bf4481e82cc69d98d953f039abbb60895b6027aa446393a9c267bd2
|
7
|
+
data.tar.gz: 529ff9d1c7ed8c6cfa40d2e9f1a5e56ad4b474ca605448f88f9f988eb5b3e5b7b73c38f959405d2d61b38b2cdbc6ff80f725ad207f5c7cdcf7fd8f7da5c6f45e
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Repres Dosser 领域特定语意表现引擎
|
2
2
|
|
3
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/repres-dosser/frames)
|
3
4
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
5
|
+
|
4
6
|
[![Gem Version](https://badge.fury.io/rb/repres-dosser.svg)](https://badge.fury.io/rb/repres-dosser)
|
5
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/repres-dosser.svg)](https://gemnasium.com/github.com/topbitdu/repres-dosser)
|
6
8
|
|
@@ -167,3 +169,18 @@ before insert the swagger_engine & the latest repres-dosser gem into the Gemfile
|
|
167
169
|
config/initializers/swagger_engine.rb
|
168
170
|
lib/swagger/administration_api_v2.json
|
169
171
|
```
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
## RSpec examples
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
# spec/models/unidom_spec.rb
|
179
|
+
require 'repres/dosser/models_rspec'
|
180
|
+
|
181
|
+
# spec/types/unidom_spec.rb
|
182
|
+
require 'repres/dosser/types_rspec'
|
183
|
+
|
184
|
+
# spec/validators/unidom_spec.rb
|
185
|
+
require 'repres/dosser/validators_rspec'
|
186
|
+
```
|
@@ -1,3 +1,10 @@
|
|
1
|
+
##
|
2
|
+
# Resource Presentation 是 DOSSER 风格的资源表现逻辑的关注点。
|
3
|
+
# HTTP 状态码可参考以下链接:
|
4
|
+
# https://httpstatuses.com/
|
5
|
+
# http://www.restapitutorial.com/httpstatuscodes.html
|
6
|
+
# http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
|
7
|
+
|
1
8
|
module Repres::Dosser::Concerns::ResourcePresentation
|
2
9
|
|
3
10
|
extend ActiveSupport::Concern
|
@@ -14,11 +21,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
14
21
|
|
15
22
|
attr_writer :criteria
|
16
23
|
|
17
|
-
|
18
|
-
#
|
19
|
-
# http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
|
20
|
-
|
21
|
-
# 200
|
24
|
+
##
|
25
|
+
# 返回 HTTP 状态码 200 ok 。
|
22
26
|
def render_ok(
|
23
27
|
success: true,
|
24
28
|
code: self.class::CODE_SUCCESS,
|
@@ -35,7 +39,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
35
39
|
errors: errors
|
36
40
|
end
|
37
41
|
|
38
|
-
|
42
|
+
##
|
43
|
+
# 返回 HTTP 状态码 201 。
|
39
44
|
def render_created(
|
40
45
|
success: true,
|
41
46
|
code: self.class::CODE_SUCCESS,
|
@@ -52,7 +57,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
52
57
|
errors: errors
|
53
58
|
end
|
54
59
|
|
55
|
-
|
60
|
+
##
|
61
|
+
# 返回 HTTP 状态码 202 。
|
56
62
|
def render_accepted(
|
57
63
|
success: true,
|
58
64
|
code: self.class::CODE_SUCCESS,
|
@@ -69,7 +75,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
69
75
|
errors: errors
|
70
76
|
end
|
71
77
|
|
72
|
-
|
78
|
+
##
|
79
|
+
# 返回 HTTP 状态码 204 。
|
73
80
|
def render_no_content(
|
74
81
|
success: true,
|
75
82
|
code: self.class::CODE_SUCCESS,
|
@@ -86,7 +93,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
86
93
|
errors: errors
|
87
94
|
end
|
88
95
|
|
89
|
-
|
96
|
+
##
|
97
|
+
# 返回 HTTP 状态码 400 。
|
90
98
|
def render_bad_request(
|
91
99
|
success: false,
|
92
100
|
code: self.class::CODE_FAILURE_WRONG_PARAMETER,
|
@@ -103,7 +111,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
103
111
|
errors: errors
|
104
112
|
end
|
105
113
|
|
106
|
-
|
114
|
+
##
|
115
|
+
# 返回 HTTP 状态码 401 。
|
107
116
|
def render_unauthorized(
|
108
117
|
success: false,
|
109
118
|
code: self.class::CODE_FAILURE,
|
@@ -120,7 +129,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
120
129
|
errors: errors
|
121
130
|
end
|
122
131
|
|
123
|
-
|
132
|
+
##
|
133
|
+
# 返回 HTTP 状态码 403 forbidden 。
|
124
134
|
def render_forbidden(
|
125
135
|
success: false,
|
126
136
|
code: self.class::CODE_FAILURE_FORBIDDEN,
|
@@ -137,7 +147,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
137
147
|
errors: errors
|
138
148
|
end
|
139
149
|
|
140
|
-
|
150
|
+
##
|
151
|
+
# 返回 HTTP 状态码 404 。
|
141
152
|
def render_not_found(
|
142
153
|
success: false,
|
143
154
|
code: self.class::CODE_FAILURE_NOT_FOUND,
|
@@ -169,7 +180,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
169
180
|
end
|
170
181
|
=end
|
171
182
|
|
172
|
-
|
183
|
+
##
|
184
|
+
# 返回 HTTP 状态码 409 。
|
173
185
|
def render_conflict(
|
174
186
|
success: false,
|
175
187
|
code: self.class::CODE_FAILURE_WRONG_STATE,
|
@@ -186,7 +198,8 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
186
198
|
errors: errors
|
187
199
|
end
|
188
200
|
|
189
|
-
|
201
|
+
##
|
202
|
+
# 返回 HTTP 状态码 500 。
|
190
203
|
def render_internal_server_error(
|
191
204
|
success: false,
|
192
205
|
code: self.class::CODE_FAILURE,
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repres-dosser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.9'
|
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: 2017-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -60,6 +60,9 @@ files:
|
|
60
60
|
- lib/generators/repres/dosser/swagger/templates/lib/swagger/api.json.erb
|
61
61
|
- lib/repres/dosser.rb
|
62
62
|
- lib/repres/dosser/engine.rb
|
63
|
+
- lib/repres/dosser/models_rspec.rb
|
64
|
+
- lib/repres/dosser/types_rspec.rb
|
65
|
+
- lib/repres/dosser/validators_rspec.rb
|
63
66
|
- lib/repres/dosser/version.rb
|
64
67
|
- lib/tasks/dosser_tasks.rake
|
65
68
|
homepage: https://github.com/topbitdu/repres-dosser
|