ad_localize 5.0.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +6 -3
  3. data/.rubocop.yml +5 -0
  4. data/.rubocop_todo.yml +319 -0
  5. data/CHANGELOG.md +31 -0
  6. data/Gemfile +1 -0
  7. data/Gemfile.lock +54 -48
  8. data/README.md +37 -10
  9. data/Rakefile +1 -0
  10. data/ad_localize.gemspec +10 -9
  11. data/bin/console +1 -0
  12. data/exe/ad_localize +2 -1
  13. data/lib/ad_localize/ad_logger.rb +5 -10
  14. data/lib/ad_localize/cli.rb +10 -3
  15. data/lib/ad_localize/entities/key.rb +3 -76
  16. data/lib/ad_localize/entities/locale_wording.rb +32 -52
  17. data/lib/ad_localize/entities/platform.rb +13 -0
  18. data/lib/ad_localize/entities/simple_wording.rb +6 -0
  19. data/lib/ad_localize/entities/wording_type.rb +11 -0
  20. data/lib/ad_localize/interactors/base_generate_files.rb +38 -0
  21. data/lib/ad_localize/interactors/download_spreadsheets.rb +20 -0
  22. data/lib/ad_localize/interactors/export_wording.rb +26 -20
  23. data/lib/ad_localize/interactors/generate_info_plist.rb +24 -0
  24. data/lib/ad_localize/interactors/generate_ios_files.rb +12 -0
  25. data/lib/ad_localize/interactors/generate_json.rb +20 -0
  26. data/lib/ad_localize/interactors/generate_localizable_strings.rb +24 -0
  27. data/lib/ad_localize/interactors/generate_localizable_strings_dict.rb +24 -0
  28. data/lib/ad_localize/interactors/generate_properties.rb +20 -0
  29. data/lib/ad_localize/interactors/generate_strings.rb +25 -0
  30. data/lib/ad_localize/interactors/generate_yaml.rb +20 -0
  31. data/lib/ad_localize/interactors/merge_wordings.rb +49 -18
  32. data/lib/ad_localize/interactors/parse_csv_files.rb +22 -0
  33. data/lib/ad_localize/interactors/process_export_request.rb +21 -0
  34. data/lib/ad_localize/mappers/locale_wording_to_hash.rb +45 -24
  35. data/lib/ad_localize/mappers/options_to_export_request.rb +15 -22
  36. data/lib/ad_localize/option_handler.rb +64 -28
  37. data/lib/ad_localize/parsers/csv_parser.rb +84 -0
  38. data/lib/ad_localize/parsers/key_parser.rb +62 -0
  39. data/lib/ad_localize/repositories/drive_repository.rb +53 -0
  40. data/lib/ad_localize/repositories/file_system_repository.rb +2 -1
  41. data/lib/ad_localize/requests/export_request.rb +103 -57
  42. data/lib/ad_localize/sanitizers/ios_sanitizer.rb +23 -0
  43. data/lib/ad_localize/{mappers/android_translation_mapper.rb → sanitizers/ios_to_android_sanitizer.rb} +8 -8
  44. data/lib/ad_localize/sanitizers/pass_through_sanitizer.rb +10 -0
  45. data/lib/ad_localize/serializers/info_plist_serializer.rb +9 -11
  46. data/lib/ad_localize/serializers/json_serializer.rb +3 -5
  47. data/lib/ad_localize/serializers/localizable_strings_serializer.rb +12 -14
  48. data/lib/ad_localize/serializers/localizable_stringsdict_serializer.rb +15 -24
  49. data/lib/ad_localize/serializers/properties_serializer.rb +9 -11
  50. data/lib/ad_localize/serializers/strings_serializer.rb +12 -21
  51. data/lib/ad_localize/serializers/templated_serializer.rb +55 -0
  52. data/lib/ad_localize/serializers/yaml_serializer.rb +4 -6
  53. data/lib/ad_localize/templates/android/strings.xml.erb +6 -6
  54. data/lib/ad_localize/templates/ios/Localizable.stringsdict.erb +14 -14
  55. data/lib/ad_localize/version.rb +2 -1
  56. data/lib/ad_localize/view_models/compound_wording_view_model.rb +2 -0
  57. data/lib/ad_localize/view_models/simple_wording_view_model.rb +2 -0
  58. data/lib/ad_localize.rb +33 -35
  59. metadata +70 -47
  60. data/lib/ad_localize/constant.rb +0 -6
  61. data/lib/ad_localize/entities/translation.rb +0 -32
  62. data/lib/ad_localize/entities/wording.rb +0 -24
  63. data/lib/ad_localize/interactors/execute_export_request.rb +0 -45
  64. data/lib/ad_localize/interactors/export_csv_files.rb +0 -20
  65. data/lib/ad_localize/interactors/export_g_spreadsheet.rb +0 -64
  66. data/lib/ad_localize/interactors/platforms/export_android_locale_wording.rb +0 -44
  67. data/lib/ad_localize/interactors/platforms/export_csv_locale_wording.rb +0 -22
  68. data/lib/ad_localize/interactors/platforms/export_ios_locale_wording.rb +0 -75
  69. data/lib/ad_localize/interactors/platforms/export_json_locale_wording.rb +0 -27
  70. data/lib/ad_localize/interactors/platforms/export_platform_factory.rb +0 -50
  71. data/lib/ad_localize/interactors/platforms/export_properties_locale_wording.rb +0 -32
  72. data/lib/ad_localize/interactors/platforms/export_yaml_locale_wording.rb +0 -27
  73. data/lib/ad_localize/mappers/csv_path_to_wording.rb +0 -73
  74. data/lib/ad_localize/mappers/ios_translation_mapper.rb +0 -12
  75. data/lib/ad_localize/mappers/translation_group_mapper.rb +0 -14
  76. data/lib/ad_localize/mappers/translation_mapper.rb +0 -30
  77. data/lib/ad_localize/mappers/value_range_to_wording.rb +0 -67
  78. data/lib/ad_localize/repositories/g_sheets_repository.rb +0 -44
  79. data/lib/ad_localize/requests/export_wording_options.rb +0 -24
  80. data/lib/ad_localize/requests/g_spreadsheet_options.rb +0 -47
  81. data/lib/ad_localize/requests/merge_policy.rb +0 -28
  82. data/lib/ad_localize/serializers/with_template.rb +0 -19
  83. data/lib/ad_localize/validators/key_validator.rb +0 -31
  84. data/lib/ad_localize/view_models/translation_group_view_model.rb +0 -19
  85. data/lib/ad_localize/view_models/translation_view_model.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e367d46040937d12da9dabf34045b83a66a3e3a042833f96971c84621f326ff7
4
- data.tar.gz: d6939a29627f1c1681525c5618dd2f68e78132de0d75d3208ad53c8495c346d3
3
+ metadata.gz: b70487e0e8087dbbdb3c6873b025748b9fc97e68ac2abc5c13a0fe71a1a1011c
4
+ data.tar.gz: c82fe7eeb8bc946411c094f51d69df40a35bc9b9e5c5805203a976c4d2aba9c0
5
5
  SHA512:
6
- metadata.gz: d05c3855c3a3b1de045b7f808d8e7e1898ba6f1a65e27cb9cd1788578ae4c448abb6960b450a09c43416b8744c6ec8857b936889111ca10553daf17771b40692
7
- data.tar.gz: c52f9eee3bab2dd91b8786ff6eb848c9da3b3ef3e0a9a3bccf0445783118432be8538ac3a12ef6639831ab920df37b98c7e8cbee0cbdf595a4e475e419a70261
6
+ metadata.gz: 8acdef650f29ede65b72fed96666be542f078337dd6e7b950a8be2ec18b1ff55ee65279dcd5736e5b4d229fed9796b30480cee9b72194ad1bdbba87fa388d81b
7
+ data.tar.gz: cad8b9ba73f3055cb7d000fdda14eb45f59a418d6e563a5d272855ff86000779c221282b07e8f33f07f793ecaec6e9150dc9b889c485e8a1496ee1839a5b9daa
@@ -7,15 +7,18 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby: ['2.7.3', '3.0.1', '3.1.0']
10
+ ruby: ['3.0.6', '3.1.4', '3.2.0']
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
14
  - uses: ruby/setup-ruby@v1
15
15
  with:
16
16
  ruby-version: ${{ matrix.ruby }}
17
- - name: Build and test with Rake
17
+ - name: Build
18
18
  run: |
19
19
  gem install bundler
20
20
  bundle install --jobs 4 --retry 3
21
- bundle exec rake
21
+ - name: Run linter
22
+ run: bundle exec rubocop
23
+ - name: Run tests
24
+ run: bundle exec rake test
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.7
5
+ NewCops: enable
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,319 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2023-02-02 13:39:01 UTC using RuboCop version 1.43.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/OrderedDependencies:
14
+ Exclude:
15
+ - 'ad_localize.gemspec'
16
+
17
+ # Offense count: 1
18
+ # Configuration parameters: Severity, Include.
19
+ # Include: **/*.gemspec
20
+ Gemspec/RequiredRubyVersion:
21
+ Exclude:
22
+ - 'ad_localize.gemspec'
23
+
24
+ # Offense count: 86
25
+ # This cop supports safe autocorrection (--autocorrect).
26
+ Layout/EmptyLineAfterMagicComment:
27
+ Enabled: false
28
+
29
+ # Offense count: 1
30
+ # This cop supports safe autocorrection (--autocorrect).
31
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
32
+ Lint/UnusedBlockArgument:
33
+ Exclude:
34
+ - 'lib/ad_localize/mappers/locale_wording_to_hash.rb'
35
+
36
+ # Offense count: 4
37
+ # This cop supports safe autocorrection (--autocorrect).
38
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
39
+ Lint/UnusedMethodArgument:
40
+ Exclude:
41
+ - 'lib/ad_localize/interactors/base_generate_files.rb'
42
+ - 'lib/ad_localize/serializers/templated_serializer.rb'
43
+
44
+ # Offense count: 6
45
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
46
+ Metrics/AbcSize:
47
+ Max: 35
48
+
49
+ # Offense count: 2
50
+ # Configuration parameters: CountComments, CountAsOne.
51
+ Metrics/ClassLength:
52
+ Max: 139
53
+
54
+ # Offense count: 1
55
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
56
+ Metrics/CyclomaticComplexity:
57
+ Max: 11
58
+
59
+ # Offense count: 11
60
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
61
+ Metrics/MethodLength:
62
+ Max: 40
63
+
64
+ # Offense count: 1
65
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
66
+ Metrics/PerceivedComplexity:
67
+ Max: 11
68
+
69
+ # Offense count: 1
70
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
71
+ # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
72
+ Naming/MethodParameterName:
73
+ Exclude:
74
+ - 'lib/ad_localize/mappers/locale_wording_to_hash.rb'
75
+
76
+ # Offense count: 10
77
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
78
+ # NamePrefix: is_, has_, have_
79
+ # ForbiddenPrefixes: is_, has_, have_
80
+ # AllowedMethods: is_a?
81
+ # MethodDefinitionMacros: define_method, define_singleton_method
82
+ Naming/PredicateName:
83
+ Exclude:
84
+ - 'spec/**/*'
85
+ - 'lib/ad_localize/interactors/base_generate_files.rb'
86
+ - 'lib/ad_localize/interactors/generate_info_plist.rb'
87
+ - 'lib/ad_localize/interactors/generate_json.rb'
88
+ - 'lib/ad_localize/interactors/generate_localizable_strings.rb'
89
+ - 'lib/ad_localize/interactors/generate_localizable_strings_dict.rb'
90
+ - 'lib/ad_localize/interactors/generate_properties.rb'
91
+ - 'lib/ad_localize/interactors/generate_strings.rb'
92
+ - 'lib/ad_localize/interactors/generate_yaml.rb'
93
+ - 'lib/ad_localize/requests/export_request.rb'
94
+
95
+ # Offense count: 28
96
+ # Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
97
+ # SupportedStyles: snake_case, camelCase
98
+ Naming/VariableName:
99
+ Exclude:
100
+ - 'lib/ad_localize/sanitizers/ios_to_android_sanitizer.rb'
101
+
102
+ # Offense count: 1
103
+ # This cop supports safe autocorrection (--autocorrect).
104
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
105
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
106
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
107
+ # FunctionalMethods: let, let!, subject, watch
108
+ # AllowedMethods: lambda, proc, it
109
+ Style/BlockDelimiters:
110
+ Exclude:
111
+ - 'lib/ad_localize/parsers/csv_parser.rb'
112
+
113
+ # Offense count: 2
114
+ # This cop supports safe autocorrection (--autocorrect).
115
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
116
+ # SupportedStyles: assign_to_condition, assign_inside_condition
117
+ Style/ConditionalAssignment:
118
+ Exclude:
119
+ - 'lib/ad_localize/interactors/export_wording.rb'
120
+ - 'lib/ad_localize/sanitizers/ios_to_android_sanitizer.rb'
121
+
122
+ # Offense count: 36
123
+ # Configuration parameters: AllowedConstants.
124
+ Style/Documentation:
125
+ Enabled: false
126
+
127
+ # Offense count: 3
128
+ # This cop supports safe autocorrection (--autocorrect).
129
+ Style/ExpandPathArguments:
130
+ Exclude:
131
+ - 'ad_localize.gemspec'
132
+ - 'test/test_helper.rb'
133
+
134
+ # Offense count: 3
135
+ # This cop supports safe autocorrection (--autocorrect).
136
+ # Configuration parameters: EnforcedStyle.
137
+ # SupportedStyles: format, sprintf, percent
138
+ Style/FormatString:
139
+ Exclude:
140
+ - 'lib/ad_localize/interactors/generate_info_plist.rb'
141
+ - 'lib/ad_localize/interactors/generate_localizable_strings.rb'
142
+ - 'lib/ad_localize/interactors/generate_localizable_strings_dict.rb'
143
+
144
+ # Offense count: 3
145
+ # This cop supports safe autocorrection (--autocorrect).
146
+ # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods.
147
+ # SupportedStyles: annotated, template, unannotated
148
+ Style/FormatStringToken:
149
+ EnforcedStyle: template
150
+
151
+ # Offense count: 1
152
+ # This cop supports unsafe autocorrection (--autocorrect-all).
153
+ Style/GlobalStdStream:
154
+ Exclude:
155
+ - 'lib/ad_localize/ad_logger.rb'
156
+
157
+ # Offense count: 1
158
+ # This cop supports safe autocorrection (--autocorrect).
159
+ # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
160
+ Style/GuardClause:
161
+ Exclude:
162
+ - 'lib/ad_localize/repositories/drive_repository.rb'
163
+
164
+ # Offense count: 57
165
+ # This cop supports safe autocorrection (--autocorrect).
166
+ # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
167
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
168
+ # SupportedShorthandSyntax: always, never, either, consistent
169
+ Style/HashSyntax:
170
+ Enabled: false
171
+
172
+ # Offense count: 4
173
+ # This cop supports unsafe autocorrection (--autocorrect-all).
174
+ Style/LineEndConcatenation:
175
+ Exclude:
176
+ - 'lib/ad_localize/entities/locale_wording.rb'
177
+
178
+ # Offense count: 6
179
+ # This cop supports unsafe autocorrection (--autocorrect-all).
180
+ # Configuration parameters: EnforcedStyle.
181
+ # SupportedStyles: literals, strict
182
+ Style/MutableConstant:
183
+ Exclude:
184
+ - 'lib/ad_localize/entities/platform.rb'
185
+ - 'lib/ad_localize/interactors/merge_wordings.rb'
186
+ - 'lib/ad_localize/option_handler.rb'
187
+ - 'lib/ad_localize/requests/export_request.rb'
188
+ - 'test/test_helper.rb'
189
+
190
+ # Offense count: 1
191
+ # This cop supports safe autocorrection (--autocorrect).
192
+ # Configuration parameters: EnforcedStyle.
193
+ # SupportedStyles: both, prefix, postfix
194
+ Style/NegatedIf:
195
+ Exclude:
196
+ - 'lib/ad_localize/interactors/generate_strings.rb'
197
+
198
+ # Offense count: 3
199
+ # This cop supports unsafe autocorrection (--autocorrect-all).
200
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
201
+ # SupportedStyles: predicate, comparison
202
+ Style/NumericPredicate:
203
+ Exclude:
204
+ - 'spec/**/*'
205
+ - 'test/interactors/process_export_request_test.rb'
206
+ - 'test/repositories/drive_repository_test.rb'
207
+
208
+ # Offense count: 1
209
+ # This cop supports safe autocorrection (--autocorrect).
210
+ # Configuration parameters: AllowedCompactTypes.
211
+ # SupportedStyles: compact, exploded
212
+ Style/RaiseArgs:
213
+ EnforcedStyle: compact
214
+
215
+ # Offense count: 1
216
+ # This cop supports safe autocorrection (--autocorrect).
217
+ Style/RedundantAssignment:
218
+ Exclude:
219
+ - 'lib/ad_localize/parsers/csv_parser.rb'
220
+
221
+ # Offense count: 1
222
+ # This cop supports safe autocorrection (--autocorrect).
223
+ Style/RedundantBegin:
224
+ Exclude:
225
+ - 'lib/ad_localize/repositories/drive_repository.rb'
226
+
227
+ # Offense count: 18
228
+ # This cop supports safe autocorrection (--autocorrect).
229
+ Style/RedundantFreeze:
230
+ Exclude:
231
+ - 'lib/ad_localize/interactors/generate_info_plist.rb'
232
+ - 'lib/ad_localize/interactors/generate_localizable_strings.rb'
233
+ - 'lib/ad_localize/interactors/generate_localizable_strings_dict.rb'
234
+ - 'lib/ad_localize/interactors/generate_strings.rb'
235
+ - 'lib/ad_localize/interactors/merge_wordings.rb'
236
+ - 'lib/ad_localize/parsers/csv_parser.rb'
237
+ - 'lib/ad_localize/parsers/key_parser.rb'
238
+ - 'lib/ad_localize/serializers/info_plist_serializer.rb'
239
+ - 'lib/ad_localize/serializers/localizable_strings_serializer.rb'
240
+ - 'lib/ad_localize/serializers/localizable_stringsdict_serializer.rb'
241
+
242
+ # Offense count: 2
243
+ # This cop supports safe autocorrection (--autocorrect).
244
+ Style/RedundantPercentQ:
245
+ Exclude:
246
+ - 'ad_localize.gemspec'
247
+
248
+ # Offense count: 2
249
+ # This cop supports safe autocorrection (--autocorrect).
250
+ Style/RedundantRegexpEscape:
251
+ Exclude:
252
+ - 'lib/ad_localize/sanitizers/ios_sanitizer.rb'
253
+ - 'lib/ad_localize/sanitizers/ios_to_android_sanitizer.rb'
254
+
255
+ # Offense count: 1
256
+ # This cop supports safe autocorrection (--autocorrect).
257
+ # Configuration parameters: AllowMultipleReturnValues.
258
+ Style/RedundantReturn:
259
+ Exclude:
260
+ - 'lib/ad_localize/option_handler.rb'
261
+
262
+ # Offense count: 2
263
+ # This cop supports safe autocorrection (--autocorrect).
264
+ # Configuration parameters: EnforcedStyle.
265
+ # SupportedStyles: implicit, explicit
266
+ Style/RescueStandardError:
267
+ Exclude:
268
+ - 'lib/ad_localize/repositories/drive_repository.rb'
269
+
270
+ # Offense count: 1
271
+ # This cop supports safe autocorrection (--autocorrect).
272
+ Style/SelfAssignment:
273
+ Exclude:
274
+ - 'lib/ad_localize/sanitizers/ios_to_android_sanitizer.rb'
275
+
276
+ # Offense count: 3
277
+ # This cop supports unsafe autocorrection (--autocorrect-all).
278
+ Style/SlicingWithRange:
279
+ Exclude:
280
+ - 'lib/ad_localize/interactors/merge_wordings.rb'
281
+ - 'lib/ad_localize/mappers/locale_wording_to_hash.rb'
282
+ - 'lib/ad_localize/parsers/csv_parser.rb'
283
+
284
+ # Offense count: 3
285
+ # This cop supports unsafe autocorrection (--autocorrect-all).
286
+ # Configuration parameters: Mode.
287
+ Style/StringConcatenation:
288
+ Exclude:
289
+ - 'lib/ad_localize/serializers/properties_serializer.rb'
290
+ - 'lib/ad_localize/serializers/strings_serializer.rb'
291
+ - 'lib/ad_localize/serializers/templated_serializer.rb'
292
+
293
+ # Offense count: 85
294
+ # This cop supports safe autocorrection (--autocorrect).
295
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
296
+ # SupportedStyles: single_quotes, double_quotes
297
+ Style/StringLiterals:
298
+ Enabled: false
299
+
300
+ # Offense count: 3
301
+ # This cop supports safe autocorrection (--autocorrect).
302
+ Style/SymbolLiteral:
303
+ Exclude:
304
+ - 'lib/ad_localize/mappers/options_to_export_request.rb'
305
+ - 'test/option_handler_test.rb'
306
+
307
+ # Offense count: 3
308
+ # This cop supports unsafe autocorrection (--autocorrect-all).
309
+ Style/ZeroLengthPredicate:
310
+ Exclude:
311
+ - 'lib/ad_localize/mappers/locale_wording_to_hash.rb'
312
+ - 'test/repositories/drive_repository_test.rb'
313
+
314
+ # Offense count: 10
315
+ # This cop supports safe autocorrection (--autocorrect).
316
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
317
+ # URISchemes: http, https
318
+ Layout/LineLength:
319
+ Max: 153
data/CHANGELOG.md CHANGED
@@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 6.1.0
11
+ ### Added
12
+
13
+ - new option (iOS only) `--auto-escape-percent` that escapes % character in wording. This option should be used if the wording is intended to be used with `String(format:)`.
14
+
15
+ ## 6.0.0
16
+ ### Added
17
+
18
+ - Remove extra spaces before and after key/translation contents
19
+ - skip lines starting with a `#` character
20
+ - new option `-l` or `--locales` to export only a subset or locales
21
+ - Separate csv parse responsibility between key parser and csv parser
22
+ - use Rubocop to detect coding style offenses (also in github workflow)
23
+ - print warning log when a value is replaced during merge
24
+
25
+ ### Changed
26
+
27
+ - parse csv in 2 steps : first analyze keys and keep them in a map, second add translations to keys
28
+ - do not store empty values during parse if `-x` option is active
29
+ - handle duplicate keys while parsing csv instead of while exporting for a platform
30
+ - BREAKING CHANGE : the way to provide service account information is no longer to set GCLOUD_CLIENT_SECRET with the content of the service account configuration. Now you need to provide the path to the configuration using the environment variable GOOGLE_APPLICATION_CREDENTIALS
31
+ - we no longer access to spreadsheet cells using GSheet v4. Now we downloaded all the relevant sheets and then we parse file contents like normal csv files. We use the exponentiel retry feature provided by google with a maximum of 3 attempts [more info here](https://github.com/googleapis/google-api-ruby-client/blob/377edf2ca4c1ef41a91de4176e5c7ad7df220007/google-apis-core/lib/google/apis/options.rb#L70). We noticed we had download error for 6 or more sheets in a spreadsheet.
32
+ - locale wording stores separately each type of wording. This allows to export each wording type concurrently if you want to
33
+ - no more plaform interactor. It has been replaced with generated file interactors. We still have an ios interactor because there are multiple files to export.
34
+ - All templated serializers now share a common parent : `TemplatedSerializer`
35
+ - Isolate the process to ensure a translation is correctly formatted for a platform in a new class type `sanitizers`. They can be tested separately.
36
+
37
+ ### Removed
38
+
39
+ - no more GSpreadsheetOptions. It is handled directly in request
40
+
10
41
  ## [5.0.0] - 2022-07-26
11
42
 
12
43
  ### Added
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source "https://rubygems.org"
2
3
 
3
4
  # Specify your gem's dependencies in ad_localize.gemspec
data/Gemfile.lock CHANGED
@@ -1,53 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ad_localize (5.0.0)
4
+ ad_localize (6.1.0)
5
5
  activesupport (>= 6.1.3.2, < 8.0)
6
6
  colorize (~> 0.8)
7
+ google-apis-drive_v3 (~> 0.33.0)
7
8
  google-apis-sheets_v4 (~> 0.9)
8
- googleauth (~> 0.12)
9
- nokogiri (~> 1.10)
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
13
12
  specs:
14
- activesupport (7.0.3.1)
13
+ activesupport (7.0.4)
15
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
15
  i18n (>= 1.6, < 2)
17
16
  minitest (>= 5.1)
18
17
  tzinfo (~> 2.0)
19
- addressable (2.8.0)
20
- public_suffix (>= 2.0.2, < 5.0)
18
+ addressable (2.8.1)
19
+ public_suffix (>= 2.0.2, < 6.0)
21
20
  ansi (1.5.0)
21
+ ast (2.4.2)
22
22
  builder (3.2.4)
23
23
  colorize (0.8.1)
24
24
  concurrent-ruby (1.1.10)
25
+ debug (1.7.1)
26
+ irb (>= 1.5.0)
27
+ reline (>= 0.3.1)
25
28
  declarative (0.0.20)
26
29
  diffy (3.4.2)
27
- faraday (1.10.0)
28
- faraday-em_http (~> 1.0)
29
- faraday-em_synchrony (~> 1.0)
30
- faraday-excon (~> 1.1)
31
- faraday-httpclient (~> 1.0)
32
- faraday-multipart (~> 1.0)
33
- faraday-net_http (~> 1.0)
34
- faraday-net_http_persistent (~> 1.0)
35
- faraday-patron (~> 1.0)
36
- faraday-rack (~> 1.0)
37
- faraday-retry (~> 1.0)
30
+ faraday (2.7.2)
31
+ faraday-net_http (>= 2.0, < 3.1)
38
32
  ruby2_keywords (>= 0.0.4)
39
- faraday-em_http (1.0.0)
40
- faraday-em_synchrony (1.0.0)
41
- faraday-excon (1.1.0)
42
- faraday-httpclient (1.0.1)
43
- faraday-multipart (1.0.4)
44
- multipart-post (~> 2)
45
- faraday-net_http (1.0.1)
46
- faraday-net_http_persistent (1.2.0)
47
- faraday-patron (1.0.0)
48
- faraday-rack (1.0.0)
49
- faraday-retry (1.0.3)
50
- google-apis-core (0.7.0)
33
+ faraday-net_http (3.0.2)
34
+ google-apis-core (0.9.4)
51
35
  addressable (~> 2.5, >= 2.5.1)
52
36
  googleauth (>= 0.16.2, < 2.a)
53
37
  httpclient (>= 2.8.1, < 3.a)
@@ -56,44 +40,63 @@ GEM
56
40
  retriable (>= 2.0, < 4.a)
57
41
  rexml
58
42
  webrick
59
- google-apis-sheets_v4 (0.17.0)
60
- google-apis-core (>= 0.7, < 2.a)
61
- googleauth (0.17.1)
62
- faraday (>= 0.17.3, < 2.0)
43
+ google-apis-drive_v3 (0.33.0)
44
+ google-apis-core (>= 0.9.1, < 2.a)
45
+ google-apis-sheets_v4 (0.21.0)
46
+ google-apis-core (>= 0.9.1, < 2.a)
47
+ googleauth (1.3.0)
48
+ faraday (>= 0.17.3, < 3.a)
63
49
  jwt (>= 1.4, < 3.0)
64
50
  memoist (~> 0.16)
65
51
  multi_json (~> 1.11)
66
52
  os (>= 0.9, < 2.0)
67
- signet (~> 0.15)
53
+ signet (>= 0.16, < 2.a)
68
54
  httpclient (2.8.3)
69
55
  i18n (1.12.0)
70
56
  concurrent-ruby (~> 1.0)
71
- jwt (2.4.1)
57
+ io-console (0.6.0)
58
+ irb (1.6.2)
59
+ reline (>= 0.3.0)
60
+ json (2.6.3)
61
+ jwt (2.6.0)
72
62
  memoist (0.16.2)
73
63
  mini_mime (1.1.2)
74
- mini_portile2 (2.8.0)
75
- minitest (5.14.4)
76
- minitest-reporters (1.4.2)
64
+ minitest (5.17.0)
65
+ minitest-reporters (1.5.0)
77
66
  ansi
78
67
  builder
79
68
  minitest (>= 5.0)
80
69
  ruby-progressbar
81
70
  multi_json (1.15.0)
82
- multipart-post (2.2.3)
83
- nokogiri (1.13.8)
84
- mini_portile2 (~> 2.8.0)
85
- racc (~> 1.4)
86
71
  os (1.1.4)
87
- public_suffix (4.0.7)
88
- racc (1.6.0)
89
- rake (12.3.3)
72
+ parallel (1.22.1)
73
+ parser (3.2.0.0)
74
+ ast (~> 2.4.1)
75
+ public_suffix (5.0.1)
76
+ rainbow (3.1.1)
77
+ rake (13.0.6)
78
+ regexp_parser (2.6.1)
79
+ reline (0.3.2)
80
+ io-console (~> 0.5)
90
81
  representable (3.2.0)
91
82
  declarative (< 0.1.0)
92
83
  trailblazer-option (>= 0.1.1, < 0.2.0)
93
84
  uber (< 0.2.0)
94
85
  retriable (3.1.2)
95
86
  rexml (3.2.5)
96
- ruby-progressbar (1.10.1)
87
+ rubocop (1.43.0)
88
+ json (~> 2.3)
89
+ parallel (~> 1.10)
90
+ parser (>= 3.2.0.0)
91
+ rainbow (>= 2.2.2, < 4.0)
92
+ regexp_parser (>= 1.8, < 3.0)
93
+ rexml (>= 3.2.5, < 4.0)
94
+ rubocop-ast (>= 1.24.1, < 2.0)
95
+ ruby-progressbar (~> 1.7)
96
+ unicode-display_width (>= 2.4.0, < 3.0)
97
+ rubocop-ast (1.24.1)
98
+ parser (>= 3.1.1.0)
99
+ ruby-progressbar (1.11.0)
97
100
  ruby2_keywords (0.0.5)
98
101
  signet (0.17.0)
99
102
  addressable (~> 2.8)
@@ -104,18 +107,21 @@ GEM
104
107
  tzinfo (2.0.5)
105
108
  concurrent-ruby (~> 1.0)
106
109
  uber (0.1.0)
110
+ unicode-display_width (2.4.2)
107
111
  webrick (1.7.0)
108
112
 
109
113
  PLATFORMS
110
- ruby
114
+ arm64-darwin-21
111
115
 
112
116
  DEPENDENCIES
113
117
  ad_localize!
114
118
  bundler (>= 1.12.0, < 3.0.0)
119
+ debug (>= 1.0.0, < 2.0)
115
120
  diffy (~> 3.3)
116
121
  minitest (~> 5.11)
117
122
  minitest-reporters (~> 1.3)
118
123
  rake (>= 12.3.0, < 14.0.0)
124
+ rubocop (~> 1.0)
119
125
 
120
126
  BUNDLED WITH
121
- 2.2.26
127
+ 2.4.3
data/README.md CHANGED
@@ -4,6 +4,11 @@ The purpose of this gem is to automatically generate wording files from a CSV in
4
4
  It supports iOS, Android, JSON, YAML and Java Properties.
5
5
  It is a useful tool when working on a mobile application or a SPA.
6
6
 
7
+ ## Migration from 5.x to 6.0.0
8
+
9
+ When using the CLI replace `GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secret.json>)` with `GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secret.json>`
10
+ When using the interactor refer to [ruby program usage section](###In-a-Ruby-program)
11
+
7
12
  ## Installation
8
13
 
9
14
  Add this line to your application's Gemfile:
@@ -43,12 +48,12 @@ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
43
48
 
44
49
  * Export wording from a private google spreadsheet. It requires a [Google Cloud Service Account](#using-a-google-cloud-service-account).
45
50
  ```
46
- $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secret.json>) ad_localize -k <your-spreadsheet-drive-key>
51
+ $ GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secret.json> ad_localize -k <your-spreadsheet-drive-key>
47
52
  ```
48
53
 
49
54
  * Export wording from all sheets in a google spreadsheet. It requires a [Google Cloud Service Account](#using-a-google-cloud-service-account).
50
55
  ```
51
- $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secret.json>) ad_localize -k <your-spreadsheet-drive-key> -e
56
+ $ GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secret.json> ad_localize -k <your-spreadsheet-drive-key> -e
52
57
  ```
53
58
 
54
59
  * Only generate wording files for the specified platforms
@@ -71,6 +76,16 @@ $ ad_localize -d
71
76
  $ ad_localize -x
72
77
  ```
73
78
 
79
+ * Will escape % character present in wordings (iOS feature only), this is useful when using the wording through String(format:)
80
+ ```
81
+ $ ad_localize --auto-escape-percent
82
+ ```
83
+
84
+ * Only generate wording files for the specified locales
85
+ ```
86
+ $ ad_localize -l fr,en
87
+ ```
88
+
74
89
  ### In a Ruby program
75
90
  There are many possibilities when using AdLocalize in a ruby program. You can add support to your own wording format, support other platforms, select which locales you want to export, generate wording file content without writing on the disk and many more.
76
91
 
@@ -79,12 +94,22 @@ If you want more examples, please open a documentation issue.
79
94
 
80
95
  ```Ruby
81
96
  require 'ad_localize'
82
- # create optional google spreasheet options
83
- g_spreadsheet_options = AdLocalize::Requests::GSpreadsheetOptions.new(spreadsheet_id: 'some_id', sheet_ids: ['first', 'second'], service_account_config: ENV['GCLOUD_CLIENT_SECRET'])
84
97
  # create export request
85
- export_request = AdLocalize::Requests::ExportRequest.new(g_spreadsheet_options: g_spreadsheet_options, verbose: true)
86
- # execute request
87
- AdLocalize::Interactors::ExecuteExportRequest.new.call(export_request: export_request)
98
+ export_request = Requests::ExportRequest.new
99
+ export_request.spreadsheet_id = 'some_id'
100
+ export_request.sheet_ids = %w[first second]
101
+ export_request.verbose = true
102
+ begin
103
+ # download files - be sure that GOOGLE_APPLICATION_CREDENTIALS is set if you use service account
104
+ export_request.downloaded_csvs = DownloadSpreadsheets.new.call(export_request: export_request)
105
+ # execute request
106
+ AdLocalize::Interactors::ExecuteExportRequest.new.call(export_request: export_request)
107
+ ensure
108
+ export_request.downloaded_csvs.each do |file|
109
+ file.close
110
+ file.unlink
111
+ end
112
+ end
88
113
  ```
89
114
 
90
115
  ## Accessing a google spreadsheet
@@ -106,12 +131,12 @@ To use a private google spreasheet you need to use a Google Cloud Service Accoun
106
131
  - In *IAM & Admin / Service Account*, the service account's email is listed. Invite it to the spreadsheet to export.
107
132
 
108
133
  ```
109
- $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>) ad_localize -k # one way
110
- $ GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>) ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list> # another way
134
+ $ GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secrets> ad_localize -k # one way
135
+ $ GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secrets> ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list> # another way
111
136
  ```
112
137
 
113
138
  ```
114
- $ export GCLOUD_CLIENT_SECRET=$(cat <path-to-client-secrets>)
139
+ $ export GOOGLE_APPLICATION_CREDENTIALS=<path-to-client-secrets>
115
140
  $ ad_localize -k <your-spreadsheet-drive-key> # one way
116
141
  $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list> # another way
117
142
  ```
@@ -121,6 +146,7 @@ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
121
146
 
122
147
  | key | fr | en |
123
148
  | --- | --- | --- |
149
+ | # General | | |
124
150
  | agenda | agenda | events |
125
151
  | favorites | Mes favoris | My favorites |
126
152
  | from_to | du %1$@ au %2$@ | from %1$@ to %2$@ |
@@ -129,6 +155,7 @@ $ ad_localize -k <your-spreadsheet-drive-key> -s <comma-separated-sheet-id-list>
129
155
  - Keys should contain only letter, number, underscore and dot : [a-z0-9_.]+.
130
156
  - Format specifiers must be numeroted if there are more than one in a translation string (eg: `"%1$@ %2$@'s report"`).
131
157
  - _Only for Android_ keys without translation won't be considered
158
+ - Lines starting with a comment will be ignored
132
159
 
133
160
  ### Comments
134
161
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/gem_tasks"
2
3
  require "rake/testtask"
3
4