PoParser 1.1.0 → 2.0.0
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/CHANGELOG.md +7 -0
- data/lib/poparser/comment.rb +9 -9
- data/lib/poparser/entry.rb +1 -1
- data/lib/poparser/header.rb +2 -3
- data/lib/poparser/message.rb +12 -13
- data/lib/poparser/parser.rb +1 -1
- data/lib/poparser/version.rb +1 -1
- data/spec/poparser/fixtures/multiline.po +1 -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: 0e320991c1d0d99631e3e9f69479d8b4a4e32e75
|
4
|
+
data.tar.gz: a22450eeb90828fa9396ab9e3ae4a066286282ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7244529dfffea1b170cc164581de87a9098cf3a0f4ca981de3c3a0a2a4a5fba222a8b32cd766cfee7ead2a750d6d19740718a8829a9590bde737b6b4b2d74f2
|
7
|
+
data.tar.gz: 5ab25bb5cfbc95cfe0bb0a131bdebae1b71d16eabf26c4b0adc378611244ed85ae4020ef04d991120b3a7c5c1af8c1606fd28240d0c4144dfcd41b9ffbc5b189
|
data/CHANGELOG.md
CHANGED
data/lib/poparser/comment.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
module PoParser
|
2
2
|
class Comment
|
3
|
-
attr_accessor :type, :
|
3
|
+
attr_accessor :type, :value
|
4
4
|
|
5
|
-
def initialize(type,
|
5
|
+
def initialize(type, value)
|
6
6
|
@type = type
|
7
|
-
@
|
7
|
+
@value = value
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s(with_label = false)
|
11
|
-
return
|
12
|
-
if @
|
11
|
+
return to_str unless with_label
|
12
|
+
if @value.is_a? Array
|
13
13
|
string = []
|
14
|
-
@
|
14
|
+
@value.each do |str|
|
15
15
|
string << "#{COMMENTS_LABELS[@type]} #{str}\n".gsub(/[^\S\n]+$/, '')
|
16
16
|
end
|
17
17
|
return string.join
|
18
18
|
else
|
19
19
|
# removes the space but not newline at the end
|
20
|
-
"#{COMMENTS_LABELS[@type]} #{@
|
20
|
+
"#{COMMENTS_LABELS[@type]} #{@value}\n".gsub(/[^\S\n]+$/, '')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_str
|
25
|
-
@
|
25
|
+
@value.is_a?(Array) ? @value.join : @value
|
26
26
|
end
|
27
27
|
|
28
28
|
def inspect
|
29
|
-
@
|
29
|
+
@value
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/poparser/entry.rb
CHANGED
@@ -146,7 +146,7 @@ module PoParser
|
|
146
146
|
if instance_variable_get("@#{type}".to_sym).is_a? object
|
147
147
|
klass = instance_variable_get "@#{type}".to_sym
|
148
148
|
klass.type = type
|
149
|
-
klass.
|
149
|
+
klass.value = val
|
150
150
|
else
|
151
151
|
instance_variable_set "@#{type}".to_sym, object.new(type, val)
|
152
152
|
end
|
data/lib/poparser/header.rb
CHANGED
@@ -7,7 +7,7 @@ module PoParser
|
|
7
7
|
|
8
8
|
def initialize(entry)
|
9
9
|
@entry = entry
|
10
|
-
@comments = entry.translator_comment.
|
10
|
+
@comments = entry.translator_comment.value
|
11
11
|
@original_configs = convert_msgstr_to_hash(entry.msgstr)
|
12
12
|
|
13
13
|
HEADER_LABELS.each do |k, v|
|
@@ -46,7 +46,7 @@ module PoParser
|
|
46
46
|
|
47
47
|
private
|
48
48
|
def convert_msgstr_to_hash(msgstr)
|
49
|
-
options_array = msgstr.
|
49
|
+
options_array = msgstr.value.map do |options|
|
50
50
|
options.split(':', 2).each do |k|
|
51
51
|
k.strip!
|
52
52
|
k.chomp!
|
@@ -70,4 +70,3 @@ module PoParser
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
data/lib/poparser/message.rb
CHANGED
@@ -1,46 +1,45 @@
|
|
1
1
|
module PoParser
|
2
2
|
class Message
|
3
|
-
attr_accessor :type
|
4
|
-
attr_writer :str
|
3
|
+
attr_accessor :type, :value
|
5
4
|
|
6
|
-
def initialize(type,
|
5
|
+
def initialize(type, value)
|
7
6
|
@type = type
|
8
|
-
@
|
7
|
+
@value = value
|
9
8
|
|
10
9
|
remove_empty_line
|
11
10
|
end
|
12
11
|
|
13
12
|
def str
|
14
|
-
@
|
13
|
+
@value.is_a?(Array) ? @value.join : @value
|
15
14
|
end
|
16
15
|
|
17
16
|
def to_s(with_label = false)
|
18
|
-
return
|
19
|
-
if @
|
17
|
+
return to_str unless with_label
|
18
|
+
if @value.is_a? Array
|
20
19
|
remove_empty_line
|
21
20
|
# multiline messages should be started with an empty line
|
22
21
|
lines = ["#{label} \"\"\n"]
|
23
|
-
@
|
22
|
+
@value.each do |str|
|
24
23
|
lines << "\"#{str}\"\n"
|
25
24
|
end
|
26
25
|
return lines.join
|
27
26
|
else
|
28
|
-
"#{label} \"#{@
|
27
|
+
"#{label} \"#{@value}\"\n"
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
31
|
def to_str
|
33
|
-
@
|
32
|
+
@value.is_a?(Array) ? @value.join : @value
|
34
33
|
end
|
35
34
|
|
36
35
|
def inspect
|
37
|
-
@
|
36
|
+
@value
|
38
37
|
end
|
39
38
|
|
40
39
|
private
|
41
40
|
def remove_empty_line
|
42
|
-
if @
|
43
|
-
@
|
41
|
+
if @value.is_a? Array
|
42
|
+
@value.shift if @value.first == ''
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
data/lib/poparser/parser.rb
CHANGED
@@ -46,7 +46,7 @@ module PoParser
|
|
46
46
|
rule(:character) { escaped | text }
|
47
47
|
rule(:text) { any }
|
48
48
|
rule(:escaped) { str('\\') >> any }
|
49
|
-
rule(:msg_line_end){ str('"') >> eol }
|
49
|
+
rule(:msg_line_end){ str('"') >> space? >> eol }
|
50
50
|
|
51
51
|
rule(:comment_text_line) do
|
52
52
|
(eol.absent? >> character).repeat.maybe.as(:text) >> eol
|
data/lib/poparser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PoParser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arash Mousavi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|