yamlt 0.0.22 → 0.0.24
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/parser/line/serializer.rb +18 -2
- data/lib/yamlt/parser/line.rb +4 -4
- data/lib/yamlt/updater.rb +22 -1
- 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: 54e44a217d69587711be7e1668c9c4ecb95db551
|
4
|
+
data.tar.gz: 6a514cc17e8dca2f3d0c8319dd600592756779e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5591bc1936d2345f63e24f25807af2064d54b6b02c2258a83fdb58735657eb1d1922b8d47b54f315642d411691ee6becfe6c0bd2dbfb278b8b10ed6977208775
|
7
|
+
data.tar.gz: 155ac88c6d3b5ac5e1f436384255c345a61bf7f34cd4d5da97cbea1e80e3f7581ba1a6624f68eed070d6b09d3bac0129dd1cb343a3d06a48130b30a75a079f7e
|
@@ -8,6 +8,24 @@ module Yamlt
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
+
[ original, result ].compact.join($/)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def original
|
17
|
+
prefix = @overrides[:original_prefix]
|
18
|
+
if prefix
|
19
|
+
prefix = "Original:" unless prefix.is_a?(String)
|
20
|
+
|
21
|
+
[ level_string,
|
22
|
+
"# #{prefix} ",
|
23
|
+
@line.value.inspect
|
24
|
+
].join("")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def result
|
11
29
|
[ level_string,
|
12
30
|
fragment_string,
|
13
31
|
anchor_string,
|
@@ -18,8 +36,6 @@ module Yamlt
|
|
18
36
|
].join("")
|
19
37
|
end
|
20
38
|
|
21
|
-
private
|
22
|
-
|
23
39
|
def level_string
|
24
40
|
if @line.level
|
25
41
|
indent(@line.level)
|
data/lib/yamlt/parser/line.rb
CHANGED
@@ -45,14 +45,14 @@ module Yamlt
|
|
45
45
|
@prefix = $~[4]
|
46
46
|
@comment = $~[6]
|
47
47
|
end
|
48
|
-
when /^(\s*)(\w+):(\s*)([\'\"])(.*)\
|
48
|
+
when /^(\s*)(\w+):(\s*(!\s*)?)([\'\"])(.*)\5((\s*)#(.*))?$/
|
49
49
|
if $~[1].length % 2 == 0
|
50
50
|
@fragment = $~[2]
|
51
51
|
@level = $~[1].length / 2
|
52
52
|
@prefix = $~[3]
|
53
|
-
@value = unescape($~[
|
54
|
-
@comment_prefix = $~[
|
55
|
-
@comment = $~[
|
53
|
+
@value = unescape($~[6])
|
54
|
+
@comment_prefix = $~[8]
|
55
|
+
@comment = $~[9]
|
56
56
|
end
|
57
57
|
when /^(\s*)(\w+):(\s*)\|(\s*)$/
|
58
58
|
if $~[1].length % 2 == 0
|
data/lib/yamlt/updater.rb
CHANGED
@@ -13,6 +13,7 @@ module Yamlt
|
|
13
13
|
@source = source
|
14
14
|
@target = target
|
15
15
|
@translator = translator_class.new(state.language, loader.language)
|
16
|
+
@config = config
|
16
17
|
end
|
17
18
|
|
18
19
|
attr_reader :target
|
@@ -54,6 +55,24 @@ module Yamlt
|
|
54
55
|
@loader ||= Yamlt::Loader.new(@target)
|
55
56
|
end
|
56
57
|
|
58
|
+
def config
|
59
|
+
@config ||=
|
60
|
+
if File.exist?(config_source)
|
61
|
+
YAML.load_file(config_source)
|
62
|
+
else
|
63
|
+
{}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def config_source
|
68
|
+
@config_source ||=
|
69
|
+
File.join(File.dirname(@source), "yamlt.yml")
|
70
|
+
end
|
71
|
+
|
72
|
+
def original_prefix
|
73
|
+
config["original_prefix"]
|
74
|
+
end
|
75
|
+
|
57
76
|
def target_updated
|
58
77
|
@target_updated ||=
|
59
78
|
if /\.yml$/ === @target
|
@@ -70,7 +89,9 @@ module Yamlt
|
|
70
89
|
if line.value && line.full_path
|
71
90
|
path = line.full_path
|
72
91
|
target_value = loader[path]
|
73
|
-
|
92
|
+
hash = {value: @translator.translate(line.value, target_value)}
|
93
|
+
hash[:original_prefix] = original_prefix
|
94
|
+
line.as_text hash
|
74
95
|
else
|
75
96
|
line.as_text
|
76
97
|
end
|
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.24
|
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-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|