mini_kraken 0.3.00 → 0.3.01

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: ceccf4c9ffeb71fc8759bbf1ea1db003d83e9e150df95793de7e729716c9538d
4
- data.tar.gz: bab9d4b22a86eec0fcd95955a799a40bfd51c032d05a56b5c2569e0e833b4d2d
3
+ metadata.gz: 184cc99bd7696eb4f51fea822e74c98f42396f92cd47e1ce4501bed4cbb6a3c0
4
+ data.tar.gz: eb0bad624831f6643db7ec04265424cab58a9245f7fbfd472041e1eaa095de68
5
5
  SHA512:
6
- metadata.gz: 5b8dac966209d3209419b2721c67ecd9ec1d1985b0a457877def4e9eda3a305b6952d996e1791436db33f863a046553df1567ef142fc7fe6d5d8092b7d0e2ecd
7
- data.tar.gz: 5c99a985287a32d2e6a2c6dbbcabeaea07203e533372183817660eb2259edda6465b4993997b9dcb8dd0db59e0b69772f31409f17a587a3d55381d7f06151a74
6
+ metadata.gz: 3803703fc02bda7cee5cd72f511f1a4a32bfecb85663571c1b15f002ab82b7551e49654aea9ce3a12e06ffa7c4839999c9ae4df9ce3fd2f9ba679ff827d47541
7
+ data.tar.gz: 88bb32e2140526ee415542421ffad57ed768b67995c0a6d70b6c33d46f520b05ee312081b6d8a13ca64042ef004b0e7e2cf8baccbc226f385d0d67776220ac05
@@ -1,334 +1,379 @@
1
- AllCops:
2
- Exclude:
3
- - 'exp/**/*'
4
-
5
- Layout/ArgumentAlignment:
6
- Enabled: false
7
-
8
- Layout/ArrayAlignment:
9
- Enabled: true
10
- EnforcedStyle: with_fixed_indentation
11
-
12
- Layout/CaseIndentation:
13
- Enabled: false
14
-
15
- Layout/ClosingHeredocIndentation:
16
- Enabled: false
17
-
18
- Layout/CommentIndentation:
19
- Enabled: false
20
-
21
- Layout/ElseAlignment:
22
- Enabled: false
23
-
24
- Layout/EmptyLines:
25
- Enabled: false
26
-
27
- Layout/EndAlignment:
28
- Enabled: false
29
-
30
- Layout/EndOfLine:
31
- Enabled: true
32
- EnforcedStyle: lf
33
-
34
- Layout/FirstArgumentIndentation:
35
- Enabled: false
36
-
37
- Layout/IndentationWidth:
38
- Enabled: false
39
-
40
- Layout/IndentationConsistency:
41
- Enabled: true
42
-
43
- Layout/HeredocIndentation:
44
- Enabled: false
45
-
46
- Layout/MultilineHashBraceLayout:
47
- Enabled: true
48
-
49
- Layout/MultilineMethodCallBraceLayout:
50
- Enabled: true
51
- EnforcedStyle: same_line
52
-
53
- Layout/SpaceAroundOperators:
54
- Enabled: true
55
-
56
- Layout/SpaceInsideParens:
57
- Enabled: true
58
-
59
- Layout/IndentationStyle:
60
- Enabled: true
61
-
62
- Layout/SpaceAroundMethodCallOperator:
63
- Enabled: true
64
-
65
- Layout/TrailingEmptyLines:
66
- Enabled: true
67
-
68
- Layout/TrailingWhitespace:
69
- Enabled: true
70
-
71
- Lint/Loop:
72
- Enabled: true
73
-
74
- Lint/RaiseException:
75
- Enabled: true
76
-
77
- Lint/RescueException:
78
- Enabled: true
79
-
80
- Lint/StructNewOverride:
81
- Enabled: true
82
-
83
- Lint/UnusedMethodArgument:
84
- Enabled: true
85
-
86
- Lint/UselessAccessModifier:
87
- Enabled: true
88
-
89
- Lint/Void:
90
- Enabled: false
91
-
92
- Lint/UselessAssignment:
93
- Enabled: true
94
-
95
- Metrics/AbcSize:
96
- Enabled: false
97
-
98
- Metrics/BlockLength:
99
- Enabled: true
100
- Max: 350
101
-
102
- Metrics/BlockNesting:
103
- Enabled: true
104
- Max: 5
105
-
106
- Metrics/ClassLength:
107
- Enabled: true
108
- Max: 350
109
-
110
- Metrics/CyclomaticComplexity:
111
- Enabled: false
112
-
113
- Layout/LineLength:
114
- Enabled: false
115
- Max: 90
116
-
117
- Metrics/MethodLength:
118
- Enabled: true
119
- Max: 50
120
-
121
- Metrics/ModuleLength:
122
- Enabled: true
123
- Max: 500
124
-
125
- Metrics/PerceivedComplexity:
126
- Enabled: false
127
-
128
- Naming/ConstantName:
129
- Enabled: false
130
-
131
- Naming/ClassAndModuleCamelCase:
132
- Enabled: false
133
-
134
- Naming/BlockParameterName:
135
- Enabled: true
136
-
137
- Naming/MethodParameterName:
138
- Enabled: false
139
-
140
- Naming/VariableName:
141
- Enabled: false
142
-
143
- Style/Alias:
144
- Enabled: true
145
-
146
- Layout/HashAlignment:
147
- Enabled: false
148
-
149
- Style/AsciiComments:
150
- Enabled: false
151
-
152
- Style/BarePercentLiterals:
153
- Enabled: false
154
-
155
- Style/BlockComments:
156
- Enabled: false
157
-
158
- Style/CharacterLiteral:
159
- Enabled: false
160
-
161
- Style/ClassCheck:
162
- Enabled: false
163
-
164
- Style/ClassVars:
165
- Enabled: false
166
-
167
- Style/ColonMethodCall:
168
- Enabled: false
169
-
170
- Style/CommentAnnotation:
171
- Enabled: false
172
-
173
- Style/CommentedKeyword:
174
- Enabled: false
175
-
176
- Style/ConditionalAssignment:
177
- Enabled: false
178
-
179
- Style/DefWithParentheses:
180
- Enabled: true
181
-
182
- Style/Documentation:
183
- Enabled: false
184
-
185
- Style/ExpandPathArguments:
186
- Enabled: false
187
-
188
- Style/ExponentialNotation:
189
- Enabled: true
190
-
191
- Style/GuardClause:
192
- Enabled: false
193
-
194
- Style/HashEachMethods:
195
- Enabled: true
196
-
197
- Style/HashTransformKeys:
198
- Enabled: true
199
-
200
- Style/HashTransformValues:
201
- Enabled: true
202
-
203
- Style/IfUnlessModifier:
204
- Enabled: false
205
-
206
- Style/InverseMethods:
207
- Enabled: true
208
-
209
- Style/MissingRespondToMissing:
210
- Enabled: false
211
-
212
- Style/Next:
213
- Enabled: false
214
-
215
- Style/NumericLiterals:
216
- Enabled: false
217
-
218
- Style/RaiseArgs:
219
- Enabled: true
220
-
221
- Style/RedundantReturn:
222
- Enabled: false
223
-
224
- Style/RedundantSelf:
225
- Enabled: true
226
-
227
- Style/RegexpLiteral:
228
- Enabled: false
229
-
230
- Style/PercentLiteralDelimiters:
231
- Enabled: false
232
-
233
- Style/StderrPuts:
234
- Enabled: false
235
-
236
- Style/StringLiterals:
237
- Enabled: true
238
-
239
- Style/TernaryParentheses:
240
- Enabled: false
241
-
242
- Style/UnlessElse:
243
- Enabled: false
244
-
245
- # Rubocop complains when it doesn't find an explicit setting for the following cops:
246
- Layout/EmptyLinesAroundAttributeAccessor:
247
- Enabled: true
248
-
249
- Lint/BinaryOperatorWithIdenticalOperands:
250
- Enabled: true
251
-
252
- Lint/DeprecatedOpenSSLConstant:
253
- Enabled: true
254
-
255
- Lint/DuplicateElsifCondition:
256
- Enabled: true
257
-
258
- Lint/DuplicateRescueException:
259
- Enabled: true
260
-
261
- Lint/EmptyConditionalBody:
262
- Enabled: true
263
-
264
- Lint/FloatComparison:
265
- Enabled: true
266
-
267
- Lint/MissingSuper:
268
- Enabled: true
269
-
270
- Lint/MixedRegexpCaptureTypes:
271
- Enabled: true
272
-
273
- Lint/OutOfRangeRegexpRef:
274
- Enabled: true
275
-
276
- Lint/SelfAssignment:
277
- Enabled: true
278
-
279
- Lint/TopLevelReturnWithArgument:
280
- Enabled: true
281
-
282
- Lint/UnreachableLoop:
283
- Enabled: true
284
-
285
- Style/AccessorGrouping:
286
- Enabled: true
287
-
288
- Style/ArrayCoercion:
289
- Enabled: true
290
-
291
- Style/BisectedAttrAccessor:
292
- Enabled: true
293
-
294
- Style/CaseLikeIf:
295
- Enabled: true
296
-
297
- Style/ExplicitBlockArgument:
298
- Enabled: true
299
-
300
- Style/GlobalStdStream:
301
- Enabled: true
302
-
303
- Style/HashAsLastArrayItem:
304
- Enabled: true
305
-
306
- Style/HashLikeCase:
307
- Enabled: true
308
-
309
- Style/OptionalBooleanParameter:
310
- Enabled: true
311
-
312
- Style/RedundantAssignment:
313
- Enabled: true
314
-
315
- Style/RedundantFetchBlock:
316
- Enabled: true
317
-
318
- Style/RedundantFileExtensionInRequire:
319
- Enabled: true
320
-
321
- Style/RedundantRegexpCharacterClass:
322
- Enabled: true
323
-
324
- Style/RedundantRegexpEscape:
325
- Enabled: true
326
-
327
- Style/SingleArgumentDig:
328
- Enabled: true
329
-
330
- Style/SlicingWithRange:
331
- Enabled: true
332
-
333
- Style/StringConcatenation:
1
+ AllCops:
2
+ Exclude:
3
+ - 'exp/**/*'
4
+
5
+ Layout/ArgumentAlignment:
6
+ Enabled: false
7
+
8
+ Layout/ArrayAlignment:
9
+ Enabled: true
10
+ EnforcedStyle: with_fixed_indentation
11
+
12
+ Layout/CaseIndentation:
13
+ Enabled: false
14
+
15
+ Layout/ClosingHeredocIndentation:
16
+ Enabled: false
17
+
18
+ Layout/CommentIndentation:
19
+ Enabled: false
20
+
21
+ Layout/ElseAlignment:
22
+ Enabled: false
23
+
24
+ Layout/EmptyLines:
25
+ Enabled: false
26
+
27
+ Layout/EndAlignment:
28
+ Enabled: false
29
+
30
+ Layout/EndOfLine:
31
+ Enabled: true
32
+ EnforcedStyle: lf
33
+
34
+ Layout/FirstArgumentIndentation:
35
+ Enabled: false
36
+
37
+ Layout/HashAlignment:
38
+ Enabled: false
39
+
40
+ Layout/IndentationWidth:
41
+ Enabled: false
42
+
43
+ Layout/IndentationConsistency:
44
+ Enabled: true
45
+
46
+ Layout/HeredocIndentation:
47
+ Enabled: false
48
+
49
+ Layout/MultilineHashBraceLayout:
50
+ Enabled: true
51
+
52
+ Layout/MultilineMethodCallBraceLayout:
53
+ Enabled: true
54
+ EnforcedStyle: same_line
55
+
56
+ Layout/SpaceAroundOperators:
57
+ Enabled: true
58
+
59
+ Layout/SpaceInsideParens:
60
+ Enabled: true
61
+
62
+ Layout/IndentationStyle:
63
+ Enabled: true
64
+
65
+ Layout/SpaceAroundMethodCallOperator:
66
+ Enabled: true
67
+
68
+ Layout/TrailingEmptyLines:
69
+ Enabled: true
70
+
71
+ Layout/TrailingWhitespace:
72
+ Enabled: true
73
+
74
+ Lint/DuplicateBranch:
75
+ Enabled: true
76
+
77
+ Lint/DuplicateRegexpCharacterClassElement:
78
+ Enabled: true
79
+
80
+ Lint/EmptyBlock:
81
+ Enabled: true
82
+
83
+ Lint/EmptyClass:
84
+ Enabled: false
85
+
86
+ Lint/Loop:
87
+ Enabled: true
88
+
89
+ Lint/NoReturnInBeginEndBlocks:
90
+ Enabled: true
91
+
92
+ Lint/RaiseException:
93
+ Enabled: true
94
+
95
+ Lint/RescueException:
96
+ Enabled: true
97
+
98
+ Lint/StructNewOverride:
99
+ Enabled: true
100
+
101
+ Lint/ToEnumArguments:
102
+ Enabled: true
103
+
104
+ Lint/UnexpectedBlockArity:
105
+ Enabled: true
106
+
107
+ Lint/UnmodifiedReduceAccumulator:
108
+ Enabled: true
109
+
110
+ Lint/UnusedMethodArgument:
111
+ Enabled: true
112
+
113
+ Lint/UselessAccessModifier:
114
+ Enabled: true
115
+
116
+ Lint/Void:
117
+ Enabled: false
118
+
119
+ Lint/UselessAssignment:
120
+ Enabled: true
121
+
122
+ Metrics/AbcSize:
123
+ Enabled: false
124
+
125
+ Metrics/BlockLength:
126
+ Enabled: true
127
+ Max: 350
128
+
129
+ Metrics/BlockNesting:
130
+ Enabled: true
131
+ Max: 5
132
+
133
+ Metrics/ClassLength:
134
+ Enabled: true
135
+ Max: 450
136
+
137
+ Metrics/CyclomaticComplexity:
138
+ Enabled: false
139
+
140
+ Layout/LineLength:
141
+ Enabled: false
142
+ Max: 90
143
+
144
+ Metrics/MethodLength:
145
+ Enabled: true
146
+ Max: 60
147
+
148
+ Metrics/ModuleLength:
149
+ Enabled: true
150
+ Max: 500
151
+
152
+ Metrics/PerceivedComplexity:
153
+ Enabled: false
154
+
155
+ Naming/ConstantName:
156
+ Enabled: false
157
+
158
+ Naming/ClassAndModuleCamelCase:
159
+ Enabled: false
160
+
161
+ Naming/BlockParameterName:
162
+ Enabled: true
163
+
164
+ Naming/MethodParameterName:
165
+ Enabled: false
166
+
167
+ Naming/VariableName:
168
+ Enabled: false
169
+
170
+ Style/Alias:
171
+ Enabled: true
172
+
173
+ Style/ArgumentsForwarding:
174
+ Enabled: true
175
+
176
+ Style/AsciiComments:
177
+ Enabled: false
178
+
179
+ Style/BarePercentLiterals:
180
+ Enabled: false
181
+
182
+ Style/BlockComments:
183
+ Enabled: false
184
+
185
+ Style/CharacterLiteral:
186
+ Enabled: false
187
+
188
+ Style/ClassCheck:
189
+ Enabled: false
190
+
191
+ Style/ClassVars:
192
+ Enabled: false
193
+
194
+ Style/CollectionCompact:
195
+ Enabled: true
196
+
197
+ Style/ColonMethodCall:
198
+ Enabled: false
199
+
200
+ Style/CommentAnnotation:
201
+ Enabled: false
202
+
203
+ Style/CommentedKeyword:
204
+ Enabled: false
205
+
206
+ Style/ConditionalAssignment:
207
+ Enabled: false
208
+
209
+ Style/DefWithParentheses:
210
+ Enabled: true
211
+
212
+ Style/Documentation:
213
+ Enabled: false
214
+
215
+ Style/DocumentDynamicEvalDefinition:
216
+ Enabled: true
217
+
218
+ Style/ExpandPathArguments:
219
+ Enabled: false
220
+
221
+ Style/ExponentialNotation:
222
+ Enabled: true
223
+
224
+ Style/GuardClause:
225
+ Enabled: false
226
+
227
+ Style/HashEachMethods:
228
+ Enabled: true
229
+
230
+ Style/HashTransformKeys:
231
+ Enabled: true
232
+
233
+ Style/HashTransformValues:
234
+ Enabled: true
235
+
236
+ Style/IfUnlessModifier:
237
+ Enabled: false
238
+
239
+ Style/InverseMethods:
240
+ Enabled: true
241
+
242
+ Style/MissingRespondToMissing:
243
+ Enabled: false
244
+
245
+ Style/NegatedIfElseCondition:
246
+ Enabled: true
247
+
248
+ Style/Next:
249
+ Enabled: false
250
+
251
+ Style/NilLambda:
252
+ Enabled: true
253
+
254
+ Style/NumericLiterals:
255
+ Enabled: false
256
+
257
+ Style/RaiseArgs:
258
+ Enabled: true
259
+
260
+ Style/RedundantArgument:
261
+ Enabled: true
262
+
263
+ Style/RedundantReturn:
264
+ Enabled: false
265
+
266
+ Style/RedundantSelf:
267
+ Enabled: true
268
+
269
+ Style/RegexpLiteral:
270
+ Enabled: false
271
+
272
+ Style/PercentLiteralDelimiters:
273
+ Enabled: false
274
+
275
+ Style/StderrPuts:
276
+ Enabled: false
277
+
278
+ Style/StringLiterals:
279
+ Enabled: true
280
+
281
+ Style/SwapValues:
282
+ Enabled: true
283
+
284
+ Style/TernaryParentheses:
285
+ Enabled: false
286
+
287
+ Style/UnlessElse:
288
+ Enabled: false
289
+
290
+ # Rubocop complains when it doesn't find an explicit setting for the following cops:
291
+ Layout/EmptyLinesAroundAttributeAccessor:
292
+ Enabled: true
293
+
294
+ Lint/BinaryOperatorWithIdenticalOperands:
295
+ Enabled: true
296
+
297
+ Lint/DeprecatedOpenSSLConstant:
298
+ Enabled: true
299
+
300
+ Lint/DuplicateElsifCondition:
301
+ Enabled: true
302
+
303
+ Lint/DuplicateRescueException:
304
+ Enabled: true
305
+
306
+ Lint/EmptyConditionalBody:
307
+ Enabled: true
308
+
309
+ Lint/FloatComparison:
310
+ Enabled: true
311
+
312
+ Lint/MissingSuper:
313
+ Enabled: true
314
+
315
+ Lint/MixedRegexpCaptureTypes:
316
+ Enabled: true
317
+
318
+ Lint/OutOfRangeRegexpRef:
319
+ Enabled: true
320
+
321
+ Lint/SelfAssignment:
322
+ Enabled: true
323
+
324
+ Lint/TopLevelReturnWithArgument:
325
+ Enabled: true
326
+
327
+ Lint/UnreachableLoop:
328
+ Enabled: true
329
+
330
+ Style/AccessorGrouping:
331
+ Enabled: true
332
+
333
+ Style/ArrayCoercion:
334
+ Enabled: true
335
+
336
+ Style/BisectedAttrAccessor:
337
+ Enabled: true
338
+
339
+ Style/CaseLikeIf:
340
+ Enabled: true
341
+
342
+ Style/ExplicitBlockArgument:
343
+ Enabled: true
344
+
345
+ Style/GlobalStdStream:
346
+ Enabled: true
347
+
348
+ Style/HashAsLastArrayItem:
349
+ Enabled: true
350
+
351
+ Style/HashLikeCase:
352
+ Enabled: true
353
+
354
+ Style/OptionalBooleanParameter:
355
+ Enabled: true
356
+
357
+ Style/RedundantAssignment:
358
+ Enabled: true
359
+
360
+ Style/RedundantFetchBlock:
361
+ Enabled: true
362
+
363
+ Style/RedundantFileExtensionInRequire:
364
+ Enabled: true
365
+
366
+ Style/RedundantRegexpCharacterClass:
367
+ Enabled: true
368
+
369
+ Style/RedundantRegexpEscape:
370
+ Enabled: true
371
+
372
+ Style/SingleArgumentDig:
373
+ Enabled: true
374
+
375
+ Style/SlicingWithRange:
376
+ Enabled: true
377
+
378
+ Style/StringConcatenation:
334
379
  Enabled: true
@@ -1,3 +1,11 @@
1
+ ## [0.3.01] - 2020-12-17
2
+ - Minor: updated Rubocop config file `.rubocop.yml`
3
+
4
+ ### CHANGED
5
+ - Config file `.rubocop.yml` updated to incorporate the cops from Rubocop 1.6.1
6
+ - Several files re-styled to please Rubocop
7
+ - `README.md` Checkbox for `cdro` is now ticked
8
+
1
9
  ## [0.3.00] - 2020-12-16
2
10
  - Version number bump because this is a vast code rewrite
3
11
 
@@ -62,16 +62,6 @@ module MiniKraken
62
62
  end
63
63
  rela = Rela::DefRelation.new(relationName, aGoalExpr, formals)
64
64
  add_defrel(rela)
65
-
66
- # start_defrel
67
-
68
- # formals = @defrel_formals.map { |name| Core::FormalArg.new(name) }
69
- # g_template = aGoalTemplateExpr.call
70
- # result = Core::DefRelation.new(relationName, g_template, formals)
71
- # add_defrel(result)
72
-
73
- # end_defrel
74
- # result
75
65
  end
76
66
 
77
67
  def disj2(arg1, arg2)
@@ -117,15 +107,16 @@ module MiniKraken
117
107
 
118
108
  case anArgument
119
109
  when Symbol
120
- if anArgument.id2name =~ /_\d+/
121
- rank = anArgument.id2name.slice(1..-1).to_i
122
- any_val = Core::AnyValue.allocate
123
- any_val.instance_variable_set(:@rank, rank)
124
- converted = any_val
125
- elsif anArgument.id2name =~ /^"#[ft]"$/
126
- converted = Atomic::KBoolean.new(anArgument)
127
- else
128
- converted = Atomic::KSymbol.new(anArgument)
110
+ case anArgument.id2name
111
+ when /_\d+/
112
+ rank = anArgument.id2name.slice(1..-1).to_i
113
+ any_val = Core::AnyValue.allocate
114
+ any_val.instance_variable_set(:@rank, rank)
115
+ converted = any_val
116
+ when /^"#[ft]"$/
117
+ converted = Atomic::KBoolean.new(anArgument)
118
+ else
119
+ converted = Atomic::KSymbol.new(anArgument)
129
120
  end
130
121
  when String
131
122
  if anArgument =~ /^#[ft]$/
@@ -136,15 +127,9 @@ module MiniKraken
136
127
  end
137
128
  when false, true
138
129
  converted = Atomic::KBoolean.new(anArgument)
139
- when Atomic::KBoolean, Atomic::KSymbol
140
- converted = anArgument
141
- when Core::Goal
142
- converted = anArgument
143
- when Core::LogVarRef
144
- converted = anArgument
145
- when Composite::ConsCell
130
+ when NilClass, Atomic::KBoolean, Atomic::KSymbol
146
131
  converted = anArgument
147
- when NilClass
132
+ when Core::Goal, Core::LogVarRef, Composite::ConsCell
148
133
  converted = anArgument
149
134
  else
150
135
  msg = "Internal error: undefined conversion for #{anArgument.class}"
@@ -85,10 +85,7 @@ module MiniKraken
85
85
 
86
86
  actuals.each do |arg|
87
87
  case arg
88
- when Core::Goal
89
- result << arg
90
-
91
- when Core::Context
88
+ when Core::Goal, Core::Context
92
89
  result << arg
93
90
 
94
91
  when Array
@@ -49,7 +49,36 @@ module MiniKraken
49
49
  def validated_expression(aGoalTemplate)
50
50
  raise StandardError unless aGoalTemplate
51
51
 
52
- aGoalTemplate
52
+ compose_goals(aGoalTemplate)
53
+ end
54
+
55
+ def compose_goals(subgoals)
56
+ nested_goal = nil
57
+
58
+ case subgoals
59
+ when Core::Goal
60
+ nested_goal = subgoals
61
+
62
+ when Array
63
+ goal_array = subgoals
64
+ loop do
65
+ conjunctions = []
66
+ goal_array.each_slice(2) do |uno_duo|
67
+ if uno_duo.size == 2
68
+ conjunctions << Core::Goal.new(Conj2.instance, uno_duo)
69
+ else
70
+ conjunctions << uno_duo[0]
71
+ end
72
+ end
73
+ if conjunctions.size == 1
74
+ nested_goal = conjunctions[0]
75
+ break
76
+ end
77
+ goal_array = conjunctions
78
+ end
79
+ end
80
+
81
+ nested_goal
53
82
  end
54
83
 
55
84
  # With the given expression, create a new expression where
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniKraken
4
- VERSION = '0.3.00'
4
+ VERSION = '0.3.01'
5
5
  end
@@ -40,8 +40,8 @@ Gem::Specification.new do |spec|
40
40
  spec.authors = ['Dimitri Geshef']
41
41
  spec.email = ['famished.tiger@yahoo.com']
42
42
 
43
- spec.summary = 'Implementation of Minikanren language in Ruby. WIP'
44
- spec.description = 'Implementation of Minikanren language in Ruby. WIP'
43
+ spec.summary = 'Implementation of miniKanren language in Ruby. WIP'
44
+ spec.description = 'Implementation of miniKanren language in Ruby. WIP'
45
45
  spec.homepage = 'https://github.com/famished-tiger/mini_kraken'
46
46
  spec.license = 'MIT'
47
47
 
@@ -44,7 +44,8 @@ module MiniKraken
44
44
  end
45
45
 
46
46
  it 'performs data value comparison' do
47
- expect(subject == subject).to be_truthy
47
+ itself = subject # Renaming as workaround to Rubocop complaint
48
+ expect(subject == itself).to be_truthy
48
49
  expect(subject == subject.value).to be_truthy
49
50
 
50
51
  expect(subject == other_value).to be_falsy
@@ -74,7 +74,8 @@ module MiniKraken
74
74
  end
75
75
 
76
76
  it 'should know whether is equal to another arity' do
77
- expect(subject == subject).to be_truthy
77
+ itself = subject # Renaming as workaround to Rubocop complaint
78
+ expect(subject == itself).to be_truthy
78
79
 
79
80
  same = Arity.new(0, 1)
80
81
  expect(subject == same).to be_truthy
@@ -8,12 +8,6 @@ require_relative '../../lib/mini_kraken/core/duck_fiber'
8
8
  module MiniKraken
9
9
  module Core
10
10
  describe DuckFiber do
11
- Callable = Struct.new(:proc) do
12
- def call
13
- proc.call
14
- end
15
- end
16
-
17
11
  let(:ctx) { Core::Context.new }
18
12
  let(:callable) { -> { ctx.failed! } }
19
13
  subject { DuckFiber.new(callable) }
@@ -215,11 +215,67 @@ module MiniKraken
215
215
  # (== 'a x))) ;; l => ('(a c o r n))
216
216
 
217
217
  result = run_star('l', fresh('x',
218
- [cdro(l, corn), # WRONG l => a c o r n (side effect from other tests)
218
+ [cdro(l, corn),
219
219
  caro(l, x),
220
220
  unify(:a, x)]))
221
221
  expect(result.to_s).to eq('((:a :c :o :r :n))')
222
222
  end
223
+
224
+ it 'accepts conso definition inspired from frame 2:25' do
225
+ defrel_caro
226
+ defrel_cdro
227
+
228
+ # Reasoned S2, frame 2:25
229
+ # (defrel (conso a p d)
230
+ # (caro p a)
231
+ # (cdro p d))
232
+
233
+ # As 'p' has a special meaning in Ruby, the argument has been remaned to 'r'
234
+ conso_rel = defrel('conso', %w[a r d], [caro(r, a), cdro(r, d)])
235
+
236
+ expect(conso_rel).to be_kind_of(Rela::DefRelation)
237
+ expect(conso_rel.name).to eq('conso')
238
+ expect(conso_rel.arity).to eq(3)
239
+ expect(conso_rel.formals[0]).to match(/^a_[-0-9a-f]+$/)
240
+ expect(conso_rel.formals[1]).to match(/^r_[-0-9a-f]+$/)
241
+ expect(conso_rel.formals[2]).to match(/^d_[-0-9a-f]+$/)
242
+ g_template = conso_rel.expression
243
+ expect(g_template.relation).to be_kind_of(Rela::Conj2)
244
+ g1 = g_template.actuals[0]
245
+ expect(g1).to be_kind_of(Core::Goal)
246
+ expect(g1.relation.name).to eq('caro')
247
+ expect(g1.actuals[0].name).to match(/^r_/)
248
+ expect(g1.actuals[1].name).to match(/^a_/)
249
+
250
+ g2 = g_template.actuals[1]
251
+ expect(g2).to be_kind_of(Core::Goal)
252
+ expect(g2.relation.name).to eq('cdro')
253
+ expect(g2.actuals[0].name).to match(/^r_/)
254
+ expect(g2.actuals[1].name).to match(/^d_/)
255
+ end
256
+
257
+ # In Scheme:
258
+ # (defrel (conso a p d)
259
+ # (caro p a)
260
+ # (cdro p d))
261
+ # In Ruby, `p`is a standard Kernel method => replace it by `r`
262
+ def defrel_conso
263
+ defrel_caro
264
+ defrel_cdro
265
+
266
+ defrel('conso', %w[a r d], [caro(r, a), cdro(r, d)])
267
+ end
268
+
269
+ # TODO: FIX THIS EXAMPLE
270
+ # it 'passes frame 2:19' do
271
+ # defrel_conso
272
+
273
+ # # (run* l
274
+ # # (conso '(a b c) '(d e) l)) ;; => ((abc) (d e))
275
+
276
+ # result = run_star('l', conso( list(:a, :b, :c), list(:d, :e), l))
277
+ # expect(result.to_s).to eq('((:a :b :c) (:d :e))')
278
+ # end
223
279
  end # context
224
280
  end # describe
225
281
  end # module
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_kraken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.00
4
+ version: 0.3.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: Implementation of Minikanren language in Ruby. WIP
55
+ description: Implementation of miniKanren language in Ruby. WIP
56
56
  email:
57
57
  - famished.tiger@yahoo.com
58
58
  executables: []
@@ -183,7 +183,7 @@ requirements: []
183
183
  rubygems_version: 3.0.3
184
184
  signing_key:
185
185
  specification_version: 4
186
- summary: Implementation of Minikanren language in Ruby. WIP
186
+ summary: Implementation of miniKanren language in Ruby. WIP
187
187
  test_files:
188
188
  - spec/atomic/atomic_term_spec.rb
189
189
  - spec/atomic/k_boolean_spec.rb