get_pomo 0.8.0 → 0.8.1
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/get_pomo/po_file.rb +24 -16
- data/lib/get_pomo/translation.rb +1 -1
- data/lib/get_pomo/version.rb +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: 5dfb3605a381f45a3b9e031d2938d9e26bebcc67
|
4
|
+
data.tar.gz: 7e6b8818a926db276d8c882a6144861a89767bbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 045d16e511a1ec0500e8ecabd03a0f9cddf107cba8970465566eef542dfab5784d8975b33659ca95ff1eb0a6e9dd47a0e6c0801b3bfd94d5c957e70f29cf4632
|
7
|
+
data.tar.gz: e5fc4ebecfa88511793611818a12702c2f16b5b16c79a96f353bd25e754622c378d6b6f3ac5f528361e1053497bd404df1698cebe6864f0be0a77dac602f09fe
|
data/lib/get_pomo/po_file.rb
CHANGED
@@ -4,15 +4,11 @@ require 'get_pomo/translation'
|
|
4
4
|
module GetPomo
|
5
5
|
class PoFile
|
6
6
|
def self.parse(text, options = {})
|
7
|
-
default_options = {:parse_obsoletes => false}
|
8
|
-
options = default_options.merge(options)
|
9
7
|
PoFile.new.add_translations_from_text(text, options)
|
10
8
|
end
|
11
9
|
|
12
10
|
def self.to_text(translations, options = {})
|
13
|
-
|
14
|
-
options = default_options.merge(options)
|
15
|
-
p = PoFile.new(:translations=>translations)
|
11
|
+
p = PoFile.new(:translations => translations)
|
16
12
|
p.to_text(options)
|
17
13
|
end
|
18
14
|
|
@@ -20,14 +16,22 @@ module GetPomo
|
|
20
16
|
|
21
17
|
def initialize(options = {})
|
22
18
|
@translations = options[:translations] || []
|
19
|
+
# no object options should be set through initialize arguments for now,
|
20
|
+
# as they are meant to be changeable for each method call
|
21
|
+
@options = {:parse_obsoletes => false, :merge => false}
|
23
22
|
end
|
24
23
|
|
25
|
-
#the text is split into lines and then converted into logical translations
|
26
|
-
#each translation consists of comments(that come before a translation)
|
27
|
-
#and a msgid / msgstr
|
24
|
+
# the text is split into lines and then converted into logical translations
|
25
|
+
# each translation consists of comments(that come before a translation)
|
26
|
+
# and a msgid / msgstr
|
28
27
|
def add_translations_from_text(text, options = {})
|
28
|
+
# only keep valid options for this method
|
29
|
+
options.delete_if do |key, value|
|
30
|
+
!([:parse_obsoletes].include?(key))
|
31
|
+
end
|
32
|
+
# default options for this method
|
29
33
|
default_options = {:parse_obsoletes => false}
|
30
|
-
options
|
34
|
+
@options.merge!(default_options.merge(options))
|
31
35
|
start_new_translation
|
32
36
|
text.gsub!(/^#{"\357\273\277"}/, "") #remove boom
|
33
37
|
text.split(/$/).each_with_index do |line,index|
|
@@ -41,13 +45,18 @@ module GetPomo
|
|
41
45
|
add_string line
|
42
46
|
end
|
43
47
|
end
|
44
|
-
start_new_translation
|
48
|
+
start_new_translation #instance_variable has to be overwritten or errors can occur on next add
|
45
49
|
translations
|
46
50
|
end
|
47
51
|
|
48
52
|
def to_text(options = {})
|
53
|
+
# only keep valid options for this method
|
54
|
+
options.delete_if do |key, value|
|
55
|
+
!([:merge].include?(key))
|
56
|
+
end
|
57
|
+
# default options for this method
|
49
58
|
default_options = {:merge => false}
|
50
|
-
options
|
59
|
+
@options.merge!(default_options.merge(options))
|
51
60
|
GetPomo.unique_translations(translations, options[:merge]).map do |translation|
|
52
61
|
comment = translation.comment.to_s.split(/\n|\r\n/).map{|line|"#{line}\n"}*''
|
53
62
|
|
@@ -117,15 +126,14 @@ module GetPomo
|
|
117
126
|
@current_translation.complete?
|
118
127
|
end
|
119
128
|
|
120
|
-
def store_translation
|
121
|
-
if translation_complete? && (parse_obsoletes || !@current_translation.obsolete?)
|
129
|
+
def store_translation
|
130
|
+
if translation_complete? && (@options[:parse_obsoletes] || !@current_translation.obsolete?)
|
122
131
|
@translations += [@current_translation]
|
123
132
|
end
|
124
|
-
|
125
133
|
end
|
126
134
|
|
127
|
-
def start_new_translation
|
128
|
-
store_translation
|
135
|
+
def start_new_translation
|
136
|
+
store_translation if translation_complete?
|
129
137
|
@current_translation = Translation.new
|
130
138
|
end
|
131
139
|
end
|
data/lib/get_pomo/translation.rb
CHANGED
data/lib/get_pomo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_pomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|