cuprum 0.8.0 → 0.10.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 +5 -5
- data/CHANGELOG.md +85 -9
- data/DEVELOPMENT.md +58 -42
- data/README.md +414 -754
- data/lib/cuprum.rb +1 -25
- data/lib/cuprum/built_in/identity_command.rb +4 -4
- data/lib/cuprum/chaining.rb +139 -148
- data/lib/cuprum/command.rb +24 -15
- data/lib/cuprum/command_factory.rb +43 -19
- data/lib/cuprum/currying.rb +78 -0
- data/lib/cuprum/currying/curried_command.rb +109 -0
- data/lib/cuprum/error.rb +37 -0
- data/lib/cuprum/errors/command_not_implemented.rb +35 -0
- data/lib/cuprum/errors/operation_not_called.rb +35 -0
- data/lib/cuprum/operation.rb +37 -28
- data/lib/cuprum/processing.rb +45 -82
- data/lib/cuprum/result.rb +52 -127
- data/lib/cuprum/result_helpers.rb +14 -105
- data/lib/cuprum/rspec.rb +8 -0
- data/lib/cuprum/rspec/be_a_result.rb +19 -0
- data/lib/cuprum/rspec/be_a_result_matcher.rb +286 -0
- data/lib/cuprum/steps.rb +275 -0
- data/lib/cuprum/utils/instance_spy.rb +9 -2
- data/lib/cuprum/version.rb +1 -1
- metadata +14 -8
- data/lib/cuprum/errors/process_not_implemented_error.rb +0 -14
- data/lib/cuprum/utils/result_not_empty_warning.rb +0 -72
@@ -129,8 +129,15 @@ module Cuprum::Utils
|
|
129
129
|
end # eigenclass
|
130
130
|
|
131
131
|
# (see Cuprum::Command#call)
|
132
|
-
def call *args, &block
|
133
|
-
|
132
|
+
def call *args, **kwargs, &block
|
133
|
+
if kwargs.empty?
|
134
|
+
Cuprum::Utils::InstanceSpy.send(:call_spies_for, self, *args, &block)
|
135
|
+
else
|
136
|
+
# :nocov:
|
137
|
+
Cuprum::Utils::InstanceSpy
|
138
|
+
.send(:call_spies_for, self, *args, **kwargs, &block)
|
139
|
+
# :nocov:
|
140
|
+
end
|
134
141
|
|
135
142
|
super
|
136
143
|
end # method call
|
data/lib/cuprum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuprum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob "Merlin" Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sleeping_king_studios-tools
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,15 +116,22 @@ files:
|
|
116
116
|
- lib/cuprum/chaining.rb
|
117
117
|
- lib/cuprum/command.rb
|
118
118
|
- lib/cuprum/command_factory.rb
|
119
|
+
- lib/cuprum/currying.rb
|
120
|
+
- lib/cuprum/currying/curried_command.rb
|
121
|
+
- lib/cuprum/error.rb
|
119
122
|
- lib/cuprum/errors.rb
|
120
|
-
- lib/cuprum/errors/
|
123
|
+
- lib/cuprum/errors/command_not_implemented.rb
|
124
|
+
- lib/cuprum/errors/operation_not_called.rb
|
121
125
|
- lib/cuprum/operation.rb
|
122
126
|
- lib/cuprum/processing.rb
|
123
127
|
- lib/cuprum/result.rb
|
124
128
|
- lib/cuprum/result_helpers.rb
|
129
|
+
- lib/cuprum/rspec.rb
|
130
|
+
- lib/cuprum/rspec/be_a_result.rb
|
131
|
+
- lib/cuprum/rspec/be_a_result_matcher.rb
|
132
|
+
- lib/cuprum/steps.rb
|
125
133
|
- lib/cuprum/utils.rb
|
126
134
|
- lib/cuprum/utils/instance_spy.rb
|
127
|
-
- lib/cuprum/utils/result_not_empty_warning.rb
|
128
135
|
- lib/cuprum/version.rb
|
129
136
|
homepage: http://sleepingkingstudios.com
|
130
137
|
licenses:
|
@@ -145,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
152
|
- !ruby/object:Gem::Version
|
146
153
|
version: '0'
|
147
154
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.6.13
|
155
|
+
rubygems_version: 3.1.2
|
150
156
|
signing_key:
|
151
157
|
specification_version: 4
|
152
158
|
summary: An opinionated implementation of the Command pattern.
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'cuprum/errors'
|
2
|
-
|
3
|
-
module Cuprum::Errors
|
4
|
-
# Error class for calling a Command that was not given a definition block
|
5
|
-
# or have a #process method defined.
|
6
|
-
class ProcessNotImplementedError < StandardError
|
7
|
-
# Error message for a ProcessNotImplementedError.
|
8
|
-
DEFAULT_MESSAGE = 'no implementation defined for command'.freeze
|
9
|
-
|
10
|
-
def initialize message = nil
|
11
|
-
super(message || DEFAULT_MESSAGE)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'cuprum/utils'
|
2
|
-
|
3
|
-
module Cuprum::Utils
|
4
|
-
# Helper class for building a warning message when a command returns a result,
|
5
|
-
# but the command's current result already has errors, a set status, or is
|
6
|
-
# halted.
|
7
|
-
class ResultNotEmptyWarning
|
8
|
-
MESSAGE = '#process returned a result, but '.freeze
|
9
|
-
private_constant :MESSAGE
|
10
|
-
|
11
|
-
# @param result [Cuprum::Result] The result for which to generate the
|
12
|
-
# warning message.
|
13
|
-
def initialize result
|
14
|
-
@result = result
|
15
|
-
end # constructor
|
16
|
-
|
17
|
-
# @return [String] The warning message for the given result.
|
18
|
-
def message
|
19
|
-
return ''.freeze if warnings.empty?
|
20
|
-
|
21
|
-
MESSAGE + humanize_list(warnings).freeze
|
22
|
-
end # method message
|
23
|
-
|
24
|
-
# @return [Boolean] True if a warning is generated, otherwise false.
|
25
|
-
def warning?
|
26
|
-
!warnings.empty?
|
27
|
-
end # method warning?
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :result
|
32
|
-
|
33
|
-
def errors_not_empty_warning
|
34
|
-
return nil if result.errors.empty?
|
35
|
-
|
36
|
-
"there were already errors #{@result.errors.inspect}".freeze
|
37
|
-
end # method errors_not_empty_warning
|
38
|
-
|
39
|
-
def halted_warning
|
40
|
-
return nil unless result.halted?
|
41
|
-
|
42
|
-
'the command was halted'.freeze
|
43
|
-
end # method halted_warning
|
44
|
-
|
45
|
-
def humanize_list list, empty_value: ''
|
46
|
-
return empty_value if list.size.zero?
|
47
|
-
|
48
|
-
return list.first.to_s if list.size == 1
|
49
|
-
|
50
|
-
return "#{list.first} and #{list.last}" if list.size == 2
|
51
|
-
|
52
|
-
"#{list[0...-1].join ', '}, and #{list.last}"
|
53
|
-
end # method humanize_list
|
54
|
-
|
55
|
-
def status_set_warning
|
56
|
-
status = result.send(:status)
|
57
|
-
|
58
|
-
return nil if status.nil?
|
59
|
-
|
60
|
-
"the status was set to #{status.inspect}".freeze
|
61
|
-
end # method status_set_warning
|
62
|
-
|
63
|
-
def warnings
|
64
|
-
@warnings ||=
|
65
|
-
[
|
66
|
-
errors_not_empty_warning,
|
67
|
-
status_set_warning,
|
68
|
-
halted_warning
|
69
|
-
].compact
|
70
|
-
end # method warnings
|
71
|
-
end # class
|
72
|
-
end # module
|