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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b48bd839081e93bf86ae68587a35c6f3ad07fc4d
4
- data.tar.gz: a0ce83bc5177c74503d82b744126f0f02931093c
2
+ SHA256:
3
+ metadata.gz: 3420ea754f34bea0b246202e61f6aec0df6d32a5c0ec7898d44c7deea6839a62
4
+ data.tar.gz: 7791099085278d8dc3947222ab0cae339154b8ec56d3ce96512403031b18b37c
5
5
  SHA512:
6
- metadata.gz: cde98287cc82bc74923286973dc18cf83c04847943bc5bbc86652ac59b7391272b2b41a336cfbc47f2da9f3cc2dbf3c0f381a0dde76040a5a00d36d87848ca5d
7
- data.tar.gz: 9d4179add815dcb6c5732c8c8501ba407298d97a1ac78c749e1499e85dede8a6b2d146c6e48e6db890df171f426f3a78e85469f2eed9aafe22f52b085245b015
6
+ metadata.gz: 0bf7cdd63680130290bc38bdaea3b33c971a98bfcb06f8c059d0e5d686bc50733454f4cf68e8e1b91f1ba3e19f2dda61cf790bcaeb30473b8b57bb4cb34a02d6
7
+ data.tar.gz: a3583c074377ed6739c27346a9746a6ac3cf389be390d348b0f91f2becf622b572c73a89d802ef74cbdade59edc61e50d4df0e0e8674b34af84d18de527f79f8
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /spec/examples.txt
10
+ .ruby-version
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://img.shields.io/travis/pragmarb/pragma-operation.svg?maxAge=3600&style=flat-square)](https://travis-ci.org/pragmarb/pragma-operation)
4
- [![Dependency Status](https://img.shields.io/gemnasium/pragmarb/pragma-operation.svg?maxAge=3600&style=flat-square)](https://gemnasium.com/github.com/pragmarb/pragma-operation)
5
- [![Code Climate](https://img.shields.io/codeclimate/github/pragmarb/pragma-operation.svg?maxAge=3600&style=flat-square)](https://codeclimate.com/github/pragmarb/pragma-operation)
6
- [![Coveralls](https://img.shields.io/coveralls/pragmarb/pragma-operation.svg?maxAge=3600&style=flat-square)](https://coveralls.io/github/pragmarb/pragma-operation)
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
 
@@ -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.
@@ -11,7 +11,7 @@ module Pragma
11
11
  @meta = meta
12
12
  end
13
13
 
14
- def as_json
14
+ def as_json(*)
15
15
  {
16
16
  error_type: error_type,
17
17
  error_message: error_message,
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pragma
4
4
  module Operation
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.0'
6
6
  end
7
7
  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.0.0
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: 2017-09-27 00:00:00.000000000 Z
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.6.13
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.