civil_service 1.0.0 → 2.0.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
2
  SHA256:
3
- metadata.gz: 3505ccbce978bbeeea7a494316cd161eee31460207b6b3b2c322315089bd1442
4
- data.tar.gz: cf203b21b33f1f3b5e87a010bc3c2b8006703ca1cf1b53b1328b107264b21890
3
+ metadata.gz: c0155a0d0cbcf7c649725deedc1eb51e64ebe4f6a5f77ea4fbb6022768598afd
4
+ data.tar.gz: 82f50992961ad30130760307434340c180a459052fe4fa04c1bd295472be8a19
5
5
  SHA512:
6
- metadata.gz: 8d99b796b01ecaa22eacf3b4bea961037749c927b798d7f2b153a7114192b6a40b8d1833e014abc2c736a929d2c5250f6ea8e4f2c94445c1df4df97a1fb41ae4
7
- data.tar.gz: 73885e7a905e506e0f7c65324b370af89ed21f5df44755b40b7b44e414a5ffc75e635b6ab93e767fd910b107a18f66ac6ba20cd8ed3a34e40dca7b99fcc68068
6
+ metadata.gz: ec1adf3b57089d4849ca5ce70b2ed8b9938ee03aabd55b3e0952ee0d3cb0734e87bac765794b023c83b80276312c1e754a3ce517a97af9eaed80ac1f94e242b0
7
+ data.tar.gz: ff3622cb3f407734e8adfe0b4f844d9db437f72a642b17669920339027bdd62cf1a0aaf27d11fa4e35bcfdb2c878572579f1066cb5ec25567a6d0253dc6f32ab
@@ -0,0 +1,19 @@
1
+ # Version 2.0.0 - June 26, 2019
2
+
3
+ * BREAKING CHANGE: The behavior of `CivilService::Service#call` has changed when exceptions are
4
+ raised inside the service. The `call` method will now catch the exception and return a failing
5
+ result object, with the exception message as an error on `:base`.
6
+
7
+ The behavior of `call!` has not changed: a failing result will be raised as a
8
+ `CivilService::ServiceFailure` exception, and an exception thrown inside the service will not be
9
+ caught (and therefore will be raised to the caller).
10
+
11
+ The idea of this change is that the behaviors of `call` and `call!` are now predictable: `call`
12
+ will (almost) never raise an exception, whereas `call!` can raise an exception.
13
+
14
+ The exception to this rule (pun intended, always intend your puns) is that `call` will not catch
15
+ exceptions that don't inherit from `StandardError`, such as `SystemExit`. See
16
+ [Honeybadger's explanation](https://www.honeybadger.io/blog/a-beginner-s-guide-to-exceptions-in-ruby/)
17
+ of why this is a good idea.
18
+ * `CivilService::Result` now has an additional attribute called `exception`, which can be used to
19
+ retrieve an exception thrown inside a `call` method.
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civil_service (1.0.0)
4
+ civil_service (2.0.0)
5
5
  activemodel (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (5.1.5)
11
- activesupport (= 5.1.5)
12
- activesupport (5.1.5)
10
+ activemodel (5.2.3)
11
+ activesupport (= 5.2.3)
12
+ activesupport (5.2.3)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (~> 0.7)
14
+ i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
- concurrent-ruby (1.0.5)
18
- i18n (0.9.5)
17
+ concurrent-ruby (1.1.5)
18
+ i18n (1.6.0)
19
19
  concurrent-ruby (~> 1.0)
20
20
  minitest (5.11.3)
21
21
  rake (10.5.0)
@@ -33,4 +33,4 @@ DEPENDENCIES
33
33
  rake (~> 10.0)
34
34
 
35
35
  BUNDLED WITH
36
- 1.16.1
36
+ 1.17.2
data/README.md CHANGED
@@ -53,7 +53,7 @@ class PasswordChangeService < CivilService::Service
53
53
  success
54
54
  end
55
55
 
56
- def ensure_valid
56
+ def ensure_valid_password
57
57
  return if new_password.length >= 8
58
58
  errors.add(:base, "Passwords must be at least 8 characters long")
59
59
  end
@@ -1,6 +1,6 @@
1
1
  class CivilService::Result
2
2
  include ActiveModel::Model
3
- attr_accessor :success, :errors
3
+ attr_accessor :success, :errors, :exception
4
4
 
5
5
  def self.success(attributes = {})
6
6
  new(attributes.merge(success: true))
@@ -17,7 +17,12 @@ class CivilService::Service
17
17
  return failure(errors) unless valid?
18
18
  end
19
19
 
20
- inner_call
20
+ begin
21
+ inner_call
22
+ rescue StandardError => exception
23
+ errors.add :base, exception.message
24
+ failure(errors, exception: exception)
25
+ end
21
26
  end
22
27
 
23
28
  def call!
@@ -1,3 +1,3 @@
1
1
  module CivilService
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civil_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -77,6 +77,7 @@ extra_rdoc_files: []
77
77
  files:
78
78
  - ".gitignore"
79
79
  - ".travis.yml"
80
+ - CHANGELOG.md
80
81
  - CODE_OF_CONDUCT.md
81
82
  - Gemfile
82
83
  - Gemfile.lock
@@ -109,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.3
113
+ rubygems_version: 3.0.3
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: A tiny service object framework for Rails apps