MonkeyEngine 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +192 -0
- data/CHANGELOG.md +12 -4
- data/Gemfile.lock +16 -19
- data/lib/Action/action.rb +0 -2
- data/lib/Monkey/monkey.rb +1 -2
- data/lib/MonkeyAction/monkey_action.rb +0 -2
- data/lib/MonkeyAction/monkey_action_dead.rb +1 -3
- data/lib/MonkeyAction/monkey_action_eat.rb +1 -3
- data/lib/MonkeyAction/monkey_action_pause.rb +1 -3
- data/lib/MonkeyAction/monkey_action_sleep.rb +1 -3
- data/lib/MonkeyAction/monkey_action_type.rb +5 -7
- data/lib/MonkeyAction/monkey_action_wake.rb +1 -3
- data/lib/MonkeyAction/monkey_timed_action.rb +2 -4
- data/lib/MonkeyEngine/action_rules.rb +1 -1
- data/lib/MonkeyEngine/monkey_engine.rb +2 -8
- data/lib/MonkeyEngine/version.rb +1 -1
- data/lib/MonkeyKeyboard/keyboard_char.rb +0 -1
- data/lib/MonkeyKeyboard/keyboard_key.rb +9 -9
- data/lib/MonkeyKeyboard/keyboard_key_evaluator.rb +1 -1
- data/lib/MonkeyKeyboard/monkey_keyboard_en_us.rb +2 -2
- data/lib/MonkeyManager/monkey_manager.rb +5 -5
- data/lib/tasks/engine.rb +11 -7
- data/monkeyengine.gemspec +6 -2
- data/spec/action_rules_spec.rb +8 -14
- data/spec/engine_spec.rb +10 -10
- data/spec/keyboard_char_spec.rb +1 -1
- data/spec/keyboard_key_spec.rb +5 -5
- data/spec/monkey_action_eat_spec.rb +8 -8
- data/spec/monkey_action_pause_spec.rb +9 -9
- data/spec/monkey_action_sleep_spec.rb +9 -9
- data/spec/monkey_action_type_spec.rb +7 -7
- data/spec/monkey_action_wake_spec.rb +5 -5
- data/spec/monkey_factory_spec.rb +3 -11
- data/spec/monkey_keyboard_en_us_spec.rb +4 -7
- data/spec/monkey_manager_spec.rb +1 -1
- data/spec/monkey_service_spec.rb +11 -11
- data/spec/monkey_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_examples.rb +9 -9
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6999ecf2d6d8a4c2f0db40d32f38d619a40c55ce53e6616c381650f650500d3
|
4
|
+
data.tar.gz: 21b27a1563e5c59d980c980e4e6c3a6d5bf2c79c0d6c607109a0f165566126dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c2f2e708dbc90200c22f3d54267724ccaa881d16a21f6628249b11c02a465ae3442b05d8d9a5161ea7b9b02ca66b386f1c4ce378ecd34020effd98795fd99fd
|
7
|
+
data.tar.gz: 02fb5c756fd169cd9c5f4c90d578c7fcac045a0a2406e4c4e202fe154ecf2270ebaab9103470269de1e861851da9ff53cf01e3b816a28154bcfa0c369dd0dc71
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.0.1
|
7
|
+
NewCops: enable
|
8
|
+
Exclude:
|
9
|
+
- '.git/**/*'
|
10
|
+
- '.idea/**/*'
|
11
|
+
- 'init/*'
|
12
|
+
- 'Rakefile'
|
13
|
+
- '*.gemspec'
|
14
|
+
# - 'spec/**/*'
|
15
|
+
- 'vendor/**/*'
|
16
|
+
- 'scratch*.rb'
|
17
|
+
- 'snippets*.rb'
|
18
|
+
|
19
|
+
# Align the elements of a hash literal if they span more than one line.
|
20
|
+
Layout/HashAlignment:
|
21
|
+
EnforcedLastArgumentHashStyle: always_ignore
|
22
|
+
|
23
|
+
# Alignment of parameters in multi-line method definition.
|
24
|
+
# The `with_fixed_indentation` style aligns the following lines with one
|
25
|
+
# level of indentation relative to the start of the line with the method
|
26
|
+
# definition.
|
27
|
+
#
|
28
|
+
# def my_method(a,
|
29
|
+
# b)
|
30
|
+
Layout/ParameterAlignment:
|
31
|
+
EnforcedStyle: with_fixed_indentation
|
32
|
+
|
33
|
+
# Alignment of parameters in multi-line method call.
|
34
|
+
# The `with_fixed_indentation` style aligns the following lines with one
|
35
|
+
# level of indentation relative to the start of the line with the method call.
|
36
|
+
#
|
37
|
+
# my_method(a,
|
38
|
+
# b)
|
39
|
+
Layout/ArgumentAlignment:
|
40
|
+
EnforcedStyle: with_fixed_indentation
|
41
|
+
|
42
|
+
# a = case n
|
43
|
+
# when 0
|
44
|
+
# x * 2
|
45
|
+
# else
|
46
|
+
# y / 3
|
47
|
+
# end
|
48
|
+
Layout/CaseIndentation:
|
49
|
+
EnforcedStyle: end
|
50
|
+
|
51
|
+
# Enforces a configured order of definitions within a class body
|
52
|
+
Layout/ClassStructure:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
# Align `end` with the matching keyword or starting expression except for
|
56
|
+
# assignments, where it should be aligned with the LHS.
|
57
|
+
Layout/EndAlignment:
|
58
|
+
EnforcedStyleAlignWith: variable
|
59
|
+
AutoCorrect: true
|
60
|
+
|
61
|
+
# The `consistent` style enforces that the first element in an array
|
62
|
+
# literal where the opening bracket and the first element are on
|
63
|
+
# seprate lines is indented the same as an array literal which is not
|
64
|
+
# defined inside a method call.
|
65
|
+
Layout/FirstArrayElementIndentation:
|
66
|
+
EnforcedStyle: consistent
|
67
|
+
|
68
|
+
# The `consistent` style enforces that the first key in a hash
|
69
|
+
# literal where the opening brace and the first key are on
|
70
|
+
# seprate lines is indented the same as a hash literal which is not
|
71
|
+
# defined inside a method call.
|
72
|
+
Layout/FirstHashElementIndentation:
|
73
|
+
EnforcedStyle: consistent
|
74
|
+
|
75
|
+
# Indent multi-line methods instead of aligning with periods
|
76
|
+
Layout/MultilineMethodCallIndentation:
|
77
|
+
EnforcedStyle: indented
|
78
|
+
|
79
|
+
# Allow `debug` in tasks for now
|
80
|
+
Lint/Debugger:
|
81
|
+
Exclude:
|
82
|
+
- 'RakeFile'
|
83
|
+
|
84
|
+
# A calculated magnitude based on number of assignments, branches, and
|
85
|
+
# conditions.
|
86
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
87
|
+
# complaints
|
88
|
+
Metrics/AbcSize:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
# Avoid long blocks with many lines.
|
92
|
+
Metrics/BlockLength:
|
93
|
+
Exclude:
|
94
|
+
- 'RakeFile'
|
95
|
+
- 'db/seeds.rb'
|
96
|
+
- 'spec/**/*.rb'
|
97
|
+
|
98
|
+
# Avoid classes longer than 100 lines of code.
|
99
|
+
# NOTE: This is temporarily disabled until we can eliminate existing Rubocop
|
100
|
+
# complaints
|
101
|
+
Metrics/ClassLength:
|
102
|
+
Max: 200
|
103
|
+
Exclude:
|
104
|
+
- 'spec/**/*.rb'
|
105
|
+
|
106
|
+
# A complexity metric that is strongly correlated to the number of test cases
|
107
|
+
# needed to validate a method.
|
108
|
+
Metrics/CyclomaticComplexity:
|
109
|
+
Max: 9
|
110
|
+
|
111
|
+
# Limit lines to 80 characters
|
112
|
+
Layout/LineLength:
|
113
|
+
Exclude:
|
114
|
+
- 'RakeFile'
|
115
|
+
- 'spec/**/*.rb'
|
116
|
+
|
117
|
+
# Avoid methods longer than 15 lines of code.
|
118
|
+
Metrics/MethodLength:
|
119
|
+
Max: 20
|
120
|
+
AllowedMethods:
|
121
|
+
- swagger_path
|
122
|
+
- operation
|
123
|
+
|
124
|
+
|
125
|
+
# A complexity metric geared towards measuring complexity for a human reader.
|
126
|
+
Metrics/PerceivedComplexity:
|
127
|
+
Max: 10
|
128
|
+
|
129
|
+
NestedGroups:
|
130
|
+
Max: 4
|
131
|
+
|
132
|
+
# Naming/FileName:
|
133
|
+
# Exclude:
|
134
|
+
# - 'lib/file.rb'
|
135
|
+
|
136
|
+
# Allow `downcase == ` instead of forcing `casecmp`
|
137
|
+
Performance/Casecmp:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
# Require children definitions to be nested or compact in classes and modules
|
141
|
+
Style/ClassAndModuleChildren:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
# Document classes and non-namespace modules.
|
145
|
+
# (Disabled for now, may revisit later)
|
146
|
+
Style/Documentation:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
# Checks the formatting of empty method definitions.
|
150
|
+
Style/EmptyMethod:
|
151
|
+
EnforcedStyle: expanded
|
152
|
+
|
153
|
+
# Add the frozen_string_literal comment to the top of files to help transition
|
154
|
+
# to frozen string literals by default.
|
155
|
+
Style/FrozenStringLiteralComment:
|
156
|
+
EnforcedStyle: always
|
157
|
+
|
158
|
+
# Check for conditionals that can be replaced with guard clauses
|
159
|
+
Style/GuardClause:
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
Style/MixinUsage:
|
163
|
+
Exclude:
|
164
|
+
- 'RakeFile'
|
165
|
+
|
166
|
+
# Avoid multi-line method signatures.
|
167
|
+
Style/MultilineMethodSignature:
|
168
|
+
Enabled: true
|
169
|
+
|
170
|
+
# Don't use option hashes when you can use keyword arguments.
|
171
|
+
Style/OptionHash:
|
172
|
+
Enabled: true
|
173
|
+
|
174
|
+
# Use return instead of return nil.
|
175
|
+
Style/ReturnNil:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
# Allow code like `return x, y` as it's occasionally handy.
|
179
|
+
Style/RedundantReturn:
|
180
|
+
AllowMultipleReturnValues: true
|
181
|
+
|
182
|
+
# Prefer symbols instead of strings as hash keys.
|
183
|
+
Style/StringHashKeys:
|
184
|
+
Enabled: true
|
185
|
+
|
186
|
+
# Checks if configured preferred methods are used over non-preferred.
|
187
|
+
Style/StringMethods:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
# Checks for use of parentheses around ternary conditions.
|
191
|
+
Style/TernaryParentheses:
|
192
|
+
EnforcedStyle: require_parentheses_when_complex
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
### Version 2.0.2 2023-11-01
|
2
|
+
- Update ruby gems.
|
3
|
+
|
4
|
+
### Version 2.0.1
|
5
|
+
- Update ruby gems.
|
6
|
+
- Various refactors.
|
7
|
+
|
1
8
|
### Version 2.0.0
|
2
|
-
|
3
|
-
|
9
|
+
- Use LittleWeasel gem for dictionary.
|
10
|
+
- Gem update to patch CVEs.
|
11
|
+
|
4
12
|
### Version 1.1.0
|
5
|
-
|
6
|
-
|
13
|
+
- Made some changes to the sample rake task $ bundle exec rake engine:run
|
14
|
+
- Added this CHANGELOG.md file
|
data/Gemfile.lock
CHANGED
@@ -1,65 +1,62 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
MonkeyEngine (2.0.
|
4
|
+
MonkeyEngine (2.0.2)
|
5
5
|
LittleWeasel (~> 5.0, >= 5.0.3)
|
6
6
|
ProtectedConstructor (~> 2.0, >= 2.0.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
LittleWeasel (5.0.
|
12
|
-
activesupport (~>
|
13
|
-
ProtectedConstructor (2.1.
|
14
|
-
activesupport (
|
11
|
+
LittleWeasel (5.0.7)
|
12
|
+
activesupport (~> 7.0.8)
|
13
|
+
ProtectedConstructor (2.1.5)
|
14
|
+
activesupport (7.0.8)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
18
18
|
tzinfo (~> 2.0)
|
19
|
-
zeitwerk (~> 2.3)
|
20
19
|
byebug (11.1.3)
|
21
20
|
coderay (1.1.3)
|
22
21
|
colorize (0.8.1)
|
23
22
|
concurrent-ruby (1.2.2)
|
24
23
|
diff-lcs (1.5.0)
|
25
|
-
i18n (1.
|
24
|
+
i18n (1.14.1)
|
26
25
|
concurrent-ruby (~> 1.0)
|
27
26
|
method_source (1.0.0)
|
28
|
-
minitest (5.
|
27
|
+
minitest (5.20.0)
|
29
28
|
pry (0.14.2)
|
30
29
|
coderay (~> 1.1)
|
31
30
|
method_source (~> 1.0)
|
32
31
|
pry-byebug (3.10.1)
|
33
32
|
byebug (~> 11.0)
|
34
33
|
pry (>= 0.13, < 0.15)
|
35
|
-
rake (13.0
|
34
|
+
rake (13.1.0)
|
36
35
|
redcarpet (2.3.0)
|
37
36
|
rspec (3.12.0)
|
38
37
|
rspec-core (~> 3.12.0)
|
39
38
|
rspec-expectations (~> 3.12.0)
|
40
39
|
rspec-mocks (~> 3.12.0)
|
41
|
-
rspec-core (3.12.
|
40
|
+
rspec-core (3.12.2)
|
42
41
|
rspec-support (~> 3.12.0)
|
43
|
-
rspec-expectations (3.12.
|
42
|
+
rspec-expectations (3.12.3)
|
44
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
44
|
rspec-support (~> 3.12.0)
|
46
|
-
rspec-mocks (3.12.
|
45
|
+
rspec-mocks (3.12.6)
|
47
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
47
|
rspec-support (~> 3.12.0)
|
49
|
-
rspec-support (3.12.
|
48
|
+
rspec-support (3.12.1)
|
50
49
|
tzinfo (2.0.6)
|
51
50
|
concurrent-ruby (~> 1.0)
|
52
|
-
|
53
|
-
yard (0.9.28)
|
54
|
-
webrick (~> 1.7.0)
|
55
|
-
zeitwerk (2.6.7)
|
51
|
+
yard (0.9.34)
|
56
52
|
|
57
53
|
PLATFORMS
|
58
54
|
x86_64-darwin-19
|
55
|
+
x86_64-darwin-21
|
59
56
|
|
60
57
|
DEPENDENCIES
|
61
58
|
MonkeyEngine!
|
62
|
-
bundler (~> 2.
|
59
|
+
bundler (~> 2.4, >= 2.4.21)
|
63
60
|
colorize (~> 0.8.1)
|
64
61
|
pry-byebug (~> 3.9)
|
65
62
|
rake (~> 13.0, >= 13.0.6)
|
@@ -68,4 +65,4 @@ DEPENDENCIES
|
|
68
65
|
yard (~> 0.9.28)
|
69
66
|
|
70
67
|
BUNDLED WITH
|
71
|
-
2.
|
68
|
+
2.4.21
|
data/lib/Action/action.rb
CHANGED
data/lib/Monkey/monkey.rb
CHANGED
@@ -31,7 +31,6 @@ class Monkey
|
|
31
31
|
def initialize(monkey_symbol)
|
32
32
|
@monkey_symbol = monkey_symbol
|
33
33
|
@monkey_service = MonkeyEngine::MonkeyService.instance
|
34
|
-
self
|
35
34
|
end
|
36
35
|
|
37
36
|
public
|
@@ -76,7 +75,7 @@ class Monkey
|
|
76
75
|
def start
|
77
76
|
if alive?
|
78
77
|
raise MonkeyEngine::Exceptions::InvalidOperationException,
|
79
|
-
|
78
|
+
"The monkey [#{@monkey_symbol}] thread is already started"
|
80
79
|
end
|
81
80
|
|
82
81
|
initialize_thread
|
@@ -13,8 +13,6 @@ class MonkeyActionDead < MonkeyAction
|
|
13
13
|
super monkey, true, WEIGHT
|
14
14
|
|
15
15
|
validate
|
16
|
-
|
17
|
-
self
|
18
16
|
end
|
19
17
|
|
20
18
|
protected
|
@@ -22,7 +20,7 @@ class MonkeyActionDead < MonkeyAction
|
|
22
20
|
def validate
|
23
21
|
super
|
24
22
|
|
25
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value"
|
23
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value" \
|
26
24
|
unless VALID_VALUES.include?(@value)
|
27
25
|
end
|
28
26
|
end
|
@@ -18,8 +18,6 @@ class MonkeyActionEat < MonkeyTimedAction
|
|
18
18
|
@action_time_of_completion = @action_time + (value * 60)
|
19
19
|
|
20
20
|
validate
|
21
|
-
|
22
|
-
self
|
23
21
|
end
|
24
22
|
|
25
23
|
protected
|
@@ -27,7 +25,7 @@ class MonkeyActionEat < MonkeyTimedAction
|
|
27
25
|
def validate
|
28
26
|
super
|
29
27
|
|
30
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value"
|
28
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value" \
|
31
29
|
unless VALID_VALUES.include?(@value)
|
32
30
|
end
|
33
31
|
end
|
@@ -18,8 +18,6 @@ class MonkeyActionPause < MonkeyTimedAction
|
|
18
18
|
@action_time_of_completion = @action_time + value
|
19
19
|
|
20
20
|
validate
|
21
|
-
|
22
|
-
self
|
23
21
|
end
|
24
22
|
|
25
23
|
protected
|
@@ -27,7 +25,7 @@ class MonkeyActionPause < MonkeyTimedAction
|
|
27
25
|
def validate
|
28
26
|
super
|
29
27
|
|
30
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value"
|
28
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value" \
|
31
29
|
unless VALID_VALUES.include?(@value)
|
32
30
|
end
|
33
31
|
end
|
@@ -18,8 +18,6 @@ class MonkeyActionSleep < MonkeyTimedAction
|
|
18
18
|
@action_time_of_completion = @action_time + (value * (60 * 60))
|
19
19
|
|
20
20
|
validate
|
21
|
-
|
22
|
-
self
|
23
21
|
end
|
24
22
|
|
25
23
|
protected
|
@@ -27,7 +25,7 @@ class MonkeyActionSleep < MonkeyTimedAction
|
|
27
25
|
def validate
|
28
26
|
super
|
29
27
|
|
30
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value"
|
28
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value" \
|
31
29
|
unless VALID_VALUES.include?(@value)
|
32
30
|
end
|
33
31
|
end
|
@@ -11,12 +11,12 @@ class MonkeyActionType < MonkeyAction
|
|
11
11
|
WEIGHT = 5.0
|
12
12
|
|
13
13
|
def initialize(monkey, keyboard_input)
|
14
|
-
raise MonkeyEngine::Exceptions::NilArgumentException, "keyboard_input '#{keyboard_input}' cannot be nil"
|
14
|
+
raise MonkeyEngine::Exceptions::NilArgumentException, "keyboard_input '#{keyboard_input}' cannot be nil" \
|
15
15
|
if keyboard_input.nil?
|
16
16
|
|
17
17
|
unless keyboard_input.is_a?(KeyboardInput)
|
18
18
|
raise MonkeyEngine::Exceptions::InvalidArgumentTypeException,
|
19
|
-
|
19
|
+
"keyboard_input '#{keyboard_input}' is not a valid argument type"
|
20
20
|
end
|
21
21
|
|
22
22
|
@keyboard_input = keyboard_input
|
@@ -24,22 +24,20 @@ class MonkeyActionType < MonkeyAction
|
|
24
24
|
super monkey, @keyboard_input.input, WEIGHT
|
25
25
|
|
26
26
|
validate
|
27
|
-
|
28
|
-
self
|
29
27
|
end
|
30
28
|
|
31
29
|
protected
|
32
30
|
|
33
31
|
def validate
|
34
|
-
raise MonkeyEngine::Exceptions::NilArgumentException, "Value '#{value}' cannot be nil"
|
32
|
+
raise MonkeyEngine::Exceptions::NilArgumentException, "Value '#{value}' cannot be nil" \
|
35
33
|
if @value.nil?
|
36
34
|
|
37
35
|
unless @value.is_a?(Array)
|
38
36
|
raise MonkeyEngine::Exceptions::InvalidArgumentTypeException,
|
39
|
-
|
37
|
+
"Value '#{value}' is not a valid argument type (#{value.class.name})"
|
40
38
|
end
|
41
39
|
|
42
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' cannot be empty"
|
40
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' cannot be empty" \
|
43
41
|
if @value.empty?
|
44
42
|
end
|
45
43
|
end
|
@@ -13,8 +13,6 @@ class MonkeyActionWake < MonkeyAction
|
|
13
13
|
super monkey, true, WEIGHT
|
14
14
|
|
15
15
|
validate
|
16
|
-
|
17
|
-
self
|
18
16
|
end
|
19
17
|
|
20
18
|
protected
|
@@ -22,7 +20,7 @@ class MonkeyActionWake < MonkeyAction
|
|
22
20
|
def validate
|
23
21
|
super
|
24
22
|
|
25
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value"
|
23
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentValueException, "Value '#{value}' is not a valid value" \
|
26
24
|
unless VALID_VALUES.include?(@value)
|
27
25
|
end
|
28
26
|
end
|
@@ -13,17 +13,15 @@ class MonkeyTimedAction < MonkeyAction
|
|
13
13
|
@action_time_of_completion = nil
|
14
14
|
|
15
15
|
validate
|
16
|
-
|
17
|
-
self
|
18
16
|
end
|
19
17
|
|
20
18
|
protected
|
21
19
|
|
22
20
|
def validate
|
23
|
-
raise MonkeyEngine::Exceptions::NilArgumentException, "Value '#{value}' cannot be nil"
|
21
|
+
raise MonkeyEngine::Exceptions::NilArgumentException, "Value '#{value}' cannot be nil" \
|
24
22
|
if @value.nil?
|
25
23
|
|
26
|
-
raise MonkeyEngine::Exceptions::InvalidArgumentTypeException, "Value '#{value}' is not a valid argument type"
|
24
|
+
raise MonkeyEngine::Exceptions::InvalidArgumentTypeException, "Value '#{value}' is not a valid argument type" \
|
27
25
|
unless @value.is_a?(Integer)
|
28
26
|
end
|
29
27
|
end
|
@@ -17,7 +17,7 @@ class ActionRules
|
|
17
17
|
def get_next_action(monkey)
|
18
18
|
unless monkey.action.nil? || monkey.action.action_completed?
|
19
19
|
raise MonkeyEngine::Exceptions::InvalidOperationException,
|
20
|
-
|
20
|
+
"The action [#{monkey.action.class.name}] for Monkey [#{monkey.monkey_symbol}] must be completed before calling get_next_action"
|
21
21
|
end
|
22
22
|
|
23
23
|
# current_action = monkey.action
|
@@ -13,12 +13,6 @@ module MonkeyEngine
|
|
13
13
|
include Singleton
|
14
14
|
include Observable
|
15
15
|
|
16
|
-
private
|
17
|
-
|
18
|
-
def initialize; end
|
19
|
-
|
20
|
-
public
|
21
|
-
|
22
16
|
# Evaluates whether or not the action is completed.
|
23
17
|
def action_eval!(action)
|
24
18
|
ActionRules.instance.action_eval! action
|
@@ -27,7 +21,7 @@ module MonkeyEngine
|
|
27
21
|
def do_action(action)
|
28
22
|
if action.action_completed?
|
29
23
|
raise MonkeyEngine::Exceptions::InvalidOperationException,
|
30
|
-
|
24
|
+
"The action [#{action.class.name}] for Monkey [#{action.monkey.monkey_symbol}] is already completed"
|
31
25
|
end
|
32
26
|
|
33
27
|
do_action_type(action) if action.is_a? MonkeyActionType
|
@@ -47,7 +41,7 @@ module MonkeyEngine
|
|
47
41
|
def new_action(monkey)
|
48
42
|
unless monkey.action.nil? || monkey.action.action_completed?
|
49
43
|
raise MonkeyEngine::Exceptions::InvalidOperationException,
|
50
|
-
|
44
|
+
"The action [#{monkey.action.class.name}] for Monkey [#{monkey.monkey_symbol}] must be completed before calling new_action"
|
51
45
|
end
|
52
46
|
|
53
47
|
ActionRules.instance.get_next_action monkey
|
data/lib/MonkeyEngine/version.rb
CHANGED
@@ -6,6 +6,15 @@ require_relative 'keyboard_char'
|
|
6
6
|
class KeyboardKey
|
7
7
|
attr_reader :keyboard_char, :keyboard_shift_char, :keyboard_key_section, :keyboard_key_weight
|
8
8
|
|
9
|
+
def self.make_key(char, shift_char, keyboard_key_section, keyboard_key_weight)
|
10
|
+
# TODO: Check keyboard_key_section is :left or :right
|
11
|
+
|
12
|
+
keyboard_char = KeyboardChar.new char
|
13
|
+
keyboard_shift_char = KeyboardChar.new shift_char
|
14
|
+
|
15
|
+
KeyboardKey.new keyboard_char, keyboard_shift_char, keyboard_key_section, keyboard_key_weight
|
16
|
+
end
|
17
|
+
|
9
18
|
def initialize(keyboard_char, keyboard_shift_char, keyboard_key_section, keyboard_key_weight)
|
10
19
|
# TODO: Check keyboard_char is_a? KeyboardChar
|
11
20
|
# TODO: Check keyboard_shift_char is_a? KeyboardChar
|
@@ -16,13 +25,4 @@ class KeyboardKey
|
|
16
25
|
@keyboard_key_section = keyboard_key_section
|
17
26
|
@keyboard_key_weight = keyboard_key_weight
|
18
27
|
end
|
19
|
-
|
20
|
-
def self.make_key(char, shift_char, keyboard_key_section, keyboard_key_weight)
|
21
|
-
# TODO: Check keyboard_key_section is :left or :right
|
22
|
-
|
23
|
-
keyboard_char = KeyboardChar.new char
|
24
|
-
keyboard_shift_char = KeyboardChar.new shift_char
|
25
|
-
|
26
|
-
KeyboardKey.new keyboard_char, keyboard_shift_char, keyboard_key_section, keyboard_key_weight
|
27
|
-
end
|
28
28
|
end
|
@@ -10,7 +10,7 @@ class KeyboardKeyEvaluator
|
|
10
10
|
@shift_on = !@shift_on if keyboard_key.keyboard_char.char == :shift
|
11
11
|
@caps_on = !@shift_on if keyboard_key.keyboard_char.char == :caps
|
12
12
|
|
13
|
-
return
|
13
|
+
return if keyboard_key.keyboard_char.char.is_a? Symbol
|
14
14
|
|
15
15
|
return keyboard_key.keyboard_shift_char.char if @shift_on
|
16
16
|
|
@@ -16,7 +16,7 @@ module MonkeyEngine
|
|
16
16
|
attr_reader :keys, :left_keys, :right_keys
|
17
17
|
|
18
18
|
def initialize
|
19
|
-
LittleWeasel.configure
|
19
|
+
LittleWeasel.configure { |config| }
|
20
20
|
|
21
21
|
@keys = [
|
22
22
|
# Row 1 of 5
|
@@ -124,7 +124,7 @@ module MonkeyEngine
|
|
124
124
|
# Take the keys until we hit a key that terminates a word...
|
125
125
|
keyboard_input.input = keys.take_while do |key|
|
126
126
|
!keyboard_char_ends_word?(key.keyboard_char.char)
|
127
|
-
end.
|
127
|
+
end.filter_map { |key| keyboard_key_evaluator.get_char(key) }
|
128
128
|
|
129
129
|
# Keep going until we get something...
|
130
130
|
keyboard_input = get_keyboard_input if keyboard_input.input.empty?
|
@@ -82,15 +82,15 @@ module MonkeyEngine
|
|
82
82
|
# @raise [MonkeyEngine::Exceptions::InvalidArgumentTypeException] if parameter monkey is not a Monkey, Symbol, or String object.
|
83
83
|
#
|
84
84
|
def get(monkey)
|
85
|
-
return
|
85
|
+
return if @monkeys.empty?
|
86
86
|
|
87
87
|
# TODO: This seems inefficient.
|
88
|
-
return @monkeys.
|
89
|
-
return @monkeys.
|
90
|
-
return @monkeys.
|
88
|
+
return @monkeys.find { |m| m.monkey_symbol == monkey } if monkey.is_a? Symbol
|
89
|
+
return @monkeys.find { |m| m.monkey_symbol == monkey.to_sym } if monkey.is_a? String
|
90
|
+
return @monkeys.find { |m| m.monkey_symbol == monkey.monkey_symbol } if monkey.is_a? Monkey
|
91
91
|
|
92
92
|
raise MonkeyEngine::Exceptions::InvalidArgumentTypeException,
|
93
|
-
|
93
|
+
"Parameter 'monkey' is not a Symbol, String or Monkey object"
|
94
94
|
end
|
95
95
|
|
96
96
|
# Returns a duplicate Array of Monkey objects managed by this MonkeyManager.
|