yaml-validator 0.1.8 → 0.1.9
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/Gemfile.lock +1 -1
- data/lib/yaml-validator.rb +8 -0
- data/lib/yaml-validator/version.rb +1 -1
- data/spec/fixtures/wrong_variables/en.yml +2 -0
- data/spec/fixtures/wrong_variables/he.yml +2 -0
- data/spec/yaml-validator_spec.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72169d02254be948df3251d36d2695c6bee61d2f
|
4
|
+
data.tar.gz: 7c9dcfae1d208b65c0dcd55407e3471a68193a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54294202eaf60a86469bad84b94d95fb81f01c45f5df2c49bcc73f3abb61f0412728f4e2610b7d8ad3583a108a7143b6d508fba8e9b19cbb464cafe765fd1853
|
7
|
+
data.tar.gz: 811d5884ebfa60693e3f1d4b31f77afcb588185a8b451348c3f7693557e0fa9c2efd0ecf1b6d7d3be89c96eebf17cdb9d922468c5cf62d90abcf3fc4f7767c1e
|
data/Gemfile.lock
CHANGED
data/lib/yaml-validator.rb
CHANGED
@@ -183,9 +183,17 @@ class YamlValidator
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
+
syntax_error = /(^|[^%]){[^}]+}%?/.match(value)
|
187
|
+
unless syntax_error.nil?
|
188
|
+
return [
|
189
|
+
"#{full_key}: invalid syntax '#{syntax_error}'"
|
190
|
+
]
|
191
|
+
end
|
192
|
+
|
186
193
|
used_vars = identify_variables(value)
|
187
194
|
|
188
195
|
errors = []
|
196
|
+
|
189
197
|
used_vars.each do |var|
|
190
198
|
unless real_vars.include? var
|
191
199
|
errors << "#{full_key}: missing variable '#{var}' (available options: #{real_vars.join(', ')})"
|
data/spec/yaml-validator_spec.rb
CHANGED
@@ -25,12 +25,14 @@ describe YamlValidator do
|
|
25
25
|
|
26
26
|
|
27
27
|
describe "wrong_variables scenario" do
|
28
|
-
it "returns
|
28
|
+
it "returns errors" do
|
29
29
|
validator = YamlValidator.new('spec/fixtures/wrong_variables')
|
30
30
|
errors = validator.validate()
|
31
31
|
errors.should == [
|
32
32
|
"he.yml: parent1.key1: missing variable 'name1' (available options: name, day_of_week)",
|
33
|
-
"he.yml: parent1.key1: missing variable 'day_of_week1' (available options: name, day_of_week)"
|
33
|
+
"he.yml: parent1.key1: missing variable 'day_of_week1' (available options: name, day_of_week)",
|
34
|
+
"he.yml: parent1.key2: invalid syntax ' {name1}%'",
|
35
|
+
"he.yml: parent1.key3: invalid syntax ' {name1}'"
|
34
36
|
]
|
35
37
|
end
|
36
38
|
end
|