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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc684bcffe8a3d42c3139420c6234d1bc89677cd
4
- data.tar.gz: 20d65a153c816821ea297a7a7481c65843dcdc81
3
+ metadata.gz: 736707264f61e3efa8e47dc97679cf31c6212901
4
+ data.tar.gz: ffebd17ae4f1fc94fe0d7800d8ba3e196718c7b0
5
5
  SHA512:
6
- metadata.gz: aaf7176fcf4f2be1e5790340ec4921ec688f8ce532f4ce8ea32f4957a6981e262a131fc31ccbe04a07660c0002e046337637008070e31e703f9a019cd4b637bd
7
- data.tar.gz: 754a240b704694b1cb3e210af063069be31fa64c6ff27598843abaf1430bf15043330ee245b00582afbd1ac5b1c7fcdf507de6c78f3b479db36be99039fc1999
6
+ metadata.gz: 1f7810b4c8bea3e38bf769bef673e0c7be935449823cb31880d728e8724412a6b69120f6b1864a0474a3ac3bc0b680dd93e4b957b1507d9c5b5f634a8b2fcf57
7
+ data.tar.gz: 830c7639022326bc46e0f145207d774b09115be0bc0f02ad918f54f87cc8961c424882f052d4d79d36ce58461b0b3841a3aa127b82dcb659cf8203dd0bfa4f16
@@ -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 != 1
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
@@ -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
- # do nothing
37
+ @clean = true
38
38
  when /^(\s*)#(.*)$/; @comment = $~[2]; @prefix = $~[1]
39
39
  when /^(\s*)(\w+):(\s*)(#(.*))?$/
40
40
  if $~[1].length % 2 == 0
@@ -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 !line.fragment && line.value
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamlt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tangerine Cat