pragma-operation 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/CHANGELOG.md +29 -0
- data/README.md +4 -4
- data/lib/pragma/operation.rb +4 -0
- data/lib/pragma/operation/error.rb +1 -1
- data/lib/pragma/operation/response/internal_server_error.rb +19 -0
- data/lib/pragma/operation/response/payment_required.rb +19 -0
- data/lib/pragma/operation/response/service_unavailable.rb +19 -0
- data/lib/pragma/operation/response/unauthorized.rb +19 -0
- data/lib/pragma/operation/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3420ea754f34bea0b246202e61f6aec0df6d32a5c0ec7898d44c7deea6839a62
|
4
|
+
data.tar.gz: 7791099085278d8dc3947222ab0cae339154b8ec56d3ce96512403031b18b37c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bf7cdd63680130290bc38bdaea3b33c971a98bfcb06f8c059d0e5d686bc50733454f4cf68e8e1b91f1ba3e19f2dda61cf790bcaeb30473b8b57bb4cb34a02d6
|
7
|
+
data.tar.gz: a3583c074377ed6739c27346a9746a6ac3cf389be390d348b0f91f2becf622b572c73a89d802ef74cbdade59edc61e50d4df0e0e8674b34af84d18de527f79f8
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [2.1.0]
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Added `Unauthorized` response template
|
15
|
+
- Added `ServiceUnavailable` response template
|
16
|
+
- Added `InternalServerError` response template
|
17
|
+
- Added `PaymentRequired` response template
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- Fixed `Pragma::Operation::Error#as_json` having the wrong arity
|
22
|
+
|
23
|
+
## [2.0.0]
|
24
|
+
|
25
|
+
First Pragma 2 release.
|
26
|
+
|
27
|
+
[Unreleased]: https://github.com/pragmarb/pragma-operation/compare/v2.1.0...HEAD
|
28
|
+
[2.1.0]: https://github.com/pragmarb/pragma-operation/compare/v2.0.0...v2.1.0
|
29
|
+
[2.0.0]: https://github.com/pragmarb/pragma-operation/compare/v1.6.3...v2.0.0
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Pragma::Operation
|
2
2
|
|
3
|
-
[![Build Status](https://
|
4
|
-
[![Dependency Status](https://
|
5
|
-
[![
|
6
|
-
[![
|
3
|
+
[![Build Status](https://travis-ci.org/pragmarb/pragma-operation.svg?branch=master)](https://travis-ci.org/pragmarb/pragma-operation)
|
4
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/pragmarb/pragma-operation.svg)](https://gemnasium.com/github.com/pragmarb/pragma-operation)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/pragmarb/pragma-operation/badge.svg?branch=master)](https://coveralls.io/github/pragmarb/pragma-operation?branch=master)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/e51e8d7489eb72ab97ba/maintainability)](https://codeclimate.com/github/pragmarb/pragma-operation/maintainability)
|
7
7
|
|
8
8
|
Operations encapsulate the business logic of your JSON API.
|
9
9
|
|
data/lib/pragma/operation.rb
CHANGED
@@ -16,6 +16,10 @@ require 'pragma/operation/response/unprocessable_entity'
|
|
16
16
|
require 'pragma/operation/response/created'
|
17
17
|
require 'pragma/operation/response/ok'
|
18
18
|
require 'pragma/operation/response/no_content'
|
19
|
+
require 'pragma/operation/response/unauthorized'
|
20
|
+
require 'pragma/operation/response/service_unavailable'
|
21
|
+
require 'pragma/operation/response/internal_server_error'
|
22
|
+
require 'pragma/operation/response/payment_required'
|
19
23
|
|
20
24
|
module Pragma
|
21
25
|
# Operations provide business logic encapsulation for your JSON API.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pragma
|
4
|
+
module Operation
|
5
|
+
class Response
|
6
|
+
class InternalServerError < Response
|
7
|
+
def initialize(
|
8
|
+
entity: Error.new(
|
9
|
+
error_type: :internal_server_error,
|
10
|
+
error_message: 'There was an error processing your request.',
|
11
|
+
),
|
12
|
+
headers: {}
|
13
|
+
)
|
14
|
+
super(status: 500, entity: entity, headers: headers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pragma
|
4
|
+
module Operation
|
5
|
+
class Response
|
6
|
+
class PaymentRequired < Response
|
7
|
+
def initialize(
|
8
|
+
entity: Error.new(
|
9
|
+
error_type: :payment_required,
|
10
|
+
error_message: 'This resource requires payment.',
|
11
|
+
),
|
12
|
+
headers: {}
|
13
|
+
)
|
14
|
+
super(status: 402, entity: entity, headers: headers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pragma
|
4
|
+
module Operation
|
5
|
+
class Response
|
6
|
+
class ServiceUnavailable < Response
|
7
|
+
def initialize(
|
8
|
+
entity: Error.new(
|
9
|
+
error_type: :service_unavailable,
|
10
|
+
error_message: 'This resource is not available right now. Try later.',
|
11
|
+
),
|
12
|
+
headers: {}
|
13
|
+
)
|
14
|
+
super(status: 503, entity: entity, headers: headers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pragma
|
4
|
+
module Operation
|
5
|
+
class Response
|
6
|
+
class Unauthorized < Response
|
7
|
+
def initialize(
|
8
|
+
entity: Error.new(
|
9
|
+
error_type: :unauthorized,
|
10
|
+
error_message: 'This resource requires authentication.',
|
11
|
+
),
|
12
|
+
headers: {}
|
13
|
+
)
|
14
|
+
super(status: 401, entity: entity, headers: headers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragma-operation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-operation
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".rspec"
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- ".travis.yml"
|
122
|
+
- CHANGELOG.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
124
125
|
- README.md
|
@@ -132,9 +133,13 @@ files:
|
|
132
133
|
- lib/pragma/operation/response/bad_request.rb
|
133
134
|
- lib/pragma/operation/response/created.rb
|
134
135
|
- lib/pragma/operation/response/forbidden.rb
|
136
|
+
- lib/pragma/operation/response/internal_server_error.rb
|
135
137
|
- lib/pragma/operation/response/no_content.rb
|
136
138
|
- lib/pragma/operation/response/not_found.rb
|
137
139
|
- lib/pragma/operation/response/ok.rb
|
140
|
+
- lib/pragma/operation/response/payment_required.rb
|
141
|
+
- lib/pragma/operation/response/service_unavailable.rb
|
142
|
+
- lib/pragma/operation/response/unauthorized.rb
|
138
143
|
- lib/pragma/operation/response/unprocessable_entity.rb
|
139
144
|
- lib/pragma/operation/version.rb
|
140
145
|
- pragma-operation.gemspec
|
@@ -158,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
163
|
version: '0'
|
159
164
|
requirements: []
|
160
165
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.7.5
|
162
167
|
signing_key:
|
163
168
|
specification_version: 4
|
164
169
|
summary: Business logic encapsulation for your JSON API.
|