stable 1.16.3 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/example/kw_calculator.rb +6 -0
- data/lib/stable/fact.rb +7 -4
- data/lib/stable/version.rb +1 -1
- data/lib/stable.rb +5 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48fc9fb3259b016fbd50f2f39b0bbcd8e2ed793de661fcf62510153336f9bf1b
|
4
|
+
data.tar.gz: e5c14b2a616353cccf9562ef39d1d83aaddf56ddb770412df69e0679d3f053af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57cb96d32e8edbaf0fcac195b2d295c2010e0c64e6a6f62a6a5101c6c3f8c9d7c5fc072bb098c8766d34f4a214419e580f866f5a2ff7419dffb16f895694cc1a
|
7
|
+
data.tar.gz: 82e1bb9b223bb5dbeb8dca3ef613d310de66fd6b8ebcf79f1d99f761b4ffa16929c6e223682fa924f6f8aaa5ff197da3e7eb75da5ce8fecded8bc02a656ed924
|
data/lib/stable/fact.rb
CHANGED
@@ -8,17 +8,18 @@ module Stable
|
|
8
8
|
# outputs. it's a self-contained, serializable representation of a method's
|
9
9
|
# behavior at a specific point in time.
|
10
10
|
class Fact
|
11
|
-
attr_reader :class_name, :method_name, :args, :result, :error, :actual_result, :actual_error, :status, :uuid, :signature, :name, :source_file
|
11
|
+
attr_reader :class_name, :method_name, :args, :kwargs, :result, :error, :actual_result, :actual_error, :status, :uuid, :signature, :name, :source_file
|
12
12
|
|
13
|
-
def initialize(class_name:, method_name:, args:, result: nil, error: nil, uuid: SecureRandom.uuid, name: nil, source_file: nil)
|
13
|
+
def initialize(class_name:, method_name:, args:, kwargs: {}, result: nil, error: nil, uuid: SecureRandom.uuid, name: nil, source_file: nil)
|
14
14
|
@class_name = class_name
|
15
15
|
@method_name = method_name
|
16
16
|
@args = args
|
17
|
+
@kwargs = (kwargs || {}).transform_keys(&:to_sym)
|
17
18
|
@result = result
|
18
19
|
@error = error
|
19
20
|
@status = :pending
|
20
21
|
@uuid = uuid
|
21
|
-
@signature = Digest::SHA256.hexdigest("#{class_name}##{method_name}:#{args.to_json}")
|
22
|
+
@signature = Digest::SHA256.hexdigest("#{class_name}##{method_name}:#{args.to_json}:#{kwargs.to_json}")
|
22
23
|
@name = name || uuid.split('-').last
|
23
24
|
@source_file = source_file
|
24
25
|
end
|
@@ -33,7 +34,7 @@ module Stable
|
|
33
34
|
begin
|
34
35
|
klass = Object.const_get(class_name)
|
35
36
|
instance = klass.new
|
36
|
-
@actual_result = instance.public_send(method_name, *args)
|
37
|
+
@actual_result = instance.public_send(method_name, *args, **kwargs)
|
37
38
|
if error
|
38
39
|
@status = :failed
|
39
40
|
elsif actual_result == result
|
@@ -74,6 +75,7 @@ module Stable
|
|
74
75
|
class: class_name,
|
75
76
|
method: method_name,
|
76
77
|
args: args,
|
78
|
+
kwargs: kwargs,
|
77
79
|
result: result,
|
78
80
|
error: error,
|
79
81
|
uuid: uuid,
|
@@ -88,6 +90,7 @@ module Stable
|
|
88
90
|
class_name: data['class'],
|
89
91
|
method_name: data['method'],
|
90
92
|
args: data['args'],
|
93
|
+
kwargs: data['kwargs'],
|
91
94
|
result: data['result'],
|
92
95
|
error: data['error'],
|
93
96
|
uuid: data['uuid'],
|
data/lib/stable/version.rb
CHANGED
data/lib/stable.rb
CHANGED
@@ -60,14 +60,15 @@ module Stable
|
|
60
60
|
def watch(klass, method_name)
|
61
61
|
original_method = klass.instance_method(method_name)
|
62
62
|
wrapper_module = Module.new do
|
63
|
-
define_method(method_name) do |*args, &block|
|
63
|
+
define_method(method_name) do |*args, **kwargs, &block|
|
64
64
|
if Stable.enabled?
|
65
65
|
begin
|
66
|
-
result = original_method.bind(self).call(*args, &block)
|
66
|
+
result = original_method.bind(self).call(*args, **kwargs, &block)
|
67
67
|
fact = Fact.new(
|
68
68
|
class_name: klass.name,
|
69
69
|
method_name: method_name,
|
70
70
|
args: args,
|
71
|
+
kwargs: kwargs,
|
71
72
|
result: result
|
72
73
|
)
|
73
74
|
unless Stable.send(:_fact_exists?, fact.signature)
|
@@ -81,6 +82,7 @@ module Stable
|
|
81
82
|
class_name: klass.name,
|
82
83
|
method_name: method_name,
|
83
84
|
args: args,
|
85
|
+
kwargs: kwargs,
|
84
86
|
error: {
|
85
87
|
class: e.class.name,
|
86
88
|
message: e.message,
|
@@ -95,7 +97,7 @@ module Stable
|
|
95
97
|
raise e
|
96
98
|
end
|
97
99
|
else
|
98
|
-
original_method.bind(self).call(*args, &block)
|
100
|
+
original_method.bind(self).call(*args, **kwargs, &block)
|
99
101
|
end
|
100
102
|
end
|
101
103
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
@@ -30,6 +30,7 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
32
|
- lib/example/calculator.rb
|
33
|
+
- lib/example/kw_calculator.rb
|
33
34
|
- lib/stable.rb
|
34
35
|
- lib/stable/configuration.rb
|
35
36
|
- lib/stable/fact.rb
|