yamlt 0.0.17 → 0.0.18
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/yamlt/loader.rb +1 -1
- data/lib/yamlt/parser/line.rb +2 -2
- data/lib/yamlt/parser/state.rb +11 -3
- 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: 736707264f61e3efa8e47dc97679cf31c6212901
|
4
|
+
data.tar.gz: ffebd17ae4f1fc94fe0d7800d8ba3e196718c7b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7810b4c8bea3e38bf769bef673e0c7be935449823cb31880d728e8724412a6b69120f6b1864a0474a3ac3bc0b680dd93e4b957b1507d9c5b5f634a8b2fcf57
|
7
|
+
data.tar.gz: 830c7639022326bc46e0f145207d774b09115be0bc0f02ad918f54f87cc8961c424882f052d4d79d36ce58461b0b3841a3aa127b82dcb659cf8203dd0bfa4f16
|
data/lib/yamlt/loader.rb
CHANGED
@@ -34,7 +34,7 @@ module Yamlt
|
|
34
34
|
def path0(key)
|
35
35
|
keys = values.keys
|
36
36
|
|
37
|
-
raise ::Yamlt::LoaderException "Locale file should have only one root key" if keys.size
|
37
|
+
raise ::Yamlt::LoaderException "Locale file should have only one root key" if keys.size > 1
|
38
38
|
|
39
39
|
key.split(".").tap do |path|
|
40
40
|
path[0] = keys.first
|
data/lib/yamlt/parser/line.rb
CHANGED
@@ -13,7 +13,7 @@ module Yamlt
|
|
13
13
|
parse
|
14
14
|
end
|
15
15
|
|
16
|
-
attr_reader :comment, :prefix, :fragment, :level, :multiline
|
16
|
+
attr_reader :comment, :prefix, :fragment, :level, :multiline, :clean
|
17
17
|
attr_accessor :full_path, :value
|
18
18
|
|
19
19
|
def as_text(opts={})
|
@@ -34,7 +34,7 @@ module Yamlt
|
|
34
34
|
def parse
|
35
35
|
case @text
|
36
36
|
when /^\s*$/
|
37
|
-
|
37
|
+
@clean = true
|
38
38
|
when /^(\s*)#(.*)$/; @comment = $~[2]; @prefix = $~[1]
|
39
39
|
when /^(\s*)(\w+):(\s*)(#(.*))?$/
|
40
40
|
if $~[1].length % 2 == 0
|
data/lib/yamlt/parser/state.rb
CHANGED
@@ -16,19 +16,27 @@ module Yamlt
|
|
16
16
|
attr_reader :path, :level, :multiline, :line, :lines, :values, :language
|
17
17
|
|
18
18
|
def apply(line)
|
19
|
-
pass_through(line) if line.empty?
|
19
|
+
pass_through(line) if line.empty? && !should_apply_value?(line)
|
20
20
|
apply_fragment(line) if line.fragment
|
21
|
-
apply_value(line) if
|
21
|
+
apply_value(line) if should_apply_value?(line)
|
22
22
|
end
|
23
23
|
|
24
24
|
def flush
|
25
25
|
if @line && @line.multiline && !@multiline.empty?
|
26
26
|
add_value
|
27
27
|
end
|
28
|
+
|
29
|
+
if @lines.last && @lines.last.clean
|
30
|
+
@lines.pop
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
private
|
31
35
|
|
36
|
+
def should_apply_value?(line)
|
37
|
+
!line.fragment && (line.value || line.clean)
|
38
|
+
end
|
39
|
+
|
32
40
|
def pass_through(line)
|
33
41
|
@lines.push(line)
|
34
42
|
end
|
@@ -65,7 +73,7 @@ module Yamlt
|
|
65
73
|
end
|
66
74
|
|
67
75
|
def apply_value(line)
|
68
|
-
if line.level != @level
|
76
|
+
if line.level != @level && !line.clean
|
69
77
|
raise Yamlt::Parser::StateException, "Wrong identation in multiline value\n#{line.as_text}"
|
70
78
|
end
|
71
79
|
@multiline.push(line.value)
|