babelyoda 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module Babelyoda
19
19
  end
20
20
  Dir.glob(File.join(dir, '*.strings')).each do |strings_file|
21
21
  strings = Babelyoda::Strings.new(strings_file, language).read!
22
- strings.name = File.join('Resources', File.basename(strings.name))
22
+ strings.name = File.basename(strings.name)
23
23
  keysets[strings.name] ||= Keyset.new(strings.name)
24
24
  keysets[strings.name].merge!(strings)
25
25
  end
@@ -111,7 +111,7 @@ module Babelyoda
111
111
  attr_accessor :token
112
112
  attr_accessor :project_id
113
113
 
114
- def replace(keyset, language = nil)
114
+ def replace(keyset, language = :en)
115
115
  validate_keyset_name!(keyset.name)
116
116
  doc = project_xml do |xml|
117
117
  keyset.to_xml(xml, language)
@@ -120,11 +120,9 @@ module Babelyoda
120
120
  :file => StringIO.new(doc),
121
121
  'project-id' => project_id,
122
122
  'keyset-id' => keyset.name,
123
- # TODO: REMOVE ME when Tanker is fixed.
124
- 'language' => :en,
123
+ 'language' => language,
125
124
  :format => 'xml'
126
125
  }
127
- payload.merge!({:language => language}) if language
128
126
  post('/keysets/replace/', payload)
129
127
  end
130
128
 
@@ -214,7 +212,7 @@ module Babelyoda
214
212
  req['AUTHORIZATION'] = token
215
213
  req.content_type = multipart_content_type
216
214
  req.body = multipart_data(payload)
217
-
215
+
218
216
  debug_log = ''
219
217
  conn = Net::HTTP.new(uri.host, uri.port)
220
218
  conn.set_debug_output(debug_log)
@@ -223,6 +221,10 @@ module Babelyoda
223
221
  end
224
222
  $logger.debug "HTTP DEBUG: #{debug_log}"
225
223
 
224
+ $logger.debug "=== POST DATA ==========================================="
225
+ $logger.debug req.body
226
+ $logger.debug "=== / POST DATA ========================================="
227
+
226
228
  case res
227
229
  when Net::HTTPSuccess, Net::HTTPRedirection
228
230
  Nokogiri::XML.parse(res.body)
@@ -1,3 +1,3 @@
1
1
  module Babelyoda
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
data/lib/babelyoda.rb CHANGED
@@ -37,7 +37,8 @@ namespace :babelyoda do
37
37
  $logger.info "Extracting strings from sources..."
38
38
  dev_lang = spec.development_language
39
39
  Babelyoda::Genstrings.run(spec.source_files, dev_lang) do |keyset|
40
- old_strings_filename = strings_filename(keyset.name, dev_lang)
40
+ keyset_name = File.join(spec.resources_folder, keyset.name)
41
+ old_strings_filename = strings_filename(keyset_name, dev_lang)
41
42
  old_strings = Babelyoda::Strings.new(old_strings_filename, dev_lang).read
42
43
  old_strings.merge!(keyset)
43
44
  old_strings.save!
@@ -151,17 +152,37 @@ namespace :babelyoda do
151
152
  end
152
153
  end
153
154
 
154
- desc "Pushes resources to the translators"
155
+ desc "Pushes resources to the translators. Use LANGS to specify languages to push. Defaults to '#{spec.development_language}'."
155
156
  task :push => [:drop_orphan_keysets, :drop_orphan_keys] do
156
- $logger.info "Pushing local keys to the remote..."
157
+ langs = [ spec.development_language ]
158
+ if ENV['LANGS']
159
+ if ENV['LANGS'] == '*'
160
+ langs = spec.all_languages
161
+ else
162
+ langs = ENV['LANGS'].split(',').map { |s| s.to_sym }
163
+ end
164
+ end
165
+ $logger.info "Pushing local keys for '#{langs.join(', ')}' to the remote..."
157
166
  spec.strings_files.each do |filename|
158
- strings = Babelyoda::Strings.new(filename, spec.development_language).read!
159
- $logger.debug "Processing keyset: #{strings.name}"
160
- remote_keyset = spec.engine.load_keyset(strings.name, nil, :unapproved)
161
- result = remote_keyset.merge!(strings, preserve: true)
167
+ local_keyset = nil
168
+
169
+ langs.each do |lang|
170
+ unless local_keyset
171
+ local_keyset = Babelyoda::Strings.new(filename, lang).read!
172
+ $logger.debug "Processing keyset: #{local_keyset.name}"
173
+ else
174
+ strings = Babelyoda::Strings.new(strings_filename(local_keyset.name, lang), lang).read!
175
+ local_keyset.merge!(strings, preserve: true)
176
+ end
177
+ end
178
+
179
+ remote_keyset = spec.engine.load_keyset(local_keyset.name, nil, :unapproved)
180
+ result = remote_keyset.merge!(local_keyset, preserve: true)
162
181
  remote_keyset.ensure_languages!(spec.all_languages)
163
182
  if result[:new] > 0 || result[:updated] > 0
164
- spec.engine.replace(remote_keyset)
183
+ langs.each do |lang|
184
+ spec.engine.replace(remote_keyset, lang)
185
+ end
165
186
  $logger.debug "New keys: #{result[:new]} Updated keys: #{result[:updated]}"
166
187
  end
167
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babelyoda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-20 00:00:00.000000000Z
12
+ date: 2012-02-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70356031935100 !ruby/object:Gem::Requirement
16
+ requirement: &70329428735300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70356031935100
24
+ version_requirements: *70329428735300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard
27
- requirement: &70356031934680 !ruby/object:Gem::Requirement
27
+ requirement: &70329428734720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70356031934680
35
+ version_requirements: *70329428734720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &70356031934180 !ruby/object:Gem::Requirement
38
+ requirement: &70329428734060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70356031934180
46
+ version_requirements: *70329428734060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ruby_gntp
49
- requirement: &70356031933720 !ruby/object:Gem::Requirement
49
+ requirement: &70329428733340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70356031933720
57
+ version_requirements: *70329428733340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: awesome_print
60
- requirement: &70356031933120 !ruby/object:Gem::Requirement
60
+ requirement: &70329428732520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 1.0.2
69
69
  type: :runtime
70
70
  prerelease: false
71
- version_requirements: *70356031933120
71
+ version_requirements: *70329428732520
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rake
74
- requirement: &70356031932240 !ruby/object:Gem::Requirement
74
+ requirement: &70329428731600 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ~>
@@ -82,10 +82,10 @@ dependencies:
82
82
  version: 0.9.2.2
83
83
  type: :runtime
84
84
  prerelease: false
85
- version_requirements: *70356031932240
85
+ version_requirements: *70329428731600
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: active_support
88
- requirement: &70356031931420 !ruby/object:Gem::Requirement
88
+ requirement: &70329428730800 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ~>
@@ -96,10 +96,10 @@ dependencies:
96
96
  version: 3.0.0
97
97
  type: :runtime
98
98
  prerelease: false
99
- version_requirements: *70356031931420
99
+ version_requirements: *70329428730800
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: rchardet19
102
- requirement: &70356031819460 !ruby/object:Gem::Requirement
102
+ requirement: &70329428730020 !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements:
105
105
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 1.3.5
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *70356031819460
113
+ version_requirements: *70329428730020
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: builder
116
- requirement: &70356031818600 !ruby/object:Gem::Requirement
116
+ requirement: &70329428729260 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -124,10 +124,10 @@ dependencies:
124
124
  version: 3.0.0
125
125
  type: :runtime
126
126
  prerelease: false
127
- version_requirements: *70356031818600
127
+ version_requirements: *70329428729260
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: nokogiri
130
- requirement: &70356031817800 !ruby/object:Gem::Requirement
130
+ requirement: &70329428728520 !ruby/object:Gem::Requirement
131
131
  none: false
132
132
  requirements:
133
133
  - - ~>
@@ -138,10 +138,10 @@ dependencies:
138
138
  version: 1.5.0
139
139
  type: :runtime
140
140
  prerelease: false
141
- version_requirements: *70356031817800
141
+ version_requirements: *70329428728520
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: term-ansicolor
144
- requirement: &70356031816880 !ruby/object:Gem::Requirement
144
+ requirement: &70329428727780 !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
147
147
  - - ~>
@@ -152,10 +152,10 @@ dependencies:
152
152
  version: 1.0.7
153
153
  type: :runtime
154
154
  prerelease: false
155
- version_requirements: *70356031816880
155
+ version_requirements: *70329428727780
156
156
  - !ruby/object:Gem::Dependency
157
157
  name: log4r-color
158
- requirement: &70356031815780 !ruby/object:Gem::Requirement
158
+ requirement: &70329428727060 !ruby/object:Gem::Requirement
159
159
  none: false
160
160
  requirements:
161
161
  - - ~>
@@ -163,7 +163,7 @@ dependencies:
163
163
  version: '1.2'
164
164
  type: :runtime
165
165
  prerelease: false
166
- version_requirements: *70356031815780
166
+ version_requirements: *70329428727060
167
167
  description: A simple utility to push/pull l10n resources of an Xcode project to/from
168
168
  the translators
169
169
  email: