evt-record_invocation 0.0.0.1 → 2.0.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: 9286aafeff050f48304ee7d1ecfdf7462a09f877e45f86e2ccdc536b6fe569e9
4
- data.tar.gz: 73bf724b5da53d0f5a368d90cdb09d89fb14d23968783711be6e1a02450af67e
3
+ metadata.gz: d305cde21b14c9d8f7a3d1a81309b2af541cd451908786b0fe14f20c9349c38e
4
+ data.tar.gz: fa594fea44a3621bfc8f1c96f38ff7eade778652389b49fd058f2b876774acdd
5
5
  SHA512:
6
- metadata.gz: cb1e92066779e1ece523d12f0802965e13341664472ff865a7840aca85765ff86536c7005062490eca94ccf53899bd660e23f3bc7fd4ef414ad8cf104a075bb8
7
- data.tar.gz: dd9e917020122113263d1bf3922001dabecfec1e50c91848a8a1d4f480cd9b3abfd45c3b67cb4e0eda1eeee56acb02b2a4f61d3ab6a68f7525f76db03a5441e2
6
+ metadata.gz: 1fec1e0e12635e57c5b86bc4573e49847767dc52f38a3e78a084f1877cb1acbd79a72030e5d80438c5df395785c35e1b0a0a67d2a768d1cce8ff3ede2bdf5d3e
7
+ data.tar.gz: 93a7416dfeabb71fe3758b9fcb755ef1bcf4e8760095e9a63c00114180b132a258cbca598ebb7547cdd997f70ff4d985df602cd80d2b0aa12de6ec803ca54b85
@@ -14,6 +14,40 @@ module RecordInvocation
14
14
  def self.method_name
15
15
  :some_method
16
16
  end
17
+
18
+ module MixedParameters
19
+ def self.example(...)
20
+ instance = Example.new()
21
+ instance.some_method(...)
22
+ end
23
+
24
+ class Example
25
+ def some_method(
26
+ some_parameter,
27
+ some_optional_parameter=nil,
28
+ *some_multiple_assignment_parameter,
29
+ some_keyword_parameter:,
30
+ some_optional_keyword_parameter: nil,
31
+ **some_multiple_assignment_keyword_parameter,
32
+ &some_block
33
+ )
34
+ ::Invocation.build(binding)
35
+ end
36
+ end
37
+ end
38
+
39
+ module NoParameters
40
+ def self.example
41
+ subject = Example.new
42
+ subject.some_method
43
+ end
44
+
45
+ class Example
46
+ def some_method
47
+ ::Invocation.build(binding)
48
+ end
49
+ end
50
+ end
17
51
  end
18
52
  end
19
53
  end
@@ -0,0 +1,28 @@
1
+ class Invocation
2
+ attr_reader :method_name
3
+ attr_reader :arguments
4
+
5
+ def initialize(method_name, arguments)
6
+ @method_name = method_name
7
+ @arguments = arguments
8
+ end
9
+
10
+ def self.build(bndg)
11
+ instance = bndg.receiver
12
+ method_name = bndg.eval("__method__")
13
+
14
+ mthd = instance.method(method_name)
15
+
16
+ parameters = mthd.parameters
17
+ parameter_names = parameters.map { |p| p[1] }
18
+
19
+ argument_values = parameter_names.map { |n| bndg.local_variable_get(n) }
20
+
21
+ params = {}
22
+ parameter_names.each_with_index do |n, i|
23
+ params[n] = argument_values[i]
24
+ end
25
+
26
+ new(method_name, params)
27
+ end
28
+ end
@@ -29,8 +29,8 @@ module RecordInvocation
29
29
  alias :record_invocation :__record_invocation
30
30
 
31
31
  def __invocation(method_name, **parameters)
32
- strict = parameters.delete(:strict)
33
- strict ||= false
32
+ once = parameters.delete(:once)
33
+ once ||= false
34
34
 
35
35
  invocations = __invocations(method_name, **parameters)
36
36
 
@@ -38,7 +38,7 @@ module RecordInvocation
38
38
  return nil
39
39
  end
40
40
 
41
- if strict && invocations.length > 1
41
+ if once && invocations.length > 1
42
42
  raise Error, "More than one invocation record matches (Method Name: #{method_name.inspect}, Parameters: #{parameters.inspect})"
43
43
  end
44
44
 
@@ -47,7 +47,7 @@ module RecordInvocation
47
47
  alias :invocation :__invocation
48
48
 
49
49
  def __one_invocation(method_name, **parameters)
50
- parameters[:strict] = true
50
+ parameters[:once] = true
51
51
  __invocation(method_name, **parameters)
52
52
  end
53
53
  alias :one_invocation :__one_invocation
@@ -84,8 +84,8 @@ module RecordInvocation
84
84
  return !__records.empty?
85
85
  end
86
86
 
87
- if not parameters.key?(:strict)
88
- parameters[:strict] = false
87
+ if not parameters.key?(:once)
88
+ parameters[:once] = false
89
89
  end
90
90
 
91
91
  invocation = __invocation(method_name, **parameters)
@@ -94,7 +94,7 @@ module RecordInvocation
94
94
  alias :invoked? :__invoked?
95
95
 
96
96
  def __invoked_once?(method_name, **parameters)
97
- parameters[:strict] = true
97
+ parameters[:once] = true
98
98
  __invoked?(method_name, **parameters)
99
99
  end
100
100
  alias :invoked_once? :__invoked_once?
@@ -1,3 +1,4 @@
1
1
  require 'invocation'
2
2
 
3
+ require 'record_invocation/invocation'
3
4
  require 'record_invocation/record_invocation'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-record_invocation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.1
4
+ version: 2.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-16 00:00:00.000000000 Z
11
+ date: 2023-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-invocation
@@ -48,6 +48,7 @@ files:
48
48
  - lib/record_invocation/controls.rb
49
49
  - lib/record_invocation/controls/invocation.rb
50
50
  - lib/record_invocation/controls/recorder.rb
51
+ - lib/record_invocation/invocation.rb
51
52
  - lib/record_invocation/record_invocation.rb
52
53
  homepage: https://github.com/eventide-project/record-invocation
53
54
  licenses:
@@ -71,6 +72,6 @@ requirements: []
71
72
  rubygems_version: 3.4.6
72
73
  signing_key:
73
74
  specification_version: 4
74
- summary: Record method invocations, query method invocations, and use predicates to
75
- verify a method's invocation
75
+ summary: Record method invocations, query the invocations, and use predicates to verify
76
+ a method's invocation
76
77
  test_files: []