mumuki-text-runner 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/checker.rb +7 -0
- data/lib/comparers/equality_comparer.rb +29 -0
- data/lib/metadata_hook.rb +13 -0
- data/lib/options/ignore_case.rb +7 -0
- data/lib/options/ignore_whitespace.rb +7 -0
- data/lib/test_hook.rb +22 -0
- data/lib/text_runner.rb +20 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjRkYTVjMzc2MmM5NTExNDE4ZjgwMTIxMTk4ZDM3M2E1MWYwYTJkMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGVhMjUxYWNjYmQwZTAyZGMwYzcxZjM4MGE0MzM1NzQ2ZGQ3M2Q4ZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2RmMjgxNzEzMmQ4NzFkM2JjMGEzMTQ1NzI2NzA5ZDc2N2UyNmNjMTVhYzQ2
|
10
|
+
ZWVjNTlmNWM0YjIzMzMwMzlkYmJhM2QwY2RkOTgwNGQ3OWU3ZTVkOTIxYzE1
|
11
|
+
NDRmNDNjOTkzMDQ2MjNjY2RhNTZjMGQ2YWZhNGQ4OTFiMDZiY2Q=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzBjNTIxMzEzZjBiZmVlODI4ZjlmYTg5ODdjMjlmYmY2Y2E0OWMzODI4Y2U3
|
14
|
+
YmQzMTM2NWExYzFhOGIzY2FkODYyZjcyM2I2YThiMWFkNzk0NmJhYTY1NWRk
|
15
|
+
YWE2YzY5MDk1MTk4ZDM0OTM1NzFkYTlkZWYxMzYzMjFkODViYzg=
|
data/lib/checker.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class EqualityComparer
|
2
|
+
def initialize(config)
|
3
|
+
opts = config
|
4
|
+
opts = { expected: config } unless config.is_a? Hash
|
5
|
+
@expected = opts[:expected]
|
6
|
+
parse_options(opts)
|
7
|
+
end
|
8
|
+
|
9
|
+
def satisfies?(source)
|
10
|
+
@actual = transform(source)
|
11
|
+
@actual == @expected
|
12
|
+
end
|
13
|
+
|
14
|
+
def locale_error_message
|
15
|
+
I18n.t 'equality.failure', actual: @actual
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def transform(source)
|
21
|
+
@modifiers.inject(source) { |text, modifier| modifier.apply(text) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_options(config)
|
25
|
+
@modifiers = []
|
26
|
+
@modifiers << IgnoreWhitespace if config[:ignore_whitespace]
|
27
|
+
@modifiers << IgnoreCase if config[:ignore_case]
|
28
|
+
end
|
29
|
+
end
|
data/lib/test_hook.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mumukit/hook'
|
2
|
+
|
3
|
+
class TextTestHook < Mumukit::Hook
|
4
|
+
def compile(request)
|
5
|
+
{ source: request[:content].strip, examples: parse_test(request[:test]) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def run!(test_definition)
|
9
|
+
metatest.test(test_definition, test_definition[:examples])
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def metatest
|
15
|
+
Mumukit::Metatest::Framework.new(checker: TextChecker.new,
|
16
|
+
runner: Mumukit::Metatest::IdentityRunner.new)
|
17
|
+
end
|
18
|
+
|
19
|
+
def parse_test(tests)
|
20
|
+
YAML.load(tests).map { |example| example.deep_symbolize_keys }
|
21
|
+
end
|
22
|
+
end
|
data/lib/text_runner.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mumukit'
|
2
|
+
require 'yaml'
|
3
|
+
require 'i18n'
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
Mumukit.runner_name = 'text'
|
7
|
+
Mumukit.configure do |config|
|
8
|
+
config.content_type = 'markdown'
|
9
|
+
end
|
10
|
+
|
11
|
+
I18n.load_path += Dir[File.join('.', 'locales', '*.yml')]
|
12
|
+
|
13
|
+
require_relative './metadata_hook'
|
14
|
+
require_relative './test_hook'
|
15
|
+
|
16
|
+
require_relative './checker'
|
17
|
+
|
18
|
+
require_relative './comparers/equality_comparer'
|
19
|
+
require_relative './options/ignore_whitespace'
|
20
|
+
require_relative './options/ignore_case'
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mumuki-text-runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franco Leonardo Bulgarelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mumukit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mumukit-bridge
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- franco@mumuki.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- lib/checker.rb
|
105
|
+
- lib/comparers/equality_comparer.rb
|
106
|
+
- lib/metadata_hook.rb
|
107
|
+
- lib/options/ignore_case.rb
|
108
|
+
- lib/options/ignore_whitespace.rb
|
109
|
+
- lib/test_hook.rb
|
110
|
+
- lib/text_runner.rb
|
111
|
+
homepage: http://github.com/mumuki/mumuki-text-server
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.5
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Text Runner for Mumuki
|
135
|
+
test_files: []
|