yamlt 0.0.24 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yamlt/parser/line.rb +36 -6
- data/lib/yamlt/parser/state.rb +1 -1
- data/lib/yamlt/updater.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9d5d195fac914fea149b3c5a8bcc156d4233c1
|
4
|
+
data.tar.gz: 94ec79d8bb133b7f5e40b88d5526fbef9b73bcf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0f604b1bed356e30f270f7b07df82e5e715d03950c78f24911213c6c55b3094507c8c41587bebf249a0db2c5c7a0c7e0250f4802718bbcf83b49e0f65e328d8
|
7
|
+
data.tar.gz: 487e0d25bf9aa7b08dec5f1056617a9897d78de24f1e0a98f5bceff60a1b04b3fc21e4f35f1769a8e07d4ab3c8c93b88a745b13d4fc509d040ec4d9a4fd79cf5
|
data/lib/yamlt/parser/line.rb
CHANGED
@@ -17,6 +17,12 @@ module Yamlt
|
|
17
17
|
attr_reader :comment_prefix
|
18
18
|
attr_accessor :full_path, :value
|
19
19
|
|
20
|
+
CLEAN_LINE = /^\s*$/
|
21
|
+
COMMENT_LINE = /^(?<prefix>\s*)#(?<comment>.*)$/
|
22
|
+
FRAGMENT_WITHOUT_VALUE = /^(\s*)(\w+):(\s*&\S+)?(\s*)(#(.*))?$/
|
23
|
+
FRAGMENT_WITH_VALUE = /^(\s*)(\w+):(\s*(!\s*)?)([\'\"])(.*)\5((\s*)#(.*))?$/
|
24
|
+
FRAGMENT_WITH_MULTILINE_START = /^(\s*)(\w+):(\s*)\|(\s*)$/
|
25
|
+
|
20
26
|
def as_text(opts={})
|
21
27
|
serializer = Serializer.new(self, opts)
|
22
28
|
serializer.to_s
|
@@ -32,12 +38,36 @@ module Yamlt
|
|
32
38
|
value.gsub(/\\\"/, "\"")
|
33
39
|
end
|
34
40
|
|
41
|
+
def clean_line
|
42
|
+
if CLEAN_LINE === @text
|
43
|
+
@clean = true
|
44
|
+
true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def comment_line
|
49
|
+
if COMMENT_LINE === @text
|
50
|
+
@comment = $~[:comment]
|
51
|
+
@prefix = $~[:prefix]
|
52
|
+
true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
35
56
|
def parse
|
57
|
+
# clean_line ||
|
58
|
+
# comment_line ||
|
59
|
+
# fragment_without_value ||
|
60
|
+
# fragment_with_value ||
|
61
|
+
# fragment_with_multiline_start
|
62
|
+
# # etc.
|
63
|
+
|
36
64
|
case @text
|
37
|
-
when
|
65
|
+
when CLEAN_LINE
|
38
66
|
@clean = true
|
39
|
-
when
|
40
|
-
|
67
|
+
when COMMENT_LINE
|
68
|
+
@comment = $~[:comment]
|
69
|
+
@prefix = $~[:prefix]
|
70
|
+
when FRAGMENT_WITHOUT_VALUE
|
41
71
|
if $~[1].length % 2 == 0
|
42
72
|
@fragment = $~[2]
|
43
73
|
@level = $~[1].length / 2
|
@@ -45,7 +75,7 @@ module Yamlt
|
|
45
75
|
@prefix = $~[4]
|
46
76
|
@comment = $~[6]
|
47
77
|
end
|
48
|
-
when
|
78
|
+
when FRAGMENT_WITH_VALUE
|
49
79
|
if $~[1].length % 2 == 0
|
50
80
|
@fragment = $~[2]
|
51
81
|
@level = $~[1].length / 2
|
@@ -54,7 +84,7 @@ module Yamlt
|
|
54
84
|
@comment_prefix = $~[8]
|
55
85
|
@comment = $~[9]
|
56
86
|
end
|
57
|
-
when
|
87
|
+
when FRAGMENT_WITH_MULTILINE_START
|
58
88
|
if $~[1].length % 2 == 0
|
59
89
|
@fragment = $~[2]
|
60
90
|
@level = $~[1].length / 2
|
@@ -68,7 +98,7 @@ module Yamlt
|
|
68
98
|
@anchor = $~[3]
|
69
99
|
@comment = $~[5]
|
70
100
|
end
|
71
|
-
when /^(\s*)(['"]?)(.*)\2\s*$/
|
101
|
+
when /^(\s*)(['"]?)(.*)\2\s*$/ #
|
72
102
|
if $~[1].length % 2 == 0
|
73
103
|
@level = $~[1].length / 2
|
74
104
|
@value = unescape($~[3])
|
data/lib/yamlt/parser/state.rb
CHANGED
data/lib/yamlt/updater.rb
CHANGED
@@ -9,10 +9,11 @@ require "yamlt/translator"
|
|
9
9
|
|
10
10
|
module Yamlt
|
11
11
|
class Updater
|
12
|
-
def initialize(source, target, translator_class
|
12
|
+
def initialize(source, target, translator_class: Yamlt::Updater.translator_class, config_path: "..")
|
13
13
|
@source = source
|
14
14
|
@target = target
|
15
15
|
@translator = translator_class.new(state.language, loader.language)
|
16
|
+
@config_path = config_path
|
16
17
|
@config = config
|
17
18
|
end
|
18
19
|
|
@@ -66,7 +67,7 @@ module Yamlt
|
|
66
67
|
|
67
68
|
def config_source
|
68
69
|
@config_source ||=
|
69
|
-
File.join(File.dirname(@source), "yamlt.yml")
|
70
|
+
File.join(File.dirname(@source), @config_path, "yamlt.yml")
|
70
71
|
end
|
71
72
|
|
72
73
|
def original_prefix
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamlt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tangerine Cat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|