lavin 0.3.0 → 0.4.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: 52a0a48c405e0aff4b816ff7bf91b27e8407929a838db819f8777d222b4f7674
4
- data.tar.gz: 4acb3c0a928acd45ecbd8137089433e69cdc8235919a0db6fefefb40418bfd82
3
+ metadata.gz: b997f41b4113bbae1335913c59e6788e28b324128e26359b30877127d3423dcd
4
+ data.tar.gz: 3dafac5a638eab3e505422a0777e3debdfd8f52af0c51fabaf0b2259b9f62504
5
5
  SHA512:
6
- metadata.gz: e2fe666e13f22d13dc4f085e8ab7e78c2242a973bd9b0d58054e0b4ada2cc17d1ca924e4103a3c55408bd88c4d1cd3efa8b3449cee7fd8a5d36794392218779c
7
- data.tar.gz: b1f7f478a288492082a4f02462d345ce42703316638b3d6aee7848a92a539b22b750105e5e70fdf2ffe662ac26ed68a4f6a32c63154b18ba4faf96dee917b16b
6
+ metadata.gz: 828a5a27fe2eb5efabd4f17253ce583865fb7177121a2128122261f7e1e816f13c37dc60eb1686c8885b95f9c228b5df301bbd952d23cab2f32df3f8fc1befde
7
+ data.tar.gz: f84b6e46eb8b66572de9053160a247df65958476f9ab00b933d02d1a12ffcd4f07b162c2f44bcce68174f67822947254bceecdf4d36e5440387e7043240ecc51
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/lavin/error.rb CHANGED
@@ -6,4 +6,8 @@ module Lavin
6
6
  class RecoverableError < Error; end
7
7
 
8
8
  class IrrecoverableError < Error; end
9
+
10
+ class SuccessfulStep < Error; end
11
+
12
+ class SuccessfulUser < Error; end
9
13
  end
data/lib/lavin/hook.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'lavin/error'
4
+
3
5
  module Lavin
4
6
  class Hook
5
7
  attr_reader :user, :block, :type
@@ -19,11 +21,11 @@ module Lavin
19
21
  report_statistics = context.client.report_statistics
20
22
  context.client.report_statistics = false
21
23
  context.instance_exec(&block)
22
- rescue RecoverableError
24
+ rescue SuccessfulStep, RecoverableError
25
+ rescue SuccessfulUser, IrrecoverableError
26
+ throw :stop_user
23
27
  rescue => error
24
- puts "Caught #{error.class} in #{type} hook: #{error.message}"
25
- puts error.backtrace unless error.is_a? IrrecoverableError
26
- throw :failure
28
+ puts "Exception in #{user.name}.#{type} block - #{error.class}: #{error.message}"
27
29
  ensure
28
30
  context.client.report_statistics = report_statistics
29
31
  end
data/lib/lavin/step.rb CHANGED
@@ -23,10 +23,14 @@ module Lavin
23
23
  def call(context:)
24
24
  context.instance_exec(&block)
25
25
  Statistics.register_step(user: user.name, step_name: name)
26
+ rescue SuccessfulStep, SuccessfulUser => error
27
+ Statistics.register_step(user: user.name, step_name: name)
28
+ throw :stop_user if error.is_a? SuccessfulUser
26
29
  rescue IrrecoverableError => error
27
30
  Statistics.register_step(user: user.name, step_name: name, failure: error.message)
28
- throw :failure
31
+ throw :stop_user
29
32
  rescue => error
33
+ puts "Exception in #{user.name}.#{name} - #{error.class}: #{error.message}"
30
34
  Statistics.register_step(user: user.name, step_name: name, failure: error.message)
31
35
  end
32
36
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lavin/error'
4
+
5
+ module Lavin
6
+ module Success
7
+ def success
8
+ raise SuccessfulStep
9
+ end
10
+
11
+ def success!
12
+ raise SuccessfulUser
13
+ end
14
+ end
15
+ end
data/lib/lavin/user.rb CHANGED
@@ -5,6 +5,7 @@ require "lavin/user_config"
5
5
  require "lavin/worker"
6
6
  require "lavin/http_client"
7
7
  require "lavin/failure"
8
+ require "lavin/success"
8
9
 
9
10
  module Lavin
10
11
  class User
@@ -14,6 +15,7 @@ module Lavin
14
15
  subclass.include Worker
15
16
  subclass.include HttpClient
16
17
  subclass.include Failure
18
+ subclass.include Success
17
19
  all_personas << subclass
18
20
  end
19
21
 
data/lib/lavin/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lavin
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/lavin/worker.rb CHANGED
@@ -40,13 +40,13 @@ module Lavin
40
40
  end
41
41
 
42
42
  def run
43
- catch(:failure) do
43
+ catch(:stop_user) do
44
44
  self.class.before.run(context: self).then { Runner.yield } if self.class.before
45
45
 
46
46
  run_step until finished?
47
47
  end
48
48
 
49
- catch(:failure) do
49
+ catch(:stop_user) do
50
50
  self.class.after.run(context: self).then { Runner.yield } if self.class.after
51
51
  end
52
52
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lavin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Henningsson
@@ -29,7 +29,7 @@ cert_chain:
29
29
  DVzXaUnsmwP+jQ1PkDa5q8ibBzMd2c6Hmm87UDqPxZtML0bF9SjrpbyLMjwtXaMA
30
30
  WDPp0ajpdUZ9GPHsrVNYXiOfQIqcmlmpYVsH1o7vuneUIcIDMrnMDChh
31
31
  -----END CERTIFICATE-----
32
- date: 2022-11-02 00:00:00.000000000 Z
32
+ date: 2022-11-04 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: async
@@ -120,6 +120,7 @@ files:
120
120
  - lib/lavin/statistics.rb
121
121
  - lib/lavin/stats.rb
122
122
  - lib/lavin/step.rb
123
+ - lib/lavin/success.rb
123
124
  - lib/lavin/user.rb
124
125
  - lib/lavin/user_config.rb
125
126
  - lib/lavin/version.rb
metadata.gz.sig CHANGED
Binary file