porch 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: a4465a58cd1f427a90f98c0fe4287da4a95a591c
4
- data.tar.gz: 3c9117fc73b0f17b88e1a6d6a44a3c549269886a
3
+ metadata.gz: 8ca5b85da7d6e9f54bdb5474e15320cdb7eb5045
4
+ data.tar.gz: fa4803e50502d7bc92816de9857a05c82ec49d2a
5
5
  SHA512:
6
- metadata.gz: 283ed8cbacd23252b660d4f64cd538851b1f15463f3b3e84534cc8eb260b721018a1cc6a9c6c0eec0816763811c6ce8dfbfbafe64a10c5fa1404b283d0fc2686
7
- data.tar.gz: 0809d2abafa5631ac04752b8dcc0c21864e364b38be31fe1068a4a33a7a44d2513beb491ce0422bea66325644f882092028c2ac4d6b75111c944a1b8f5b188a2
6
+ metadata.gz: 4be1ef22ded594338c326c1623d9d3dd74f2bece271514f426cc7e4870bb7db059f72e6e430d24c4dabfe2c79b1a4273ccc239bbfa4c4c84101196488f2c6894
7
+ data.tar.gz: 83dfc12f0b384a384faa0b9023234d64c0d83b1f2774772de23886ed20026288d12d5574f97254029433dd6dbc8d7eccab706f914412471f6e5f092ac6534e79
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- porch (0.1.0)
4
+ porch (0.2.0)
5
5
  dry-validation (~> 0.10.4)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Porch
2
2
  ======
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/porch.svg)](https://badge.fury.io/rb/porch)
5
+
4
6
  [ ![Codeship Status for jwright/porch](https://app.codeship.com/projects/8780ad70-b5ae-0134-fb0d-62cbe9f5cc84/status?branch=master)](https://app.codeship.com/projects/194128)
5
7
 
6
8
  A simple service layer pattern for plain old Ruby objects.
@@ -125,7 +127,7 @@ module Services
125
127
  def register
126
128
  with(attributes) do |chain|
127
129
  # ...
128
- chain.add :send_welcome_email do |context|
130
+ chain.add do |context|
129
131
  UserMailer.welcome(context.user).deliver_later
130
132
  end
131
133
  # ...
data/lib/porch/context.rb CHANGED
@@ -20,7 +20,7 @@ module Porch
20
20
  def fail!(message="")
21
21
  @message = message
22
22
  @success = false
23
- throw :stop_current_step_execution, self
23
+ raise Porch::ContextStoppedError.new(self)
24
24
  end
25
25
 
26
26
  def failure?
@@ -34,7 +34,7 @@ module Porch
34
34
  end
35
35
 
36
36
  def guard!(&block)
37
- result = guard &block
37
+ result = Guard.new(self).against(&block)
38
38
  fail!(HumanError.new(result.errors).message) if result.failure?
39
39
  result
40
40
  end
@@ -48,9 +48,9 @@ module Porch
48
48
  !!@skip_remaining
49
49
  end
50
50
 
51
- def skip_remaining!(skip_current=false)
51
+ def skip_remaining!
52
52
  @skip_remaining = true
53
- throw :stop_current_step_execution, self if skip_current
53
+ raise Porch::ContextStoppedError.new(self)
54
54
  end
55
55
 
56
56
  def success?
@@ -0,0 +1,9 @@
1
+ module Porch
2
+ class ContextStoppedError < RuntimeError
3
+ attr_reader :context
4
+
5
+ def initialize(context)
6
+ @context = context
7
+ end
8
+ end
9
+ end
data/lib/porch/errors.rb CHANGED
@@ -1 +1,2 @@
1
+ require_relative "errors/context_stopped_error"
1
2
  require_relative "errors/invalid_step_type_error"
@@ -16,7 +16,12 @@ module Porch
16
16
 
17
17
  def execute(context)
18
18
  catch :stop_current_step_execution do
19
- decorated_step.execute context
19
+ begin
20
+ decorated_step.execute context
21
+ rescue Porch::ContextStoppedError => e
22
+ # this exception is just used for flow control
23
+ e.context
24
+ end
20
25
  end
21
26
  end
22
27
 
data/lib/porch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Porch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: porch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Wright
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation
@@ -86,6 +86,7 @@ files:
86
86
  - lib/porch/core_ext.rb
87
87
  - lib/porch/core_ext/string.rb
88
88
  - lib/porch/errors.rb
89
+ - lib/porch/errors/context_stopped_error.rb
89
90
  - lib/porch/errors/invalid_step_type_error.rb
90
91
  - lib/porch/executable_step_decorator.rb
91
92
  - lib/porch/guard_rail.rb
@@ -97,6 +98,7 @@ files:
97
98
  - lib/porch/step_decorators/method_step_decorator.rb
98
99
  - lib/porch/step_decorators/proc_step_decorator.rb
99
100
  - lib/porch/version.rb
101
+ - pkg/porch-0.1.0.gem
100
102
  - porch.gemspec
101
103
  homepage: https://github.com/jwright/porch
102
104
  licenses: