mumukit 2.4.0 → 2.5.0

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
  SHA1:
3
- metadata.gz: 3f8afb7358f144c2e25c356c70f0061144ff2f04
4
- data.tar.gz: d41e834b6c92fea4897c87d46f5d3303983a8209
3
+ metadata.gz: 8925e9f1727a1384b990a00c205f3a9c8906dc66
4
+ data.tar.gz: a293893f800ed01ba33851073a2a2574176e3a7c
5
5
  SHA512:
6
- metadata.gz: b4830f051f2f4ede2c1a76f05306974ea4c8d05947b2a0b8e4d2f7c3b3ad5dbb32207045accb30c10815bd90dd2e6ccc8a9e982a947e48c0fd17df2582b67e63
7
- data.tar.gz: d1c908995f05aeab6cd7bc6a47c4614a20ec242cb3e49fee4497060c03ebc87a3636578652a3fb3716016543861405db1c7a4cd94335772303ed5cc30a06d30a
6
+ metadata.gz: ec200c9bf73b9e7842837b709fbbd40c9bf81a67c06364e476088b364a57f5f14e195b69f310373053faa91d2e753f4409f961ac15e50af0f841fd368bf46084
7
+ data.tar.gz: 45e77d2ce74b4771aa851e3e327f0aa1f6c121f78c93aad4538c0404361497e395496aa2ca2c057abfd2564233730beed044ea63c1629796a6ff7d95a6471013
@@ -0,0 +1,23 @@
1
+ class Mumukit::Explainer
2
+ def explain(content, test_results)
3
+ explain_methods
4
+ .map { |selector, key| eval_explain(selector, key, content, test_results) }
5
+ .compact
6
+ .map { |explain| I18n.t(explain[:key], explain[:binding]) }
7
+ .map { |it| "* #{it}" }
8
+ .join("\n")
9
+ end
10
+
11
+ def eval_explain(selector, key, content, test_results)
12
+ send(selector, content, test_results).try do |it|
13
+ {key: key, binding: it}
14
+ end
15
+ end
16
+
17
+ def explain_methods
18
+ self.class
19
+ .instance_methods(false)
20
+ .flat_map { |it| it.to_s.captures(/explain_(.*)/).map { [it, $1] } }
21
+ .compact
22
+ end
23
+ end
@@ -1,10 +1,10 @@
1
1
  module Mumukit::Metatest
2
2
  class Checker
3
- def check(value, example)
4
- example[:postconditions].each { |key, arg| check_assertion key, value, arg, example }
5
- [example[:name], :passed, render_success_output(value)]
3
+ def check(result, example)
4
+ example[:postconditions].each { |key, arg| check_assertion key, result, arg, example }
5
+ [example[:name], :passed, render_success_output(result)]
6
6
  rescue => e
7
- [example[:name], :failed, render_error_output(value, e.message)]
7
+ [example[:name], :failed, render_error_output(result, e.message)]
8
8
  end
9
9
 
10
10
  def render_success_output(value)
@@ -15,8 +15,8 @@ module Mumukit::Metatest
15
15
  error
16
16
  end
17
17
 
18
- def check_assertion(key, value, arg, example)
19
- send "check_#{key}", value, arg
18
+ def check_assertion(key, result, arg, example)
19
+ send "check_#{key}", result, arg
20
20
  end
21
21
 
22
22
  def fail(message)
@@ -1,3 +1,3 @@
1
1
  module Mumukit
2
- VERSION = '2.4.0'
2
+ VERSION = '2.5.0'
3
3
  end
data/lib/mumukit.rb CHANGED
@@ -65,4 +65,5 @@ require_relative 'mumukit/templates'
65
65
  require_relative 'mumukit/request_validation_error'
66
66
  require_relative 'mumukit/defaults'
67
67
  require_relative 'mumukit/metatest'
68
+ require_relative 'mumukit/explainer'
68
69
  require_relative 'mumukit/server'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -212,6 +212,7 @@ files:
212
212
  - lib/mumukit/defaults/default_test_hook.rb
213
213
  - lib/mumukit/defaults/default_validation_hook.rb
214
214
  - lib/mumukit/env.rb
215
+ - lib/mumukit/explainer.rb
215
216
  - lib/mumukit/hook.rb
216
217
  - lib/mumukit/isolated_environment.rb
217
218
  - lib/mumukit/metatest.rb