get_pomo 0.8.0 → 0.8.1

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: 4a7082c11274ecb41c557230f20679ab1afc2b47
4
- data.tar.gz: 96a578a70bf2e2690624d6b8f630da7237b55dc5
3
+ metadata.gz: 5dfb3605a381f45a3b9e031d2938d9e26bebcc67
4
+ data.tar.gz: 7e6b8818a926db276d8c882a6144861a89767bbe
5
5
  SHA512:
6
- metadata.gz: 435a39400d98fe210781d43bbf80db4a56fbfc7e747e23ba872b107fc6b04c44e60fa6e68c0967a5bf5ebc6d8edb1fcc763230ae09b836da306b5e0d2fd33200
7
- data.tar.gz: cd614be59a4bbfb31a2b487f7c17bbf4721c14e29c7674cbb6a091fe940c986c74394f61b45a39581764088fd0a663988aa62bde84917255d48713c93a556192
6
+ metadata.gz: 045d16e511a1ec0500e8ecabd03a0f9cddf107cba8970465566eef542dfab5784d8975b33659ca95ff1eb0a6e9dd47a0e6c0801b3bfd94d5c957e70f29cf4632
7
+ data.tar.gz: e5fc4ebecfa88511793611818a12702c2f16b5b16c79a96f353bd25e754622c378d6b6f3ac5f528361e1053497bd404df1698cebe6864f0be0a77dac602f09fe
@@ -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
- default_options = {:merge => false}
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 = default_options.merge(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(options[:parse_obsoletes]) #instance_variable has to be overwritten or errors can occur on next add
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 = default_options.merge(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(parse_obsoletes = false)
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(parse_obsoletes = false)
128
- store_translation(parse_obsoletes) if translation_complete?
135
+ def start_new_translation
136
+ store_translation if translation_complete?
129
137
  @current_translation = Translation.new
130
138
  end
131
139
  end
@@ -30,7 +30,7 @@ module GetPomo
30
30
  end
31
31
 
32
32
  def complete?
33
- (not msgid.nil? and not msgstr.nil?) or self.obsolete?
33
+ (not msgid.nil? and not msgstr.nil?) or obsolete?
34
34
  end
35
35
 
36
36
  def fuzzy?
@@ -1,3 +1,3 @@
1
1
  module GetPomo
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
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.0
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-08-18 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it