mulang 5.1.0.1 → 5.1.0.2
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 +4 -4
- data/lib/locales/en.yml +0 -12
- data/lib/locales/es.yml +0 -12
- data/lib/locales/pt.yml +0 -12
- data/lib/mulang/expectation/custom.rb +2 -0
- data/lib/mulang/expectation/i18n.rb +7 -3
- data/lib/mulang/expectation/standard.rb +4 -0
- data/lib/mulang/inspection.rb +27 -2
- data/lib/mulang/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d89c5d28d9b39c74f3724825ccc3c29fd773712267fd15b3c0853f7d67b63f54
|
|
4
|
+
data.tar.gz: a0b2fd73c979187897d9ded8b9f1f4375658f8e99b1734e243274658b5b59650
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71ffc947d7e0e5e41c71bc55c53ca53af0cc4dda60278373aeda511b28f62656ab7d08b908a3b353758837ad25096ac81161c11a64c93e752ee3a79fb2e91803
|
|
7
|
+
data.tar.gz: 4967f99afd203f00221edf8f01abafe95c81b3981c68ad8af0a04c61838679ea966dcc8758c6dddce3d570351aea7071a809c6ed428ea90ca209c0afd96280ca
|
data/lib/locales/en.yml
CHANGED
|
@@ -85,14 +85,6 @@ en:
|
|
|
85
85
|
DeclaresRule_like: '%{binding} %{must} declare a rule similar to %{target}'
|
|
86
86
|
DeclaresRule_named: '%{binding} %{must} declare a rule %{target}'
|
|
87
87
|
DeclaresRule: '%{binding} %{must} debe declare rules'
|
|
88
|
-
DeclaresStyles_except: '%{binding} %{must} declare style distinct from %{target}'
|
|
89
|
-
DeclaresStyles_like: '%{binding} %{must} declare a style similar to %{target}'
|
|
90
|
-
DeclaresStyles_named: '%{binding} %{must} declare a style %{target}'
|
|
91
|
-
DeclaresStyles: '%{binding} %{must} declare styles'
|
|
92
|
-
DeclaresTag_except: '%{binding} %{must} declare a tag distinct from %{target}'
|
|
93
|
-
DeclaresTag_like: '%{binding} %{must} declare a tag similar to %{target}'
|
|
94
|
-
DeclaresTag_named: '%{binding} %{must} declare a tag %{target}'
|
|
95
|
-
DeclaresTag: '%{binding} %{must} declare a tag'
|
|
96
88
|
DeclaresTypeAlias_except: '%{binding} %{must} declare type aliases distinct from %{target}'
|
|
97
89
|
DeclaresTypeAlias_like: '%{binding} %{must} declare a type alias similar to %{target}'
|
|
98
90
|
DeclaresTypeAlias_named: '%{binding} %{must} declare a type alias %{target}'
|
|
@@ -151,10 +143,6 @@ en:
|
|
|
151
143
|
Returns: '%{binding} %{must} return%{matching}'
|
|
152
144
|
ReturnsNil: '%{binding} retuns <i>%{keyword_null}</i>, which is a bad practice'
|
|
153
145
|
ReturnsNull: '%{binding} retuns <i>%{keyword_null}</i>, which is a bad practice'
|
|
154
|
-
SourceContains_named: 'solution %{must} use %{target}'
|
|
155
|
-
SourceEquals_named: 'solution %{must} be equal to %{target}'
|
|
156
|
-
SourceEqualsIgnoreSpaces_named: 'solution %{must} be equal to %{target}'
|
|
157
|
-
SourceRepeats_named: 'solution %{must} use %{target} more than one time'
|
|
158
146
|
TypesAs_named: '%{binding} %{must} type as %{target}'
|
|
159
147
|
TypesAs: '%{binding} %{must} type'
|
|
160
148
|
TypesParameterAs_except: '%{binding} %{must} type parameters with a type distinct from %{target}'
|
data/lib/locales/es.yml
CHANGED
|
@@ -85,18 +85,10 @@ es:
|
|
|
85
85
|
DeclaresRule_like: '%{binding} %{must} declarar una regla parecida a %{target}'
|
|
86
86
|
DeclaresRule_named: '%{binding} %{must} declarar una regla %{target}'
|
|
87
87
|
DeclaresRule: '%{binding} %{must} debe declarar reglas'
|
|
88
|
-
DeclaresStyle_except: '%{binding} %{must} declarar un estilo diferente a %{target}'
|
|
89
|
-
DeclaresStyle_like: '%{binding} %{must} declarar un estilo parecido a %{target}'
|
|
90
|
-
DeclaresStyle_named: '%{binding} %{must} declarar un estilo %{target}'
|
|
91
|
-
DeclaresStyle: '%{binding} %{must} declarar un estilo'
|
|
92
88
|
DeclaresSuperclass_except: '%{binding} %{must} declarar una superclase distinta de %{target}'
|
|
93
89
|
DeclaresSuperclass_like: '%{binding} %{must} declarar una superclase parecida a %{target}'
|
|
94
90
|
DeclaresSuperclass_named: '%{binding} %{must} declarar una superclase %{target}'
|
|
95
91
|
DeclaresSuperclass: '%{binding} %{must} declarar una superclase'
|
|
96
|
-
DeclaresTag_except: '%{binding} %{must} declarar un elemento diferente a %{target}'
|
|
97
|
-
DeclaresTag_like: '%{binding} %{must} declarar un elemento parecido a %{target}'
|
|
98
|
-
DeclaresTag_named: '%{binding} %{must} declarar un elemento %{target}'
|
|
99
|
-
DeclaresTag: '%{binding} %{must} declarar un elemento'
|
|
100
92
|
DeclaresTypeAlias_except: '%{binding} %{must} declarar sinónimos de tipo diferentes a %{target}'
|
|
101
93
|
DeclaresTypeAlias_like: '%{binding} %{must} declarar un sinónimo de tipo parecido a %{target}'
|
|
102
94
|
DeclaresTypeAlias_named: '%{binding} %{must} declarar un sinónimo de tipo %{target}'
|
|
@@ -163,10 +155,6 @@ es:
|
|
|
163
155
|
Returns: '%{binding} %{must} retornar%{matching}'
|
|
164
156
|
ReturnsNil: '%{binding} retorna null, lo cual es una mala práctica'
|
|
165
157
|
ReturnsNull: '%{binding} retorna null, lo cual es una mala práctica'
|
|
166
|
-
SourceContains_named: 'la solución %{must} usar %{target}'
|
|
167
|
-
SourceEquals_named: 'la solución %{must} ser igual a %{target}'
|
|
168
|
-
SourceEqualsIgnoreSpaces_named: 'la solución %{must} ser igual a %{target}'
|
|
169
|
-
SourceRepeats_named: 'la solución %{must} usar %{target} más de una vez'
|
|
170
158
|
TypesAs_named: '%{binding} %{must} ser de tipo %{target}'
|
|
171
159
|
TypesAs: '%{binding} %{must} tipar'
|
|
172
160
|
TypesParameterAs_except: '%{binding} %{must} tipar parámetros con un tipo diferente a %{target}'
|
data/lib/locales/pt.yml
CHANGED
|
@@ -85,18 +85,10 @@ pt:
|
|
|
85
85
|
DeclaresRule_like: '%{binding} %{must} declarar uma regra semelhante a %{target}'
|
|
86
86
|
DeclaresRule_named: '%{binding} %{must} declarar uma regra %{target}'
|
|
87
87
|
DeclaresRule: '%{binding} %{must} deve declarar regras'
|
|
88
|
-
DeclaresStyle_except: '%{binding} %{must} declarar um estilo diferentes de %{target}'
|
|
89
|
-
DeclaresStyle_like: '%{binding} %{must} declarar um estilo semelhante a %{target}'
|
|
90
|
-
DeclaresStyle_named: '%{binding} %{must} declarar um estilo %{target}'
|
|
91
|
-
DeclaresStyle: '%{binding} %{must} declarar um estilo'
|
|
92
88
|
DeclaresSuperclass_except: '%{binding} %{must} declarar uma superclasse diferente de %{target}'
|
|
93
89
|
DeclaresSuperclass_like: '%{binding} %{must} declarar uma superclasse semelhante a %{target}'
|
|
94
90
|
DeclaresSuperclass_named: '%{binding} %{must} declarar uma superclasse %{target}'
|
|
95
91
|
DeclaresSuperclass: '%{binding} %{must} declarar uma superclasse'
|
|
96
|
-
DeclaresTag_except: '%{binding} %{must} declarar uma etiqueta diferente de %{target}'
|
|
97
|
-
DeclaresTag_like: '%{binding} %{must} declarar uma etiqueta similar a %{target}'
|
|
98
|
-
DeclaresTag_named: '%{binding} %{must} declarar uma etiqueta %{target}'
|
|
99
|
-
DeclaresTag: '%{binding} %{must} declarar uma etiqueta'
|
|
100
92
|
DeclaresTypeAlias_except: '%{binding} %{must} declarar sinônimos de tipo diferente de %{target}'
|
|
101
93
|
DeclaresTypeAlias_like: '%{binding} %{must} declarar um sinônimo de tipo similar a %{target}'
|
|
102
94
|
DeclaresTypeAlias_named: '%{binding} %{must} declarar um sinônimo do tipo %{target}'
|
|
@@ -159,10 +151,6 @@ pt:
|
|
|
159
151
|
Returns: '%{binding} %{must} retornar%{matching}'
|
|
160
152
|
ReturnsNil: '%{binding} retorna nulo, o que é uma prática ruim'
|
|
161
153
|
ReturnsNull: '%{binding} retorna nulo, o que é uma prática ruim'
|
|
162
|
-
SourceContains_named: 'a solução %{must} usar %{target}'
|
|
163
|
-
SourceEquals_named: 'a solução %{must} ser igual a %{target}'
|
|
164
|
-
SourceEqualsIgnoreSpaces_named: 'a solução %{must} ser igual a %{target}'
|
|
165
|
-
SourceRepeats_named: 'a solução %{must} usar %{target} mais de uma vez'
|
|
166
154
|
TypesAs_named: '%{binding} %{must} é do tipo %{target}'
|
|
167
155
|
TypesAs: '%{binding} %{must} tem tipo'
|
|
168
156
|
TypesReturnAs_named: '%{binding} %{must} tem tipo de valor de retorno %{target}'
|
|
@@ -19,11 +19,15 @@ module Mulang::Expectation::I18n
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
def translate(e, keywords = nil)
|
|
22
|
+
translate!(e, keywords)
|
|
23
|
+
rescue
|
|
24
|
+
'<unknown expectation>'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def translate!(e, keywords = nil)
|
|
22
28
|
e = e.as_v2
|
|
23
29
|
key = key_for e.binding, e.inspection
|
|
24
30
|
::I18n.t key, translation_params(e, keywords)
|
|
25
|
-
rescue
|
|
26
|
-
'<unknown expectation>'
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
alias t translate
|
|
@@ -39,7 +43,7 @@ module Mulang::Expectation::I18n
|
|
|
39
43
|
end
|
|
40
44
|
|
|
41
45
|
def key_for(binding, inspection)
|
|
42
|
-
"
|
|
46
|
+
"#{inspection.i18n_namespace}.#{inspection.type}#{inspection.target ? inspection.target.i18n_suffix : nil}"
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
def t_binding(binding)
|
|
@@ -15,6 +15,10 @@ class Mulang::Expectation::Standard
|
|
|
15
15
|
Mulang::Expectation::I18n.translate self, keywords
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
def translate!(keywords = nil)
|
|
19
|
+
Mulang::Expectation::I18n.translate! self, keywords
|
|
20
|
+
end
|
|
21
|
+
|
|
18
22
|
def to_h
|
|
19
23
|
{binding: binding, inspection: inspection.to_s}
|
|
20
24
|
end
|
data/lib/mulang/inspection.rb
CHANGED
|
@@ -20,11 +20,12 @@ module Mulang
|
|
|
20
20
|
attr_accessor :type, :target, :matcher, :negated
|
|
21
21
|
alias negated? negated
|
|
22
22
|
|
|
23
|
-
def initialize(type, target, negated: false, matcher: nil)
|
|
23
|
+
def initialize(type, target, negated: false, matcher: nil, i18n_namespace: nil)
|
|
24
24
|
@type = type
|
|
25
25
|
@target = target
|
|
26
26
|
@negated = negated
|
|
27
27
|
@matcher = matcher
|
|
28
|
+
@i18n_namespace = i18n_namespace
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def to_s
|
|
@@ -43,6 +44,10 @@ module Mulang
|
|
|
43
44
|
matcher ? ":#{matcher.to_s}" : nil
|
|
44
45
|
end
|
|
45
46
|
|
|
47
|
+
def i18n_namespace
|
|
48
|
+
@i18n_namespace || 'mulang.inspection'
|
|
49
|
+
end
|
|
50
|
+
|
|
46
51
|
def self.parse_binding_name(binding_s)
|
|
47
52
|
if binding_s.start_with? 'Intransitive:'
|
|
48
53
|
binding_s[13..-1]
|
|
@@ -52,14 +57,34 @@ module Mulang
|
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
def self.parse(inspection_s)
|
|
60
|
+
parse_extension(inspection_s).try { |it| return it }
|
|
55
61
|
match = REGEXP.match inspection_s
|
|
56
62
|
raise "Invalid inspection #{inspection_s}" unless match
|
|
57
|
-
Inspection.new(
|
|
63
|
+
Mulang::Inspection.new(
|
|
58
64
|
match['type'],
|
|
59
65
|
Mulang::Inspection::Target.parse(match['target']),
|
|
60
66
|
matcher: Mulang::Inspection::Matcher.parse(match['matcher'], match['value']),
|
|
61
67
|
negated: match['negation'].present?)
|
|
62
68
|
end
|
|
69
|
+
|
|
70
|
+
def self.parse_extension(inspection_s)
|
|
71
|
+
extensions.each do |extension|
|
|
72
|
+
extension.parse(inspection_s).try { |it| return it }
|
|
73
|
+
end
|
|
74
|
+
nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.extensions
|
|
78
|
+
@extensions ||= []
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.register_extension!(extension)
|
|
82
|
+
extensions << extension
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.unregister_extension!(extension)
|
|
86
|
+
extensions.delete extension
|
|
87
|
+
end
|
|
63
88
|
end
|
|
64
89
|
end
|
|
65
90
|
|
data/lib/mulang/version.rb
CHANGED