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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c503fa73edea28c9fe2799bfaaf4758eca1b36ed
4
- data.tar.gz: 60bef9cd8b188825561a14e8aeeb16fa38fb2ff1
3
+ metadata.gz: 72169d02254be948df3251d36d2695c6bee61d2f
4
+ data.tar.gz: 7c9dcfae1d208b65c0dcd55407e3471a68193a8c
5
5
  SHA512:
6
- metadata.gz: 61c78d39bc78edd00f46e64e61518fc41f13a14c03006e3b1ed6503acf4f83e0ef2ef1b07a70e1494377f582869c9c8b3bece037a57ed58cf15ae7f359a093c5
7
- data.tar.gz: b65227a65b0551438e3f6498cf095f60a7bcd26d1cd29a73295835f356339471bdfe98d6e00d3371a15d310649c42b3a7935db51cc1055a0f81606e8002544ec
6
+ metadata.gz: 54294202eaf60a86469bad84b94d95fb81f01c45f5df2c49bcc73f3abb61f0412728f4e2610b7d8ad3583a108a7143b6d508fba8e9b19cbb464cafe765fd1853
7
+ data.tar.gz: 811d5884ebfa60693e3f1d4b31f77afcb588185a8b451348c3f7693557e0fa9c2efd0ecf1b6d7d3be89c96eebf17cdb9d922468c5cf62d90abcf3fc4f7767c1e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaml-validator (0.1.8)
4
+ yaml-validator (0.1.9)
5
5
  colorize
6
6
  rake
7
7
  rspec
@@ -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(', ')})"
@@ -1,3 +1,3 @@
1
1
  class YamlValidator
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -1,3 +1,5 @@
1
1
  en:
2
2
  parent1:
3
3
  key1: "Hello, %{name}, this is %{day_of_week}"
4
+ key2: "Hello, %{name}"
5
+ key3: "Hello, %{name}"
@@ -1,3 +1,5 @@
1
1
  he:
2
2
  parent1:
3
3
  key1: "Hello, %{name1}, this is %{day_of_week1}"
4
+ key2: "Hello, {name1}%"
5
+ key3: "Hello, {name1}"
@@ -25,12 +25,14 @@ describe YamlValidator do
25
25
 
26
26
 
27
27
  describe "wrong_variables scenario" do
28
- it "returns two errors" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Elentok