evt-mimic 2.5.0.1 → 2.6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mimic/build.rb +1 -1
- data/lib/mimic/controls/recorder.rb +1 -1
- data/lib/mimic/controls/subject/mixed_parameters.rb +8 -1
- data/lib/mimic/controls.rb +1 -9
- data/lib/mimic/define_methods.rb +14 -13
- data/lib/mimic.rb +1 -2
- metadata +3 -12
- data/lib/mimic/controls/invocation.rb +0 -33
- data/lib/mimic/controls/subject/block_parameter.rb +0 -12
- data/lib/mimic/controls/subject/keyword_parameters.rb +0 -12
- data/lib/mimic/controls/subject/multiple_assignment_keyword_parameter.rb +0 -12
- data/lib/mimic/controls/subject/multiple_assignment_parameter.rb +0 -12
- data/lib/mimic/controls/subject/optional_keyword_parameters.rb +0 -12
- data/lib/mimic/controls/subject/optional_positional_parameters.rb +0 -12
- data/lib/mimic/controls/subject/positional_parameters.rb +0 -12
- data/lib/mimic/recorder.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e9696c990776dda6ba60022878f275bee23d7efcecd72df2c2c8367bd6ed1d
|
4
|
+
data.tar.gz: fdc522e7d2af9256d8642bf3e3b10d052605498eb5cd508c337d3ced1da149ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71d50c6c0d10086940879d3a8f96c600dc05c5edac5b224d5bfec467712e8ff173bdf90840fb0bd28291682365eebdd168031ef7bb50803854e063e92a8818ab
|
7
|
+
data.tar.gz: d211119fa50570bfbdacc8a1806702aa00349fc565cdc6122b0701ad5f248c607f465e534419cd6e47a580479c228f06e0fb94742b30fcf704e5d2b859805ed3
|
data/lib/mimic/build.rb
CHANGED
@@ -3,7 +3,14 @@ module Mimic
|
|
3
3
|
module Subject
|
4
4
|
module MixedParameters
|
5
5
|
class Example
|
6
|
-
def some_method(
|
6
|
+
def some_method(
|
7
|
+
some_parameter,
|
8
|
+
some_optional_parameter=nil,
|
9
|
+
*some_multiple_assignment_parameter,
|
10
|
+
some_keyword_parameter:,
|
11
|
+
some_optional_keyword_parameter: nil,
|
12
|
+
**some_multiple_assignment_keyword_parameter,
|
13
|
+
&some_block)
|
7
14
|
end
|
8
15
|
end
|
9
16
|
end
|
data/lib/mimic/controls.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
require 'mimic/controls/subject'
|
2
2
|
require 'mimic/controls/subject/no_parameters'
|
3
|
-
require 'mimic/controls/subject/positional_parameters'
|
4
|
-
require 'mimic/controls/subject/optional_positional_parameters'
|
5
|
-
require 'mimic/controls/subject/keyword_parameters'
|
6
|
-
require 'mimic/controls/subject/optional_keyword_parameters'
|
7
|
-
require 'mimic/controls/subject/block_parameter'
|
8
|
-
require 'mimic/controls/subject/multiple_assignment_parameter'
|
9
|
-
require 'mimic/controls/subject/multiple_assignment_keyword_parameter'
|
10
|
-
require 'mimic/controls/subject/mixed_parameters'
|
11
3
|
require 'mimic/controls/subject/delegated_parameters'
|
12
|
-
require 'mimic/controls/
|
4
|
+
require 'mimic/controls/subject/mixed_parameters'
|
13
5
|
require 'mimic/controls/recorder'
|
14
6
|
require 'mimic/controls/mimic'
|
data/lib/mimic/define_methods.rb
CHANGED
@@ -19,8 +19,8 @@ module Mimic
|
|
19
19
|
|
20
20
|
def self.method_definition(mthd, record)
|
21
21
|
"
|
22
|
-
#{signature(mthd)}
|
23
|
-
|
22
|
+
#{record ? "record " : "" }#{signature(mthd)}
|
23
|
+
Void.new
|
24
24
|
end
|
25
25
|
"
|
26
26
|
end
|
@@ -77,19 +77,20 @@ module Mimic
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
##
|
81
|
+
# def self.body(record)
|
82
|
+
# body = ''
|
83
|
+
# if record
|
84
|
+
# body << <<~RECORD
|
85
|
+
# invocation = Invocation.build(binding)
|
86
|
+
# __record(invocation)
|
87
|
+
# RECORD
|
88
|
+
# end
|
88
89
|
|
89
|
-
|
90
|
+
# body << "Void.new"
|
90
91
|
|
91
|
-
|
92
|
-
end
|
92
|
+
# body
|
93
|
+
# end
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
data/lib/mimic.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'record_invocation'
|
4
4
|
|
5
5
|
require 'mimic/preserved_methods'
|
6
6
|
require 'mimic/subject_methods'
|
@@ -9,5 +9,4 @@ require 'mimic/build'
|
|
9
9
|
require 'mimic/void'
|
10
10
|
require 'mimic/remove_methods'
|
11
11
|
require 'mimic/define_methods'
|
12
|
-
require 'mimic/recorder'
|
13
12
|
require 'mimic/mimic'
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-mimic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.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-
|
11
|
+
date: 2023-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: evt-
|
14
|
+
name: evt-record_invocation
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -48,26 +48,17 @@ files:
|
|
48
48
|
- lib/mimic/build.rb
|
49
49
|
- lib/mimic/class.rb
|
50
50
|
- lib/mimic/controls.rb
|
51
|
-
- lib/mimic/controls/invocation.rb
|
52
51
|
- lib/mimic/controls/mimic.rb
|
53
52
|
- lib/mimic/controls/recorder.rb
|
54
53
|
- lib/mimic/controls/subject.rb
|
55
|
-
- lib/mimic/controls/subject/block_parameter.rb
|
56
54
|
- lib/mimic/controls/subject/delegated_parameters.rb
|
57
|
-
- lib/mimic/controls/subject/keyword_parameters.rb
|
58
55
|
- lib/mimic/controls/subject/mixed_parameters.rb
|
59
|
-
- lib/mimic/controls/subject/multiple_assignment_keyword_parameter.rb
|
60
|
-
- lib/mimic/controls/subject/multiple_assignment_parameter.rb
|
61
56
|
- lib/mimic/controls/subject/no_parameters.rb
|
62
|
-
- lib/mimic/controls/subject/optional_keyword_parameters.rb
|
63
|
-
- lib/mimic/controls/subject/optional_positional_parameters.rb
|
64
|
-
- lib/mimic/controls/subject/positional_parameters.rb
|
65
57
|
- lib/mimic/define_methods.rb
|
66
58
|
- lib/mimic/mimic.rb
|
67
59
|
- lib/mimic/predicates.rb
|
68
60
|
- lib/mimic/predicates/method/parameters.rb
|
69
61
|
- lib/mimic/preserved_methods.rb
|
70
|
-
- lib/mimic/recorder.rb
|
71
62
|
- lib/mimic/remove_methods.rb
|
72
63
|
- lib/mimic/subject_methods.rb
|
73
64
|
- lib/mimic/void.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Mimic
|
2
|
-
module Controls
|
3
|
-
module Invocation
|
4
|
-
def self.example
|
5
|
-
parameters = {}
|
6
|
-
parameters[:some_parameter] = 1
|
7
|
-
parameters[:some_other_parameter] = 11
|
8
|
-
|
9
|
-
invocation = ::Invocation.new(method_name, parameters)
|
10
|
-
|
11
|
-
invocation
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.other_example
|
15
|
-
parameters = {}
|
16
|
-
parameters[:some_parameter] = 111
|
17
|
-
parameters[:some_other_parameter] = 1111
|
18
|
-
|
19
|
-
invocation = ::Invocation.new(other_method_name, parameters)
|
20
|
-
|
21
|
-
invocation
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.method_name
|
25
|
-
:some_method
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.other_method_name
|
29
|
-
:some_other_method
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/mimic/recorder.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
module Mimic
|
2
|
-
module Recorder
|
3
|
-
Error = ::Class.new(RuntimeError)
|
4
|
-
|
5
|
-
attr_writer :__records
|
6
|
-
def __records
|
7
|
-
@__records ||= []
|
8
|
-
end
|
9
|
-
alias :records :__records
|
10
|
-
alias :records= :__records=
|
11
|
-
|
12
|
-
def __record(invocation)
|
13
|
-
__records << invocation
|
14
|
-
end
|
15
|
-
alias :record :__record
|
16
|
-
|
17
|
-
def __invocation(method_name, **parameters)
|
18
|
-
strict = parameters.delete(:strict)
|
19
|
-
strict ||= false
|
20
|
-
|
21
|
-
invocations = __invocations(method_name, **parameters)
|
22
|
-
|
23
|
-
if invocations.empty?
|
24
|
-
return nil
|
25
|
-
end
|
26
|
-
|
27
|
-
if strict && invocations.length > 1
|
28
|
-
raise Error, "More than one invocation record matches (Method Name: #{method_name.inspect}, Parameters: #{parameters.inspect})"
|
29
|
-
end
|
30
|
-
|
31
|
-
invocations.first
|
32
|
-
end
|
33
|
-
alias :invocation :__invocation
|
34
|
-
|
35
|
-
def __one_invocation(method_name, **parameters)
|
36
|
-
parameters[:strict] = true
|
37
|
-
__invocation(method_name, **parameters)
|
38
|
-
end
|
39
|
-
alias :one_invocation :__one_invocation
|
40
|
-
|
41
|
-
def __invocations(method_name=nil, **parameters)
|
42
|
-
if method_name.nil? && parameters.empty?
|
43
|
-
return __records
|
44
|
-
end
|
45
|
-
|
46
|
-
invocations = __records.select { |invocation| invocation.method_name == method_name }
|
47
|
-
|
48
|
-
if parameters.nil?
|
49
|
-
return invocations
|
50
|
-
end
|
51
|
-
|
52
|
-
if invocations.empty?
|
53
|
-
return []
|
54
|
-
end
|
55
|
-
|
56
|
-
invocations = invocations.select do |invocation|
|
57
|
-
parameters.all? do |match_parameter_name, match_parameter_value|
|
58
|
-
invocation_value = invocation.parameters[match_parameter_name]
|
59
|
-
|
60
|
-
invocation_value == match_parameter_value
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
invocations
|
65
|
-
end
|
66
|
-
alias :invocations :__invocations
|
67
|
-
|
68
|
-
def __invoked?(method_name=nil, **parameters)
|
69
|
-
if method_name.nil? && parameters.empty?
|
70
|
-
return !__records.empty?
|
71
|
-
end
|
72
|
-
|
73
|
-
if not parameters.key?(:strict)
|
74
|
-
parameters[:strict] = false
|
75
|
-
end
|
76
|
-
|
77
|
-
invocation = __invocation(method_name, **parameters)
|
78
|
-
!invocation.nil?
|
79
|
-
end
|
80
|
-
alias :invoked? :__invoked?
|
81
|
-
|
82
|
-
def __invoked_once?(method_name, **parameters)
|
83
|
-
parameters[:strict] = true
|
84
|
-
__invoked?(method_name, **parameters)
|
85
|
-
end
|
86
|
-
alias :invoked_once? :__invoked_once?
|
87
|
-
end
|
88
|
-
end
|