haku 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/haku/core.rb +14 -28
- data/lib/haku/result.rb +10 -4
- data/lib/haku/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b65774c4966531378070fabd031b8bdb943b10b7ec18f6fea1424d00d5ab382d
|
4
|
+
data.tar.gz: 7505219941e0b0dcb7189671dcf9a8593f3cdaa6d9c893b0b4ba6c438c6ee56b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e310f74ec63fe80d30381b56e36515311786dc6e8c13b065dab9d99a93ee6c9b87891582017f0de199c3e7e18d5ea2534adc9f7927633151127a2abb236fec91
|
7
|
+
data.tar.gz: c9ca7c513ec7cb2f92b9719071e84d0817d8722480274409b1937aa33062995845eb979bd91314ee41337756dcfe6faa55e7cfe8170fd89aae9a92056cbe92fa
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/haku/core.rb
CHANGED
@@ -44,12 +44,17 @@ module Haku
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
Finish = Struct.new("Finish", :status, :payload)
|
48
|
+
|
47
49
|
module Callable
|
48
50
|
def call
|
49
|
-
|
51
|
+
response = catch(:finish) { super }
|
52
|
+
|
53
|
+
status = response.is_a?(Finish) ? response.status : :success
|
54
|
+
payload = response.is_a?(Finish) ? response.payload : response
|
50
55
|
|
51
|
-
Result.new(
|
52
|
-
_haku_run_callbacks
|
56
|
+
Result.new(status, payload).tap do
|
57
|
+
_haku_run_callbacks(status)
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
@@ -57,9 +62,6 @@ module Haku
|
|
57
62
|
def initialize(params={})
|
58
63
|
@params = params
|
59
64
|
|
60
|
-
@_haku_status = :success
|
61
|
-
@_haku_response = {}
|
62
|
-
|
63
65
|
self.class.haku_inputs.each do |name|
|
64
66
|
define_singleton_method(name) { @params[name] } unless respond_to?(name)
|
65
67
|
end
|
@@ -67,32 +69,16 @@ module Haku
|
|
67
69
|
|
68
70
|
private
|
69
71
|
|
70
|
-
def success!(
|
71
|
-
|
72
|
-
@_haku_response = _haku_normalize_response(response)
|
73
|
-
nil
|
74
|
-
end
|
75
|
-
|
76
|
-
def failure!(response={})
|
77
|
-
@_haku_status = :failure
|
78
|
-
@_haku_response = _haku_normalize_response(response)
|
79
|
-
nil
|
80
|
-
end
|
81
|
-
|
82
|
-
def _haku_normalize_response(response)
|
83
|
-
response.is_a?(Hash) ? response : { data: response }
|
84
|
-
end
|
85
|
-
|
86
|
-
def _haku_status
|
87
|
-
@_haku_status
|
72
|
+
def success!(data=nil)
|
73
|
+
throw :finish, Finish.new(:success, data)
|
88
74
|
end
|
89
75
|
|
90
|
-
def
|
91
|
-
|
76
|
+
def failure!(data=nil)
|
77
|
+
throw :finish, Finish.new(:failure, data)
|
92
78
|
end
|
93
79
|
|
94
|
-
def _haku_run_callbacks
|
95
|
-
(self.class.send("haku_#{
|
80
|
+
def _haku_run_callbacks(status)
|
81
|
+
(self.class.send("haku_#{status}_callbacks") || []).each { |cb| send(cb) }
|
96
82
|
end
|
97
83
|
end
|
98
84
|
end
|
data/lib/haku/result.rb
CHANGED
@@ -4,15 +4,21 @@ require "active_support/string_inquirer"
|
|
4
4
|
|
5
5
|
module Haku
|
6
6
|
class Result
|
7
|
-
def initialize(status,
|
7
|
+
def initialize(status, payload)
|
8
8
|
@status = ActiveSupport::StringInquirer.new(status.to_s)
|
9
|
-
@
|
9
|
+
@payload = payload
|
10
10
|
|
11
|
-
@
|
12
|
-
|
11
|
+
return unless @payload.respond_to?(:to_h)
|
12
|
+
|
13
|
+
@payload.to_h.each_key do |key|
|
14
|
+
define_singleton_method(key) { @payload[key] }
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
18
|
+
def result
|
19
|
+
@payload
|
20
|
+
end
|
21
|
+
|
16
22
|
def success?
|
17
23
|
@status.success?
|
18
24
|
end
|
data/lib/haku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Aranda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -68,8 +68,8 @@ licenses:
|
|
68
68
|
- MIT
|
69
69
|
metadata:
|
70
70
|
homepage_uri: https://github.com/javierav/haku
|
71
|
-
source_code_uri: https://github.com/javierav/haku/tree/v1.
|
72
|
-
changelog_uri: https://github.com/javierav/haku/blob/v1.
|
71
|
+
source_code_uri: https://github.com/javierav/haku/tree/v1.2.0
|
72
|
+
changelog_uri: https://github.com/javierav/haku/blob/v1.2.0/CHANGELOG.md
|
73
73
|
rubygems_mfa_required: 'true'
|
74
74
|
post_install_message:
|
75
75
|
rdoc_options:
|