evt-mimic 2.5.0.1 → 2.6.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64e515b88ec2ac19e30d67f5eefc537363db005457a5e8ecc8c98604230c7140
4
- data.tar.gz: b17b01de3f590fa61b3466a869d8a9fcdd1eee36ec7700d2d024ea030ccfb8be
3
+ metadata.gz: c8e9696c990776dda6ba60022878f275bee23d7efcecd72df2c2c8367bd6ed1d
4
+ data.tar.gz: fdc522e7d2af9256d8642bf3e3b10d052605498eb5cd508c337d3ced1da149ae
5
5
  SHA512:
6
- metadata.gz: 674dd3a243991ce2f09b73946f5c77c4b117553334f34220e4dfbbb09f3f28d725cbb720fc95603a72c8b1dc032e4c35322e96f691cc006e80a4307ac975ff59
7
- data.tar.gz: d45cae25e94b062a01b139a14820455bd9bc915efd11056e17bbfedf1af7dc23a8c1e41041f19c48a93e859d6ae4efb8989d543a6943b000a3b68b388854dad3
6
+ metadata.gz: 71d50c6c0d10086940879d3a8f96c600dc05c5edac5b224d5bfec467712e8ff173bdf90840fb0bd28291682365eebdd168031ef7bb50803854e063e92a8818ab
7
+ data.tar.gz: d211119fa50570bfbdacc8a1806702aa00349fc565cdc6122b0701ad5f248c607f465e534419cd6e47a580479c228f06e0fb94742b30fcf704e5d2b859805ed3
data/lib/mimic/build.rb CHANGED
@@ -13,7 +13,7 @@ module Mimic
13
13
  ## It's about the class def
14
14
  if record
15
15
  cls.class_exec do
16
- include Recorder
16
+ include RecordInvocation
17
17
  end
18
18
  end
19
19
 
@@ -6,7 +6,7 @@ module Mimic
6
6
  end
7
7
 
8
8
  class Example
9
- include Mimic::Recorder
9
+ include RecordInvocation
10
10
  end
11
11
  end
12
12
  end
@@ -3,7 +3,14 @@ module Mimic
3
3
  module Subject
4
4
  module MixedParameters
5
5
  class Example
6
- def some_method(some_parameter, some_optional_parameter=nil, *parameters, some_keyword_parameter:, some_optional_keyword_parameter: nil, **named_parameters, &blk)
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
@@ -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/invocation'
4
+ require 'mimic/controls/subject/mixed_parameters'
13
5
  require 'mimic/controls/recorder'
14
6
  require 'mimic/controls/mimic'
@@ -19,8 +19,8 @@ module Mimic
19
19
 
20
20
  def self.method_definition(mthd, record)
21
21
  "
22
- #{signature(mthd)}
23
- #{body(record)}
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
- def self.body(record)
81
- body = ''
82
- if record
83
- body << <<~RECORD
84
- invocation = Invocation.build(binding)
85
- __record(invocation)
86
- RECORD
87
- end
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
- body << "Void.new"
90
+ # body << "Void.new"
90
91
 
91
- body
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 'invocation'
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.5.0.1
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-14 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
- name: evt-invocation
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
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module BlockParameter
5
- class Example
6
- def some_method(&blk)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module KeywordParameters
5
- class Example
6
- def some_method(some_parameter:, some_other_parameter:)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module MultipleAssignmentKeywordParameter
5
- class Example
6
- def some_method(**parameters)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module MultipleAssignmentParameter
5
- class Example
6
- def some_method(*parameters)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module OptionalKeywordParameters
5
- class Example
6
- def some_method(some_parameter: nil, some_other_parameter: nil)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module OptionalPositionalParameters
5
- class Example
6
- def some_method(some_parameter=nil, some_other_parameter=nil)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module Mimic
2
- module Controls
3
- module Subject
4
- module PositionalParameters
5
- class Example
6
- def some_method(some_parameter, some_other_parameter)
7
- end
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -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