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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54e44a217d69587711be7e1668c9c4ecb95db551
4
- data.tar.gz: 6a514cc17e8dca2f3d0c8319dd600592756779e2
3
+ metadata.gz: 6e9d5d195fac914fea149b3c5a8bcc156d4233c1
4
+ data.tar.gz: 94ec79d8bb133b7f5e40b88d5526fbef9b73bcf2
5
5
  SHA512:
6
- metadata.gz: 5591bc1936d2345f63e24f25807af2064d54b6b02c2258a83fdb58735657eb1d1922b8d47b54f315642d411691ee6becfe6c0bd2dbfb278b8b10ed6977208775
7
- data.tar.gz: 155ac88c6d3b5ac5e1f436384255c345a61bf7f34cd4d5da97cbea1e80e3f7581ba1a6624f68eed070d6b09d3bac0129dd1cb343a3d06a48130b30a75a079f7e
6
+ metadata.gz: b0f604b1bed356e30f270f7b07df82e5e715d03950c78f24911213c6c55b3094507c8c41587bebf249a0db2c5c7a0c7e0250f4802718bbcf83b49e0f65e328d8
7
+ data.tar.gz: 487e0d25bf9aa7b08dec5f1056617a9897d78de24f1e0a98f5bceff60a1b04b3fc21e4f35f1769a8e07d4ab3c8c93b88a745b13d4fc509d040ec4d9a4fd79cf5
@@ -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 /^\s*$/
65
+ when CLEAN_LINE
38
66
  @clean = true
39
- when /^(\s*)#(.*)$/; @comment = $~[2]; @prefix = $~[1]
40
- when /^(\s*)(\w+):(\s*&\S+)?(\s*)(#(.*))?$/
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 /^(\s*)(\w+):(\s*(!\s*)?)([\'\"])(.*)\5((\s*)#(.*))?$/
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 /^(\s*)(\w+):(\s*)\|(\s*)$/
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])
@@ -10,7 +10,7 @@ module Yamlt
10
10
  @lines = []
11
11
  @values = {}
12
12
 
13
- @languate = nil
13
+ @language = nil
14
14
  end
15
15
 
16
16
  attr_reader :path, :level, :multiline, :line, :lines, :values, :language
@@ -9,10 +9,11 @@ require "yamlt/translator"
9
9
 
10
10
  module Yamlt
11
11
  class Updater
12
- def initialize(source, target, translator_class = Yamlt::Updater.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.24
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-03 00:00:00.000000000 Z
11
+ date: 2015-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec