startback 0.4.2 → 0.4.3

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
2
  SHA1:
3
- metadata.gz: 4f615659a301a7720d4b61e8e2ce714eaad98197
4
- data.tar.gz: 74a968e657dbccaf5c59e5ad1b03bcf4bd6c52e2
3
+ metadata.gz: c9175aaa7fe416e9e0fa330799a3f000fed9eb44
4
+ data.tar.gz: 9afc103aefdbcb65ee348e121d0801de5e303adf
5
5
  SHA512:
6
- metadata.gz: c3636b769a3200fd2e774cabdc99e642c81e5a29921d09ad66995f5952e89aaf73012dd2589d710055aed68fa6a6dbf664bb65e79d623d4b5daf44f1dc5de3d9
7
- data.tar.gz: 88d3d45a912a3618b154dee16a798688385351d3a3e68324674b923e1428f8bbf58a79e96e603358c4033ddb7f8a088699b6449256868f9443134fa4ddf51c4a
6
+ metadata.gz: 3731debf460f9d572bd30970e0cfed5a399d753719b986ffd485548d3cdcff9f239bf917ac8bc1d4902a34db2ad42e23ccb8d32f9a88b46c3ebab9dbd576e61f
7
+ data.tar.gz: 6f772f553bcfc9a257f24e0d5b413eb6e131b690aa438e17b22f56d198efb98e8317366540b7822e04bf6d435ba7243ce6c809ba06c7040a75c16b22fe4fb478
@@ -48,6 +48,10 @@ module Startback
48
48
  @app.call(env)
49
49
  end
50
50
 
51
+ def self.context(env)
52
+ env[RACK_ENV_KEY]
53
+ end
54
+
51
55
  end # class Middleware
52
56
  end # class Context
53
57
  end # module Startback
@@ -90,6 +90,95 @@ module Startback
90
90
  status 501
91
91
  end
92
92
 
93
+ ### Helper methods
94
+
95
+ def bad_request_error!(msg = nil)
96
+ raise Startback::Errors::BadRequestError, msg
97
+ end
98
+ module_function :bad_request_error!
99
+
100
+ def unauthorized_error!(msg = nil)
101
+ raise Startback::Errors::UnauthorizedError, msg
102
+ end
103
+ module_function :unauthorized_error!
104
+
105
+ def forbidden_error!(msg = nil)
106
+ raise Startback::Errors::ForbiddenError, msg
107
+ end
108
+ module_function :forbidden_error!
109
+
110
+ def not_found_error!(msg = nil)
111
+ raise Startback::Errors::NotFoundError, "#{msg} not found"
112
+ end
113
+ module_function :not_found_error!
114
+
115
+ def method_not_allowed_error!(msg = nil)
116
+ raise Startback::Errors::MethodNotAllowedError, msg
117
+ end
118
+ module_function :method_not_allowed_error!
119
+
120
+ def not_acceptable_error!(msg = nil)
121
+ raise Startback::Errors::NotAcceptableError, msg
122
+ end
123
+ module_function :not_acceptable_error!
124
+
125
+ def conflict_error!(msg = nil)
126
+ raise Startback::Errors::ConflictError, msg
127
+ end
128
+ module_function :conflict_error!
129
+
130
+ def gone_error!(msg = nil)
131
+ raise Startback::Errors::GoneError, msg
132
+ end
133
+ module_function :gone_error!
134
+
135
+ def precondition_failed_error!(msg = nil)
136
+ raise Startback::Errors::PreconditionFailedError, msg
137
+ end
138
+ module_function :precondition_failed_error!
139
+
140
+ def unsupported_media_type_error!(media)
141
+ raise Startback::Errors::UnsupportedMediaTypeError, "Unable to use `#{media}` as input data"
142
+ end
143
+ module_function :unsupported_media_type_error!
144
+
145
+ def expectation_failed_error!(msg = nil)
146
+ raise Startback::Errors::ExpectationFailedError, msg
147
+ end
148
+ module_function :expectation_failed_error!
149
+
150
+ def locked_error!(msg = nil)
151
+ raise Startback::Errors::LockedError, msg
152
+ end
153
+ module_function :locked_error!
154
+
155
+ def precondition_required_error!(msg = nil)
156
+ raise Startback::Errors::PreconditionRequiredError, msg
157
+ end
158
+ module_function :precondition_required_error!
159
+
160
+ def internal_server_error!(msg = nil)
161
+ raise Startback::Errors::InternalServerError, msg
162
+ end
163
+ module_function :internal_server_error!
164
+
165
+ def not_implemented_error!(msg = nil)
166
+ raise Startback::Errors::NotImplementedError, msg
167
+ end
168
+ module_function :not_implemented_error!
169
+
170
+ # Aliases
171
+
172
+ def user_error!(msg = nil)
173
+ raise Startback::Errors::BadRequestError, msg
174
+ end
175
+ module_function :user_error!
176
+
177
+ def server_error!(msg = nil)
178
+ raise Startback::Errors::InternalServerError, msg
179
+ end
180
+ module_function :server_error!
181
+
93
182
  end # module Errors
94
183
  include Errors
95
- end # module Klaro
184
+ end # module Startback
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- TINY = 2
5
+ TINY = 3
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -39,7 +39,7 @@ module Startback
39
39
  file = params[:file]
40
40
  file_body file, Path(file[:filename]).extname
41
41
  else
42
- unsupported_content_type(ctype)
42
+ unsupported_media_type_error!(ctype)
43
43
  end
44
44
  end
45
45
 
@@ -36,7 +36,7 @@ module Startback
36
36
  if context && context.respond_to?(:error_handler) && context.error_handler
37
37
  context.error_handler.fatal(ex)
38
38
  else
39
- Startback::LOGGER.fatal(ex)
39
+ Startback::LOGGER.fatal(ex.message + "\n" + ex.backtrace.join("\n"))
40
40
  end
41
41
  end
42
42
 
@@ -23,7 +23,8 @@ module Startback
23
23
  self.content_type 'application/json'
24
24
 
25
25
  # Decoding errors from json and csv are considered user's fault
26
- self.on(Finitio::TypeError) { 400 }
26
+ self.on(Finitio::TypeError){ 400 }
27
+ self.on(::NotImplementedError){ 501 }
27
28
 
28
29
  # Various other codes for the framework specific error classes
29
30
  self.on(Startback::Errors::Error) {|ex|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.5.2.3
204
+ rubygems_version: 2.6.11
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: Got Your Ruby Back