phraseapp_updater 3.0.1 → 3.2.0

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
  SHA256:
3
- metadata.gz: b6c463406d92e91f0b311686a594ca4999fe4c5ff70bae5bb1273aee24f67bb7
4
- data.tar.gz: 63b4f385a02dfb4ff71c286dc009e7d5414660b40bd75c3cc983cc931084ee9e
3
+ metadata.gz: 5e8639a81e55d83a36d03854f2c970737ee9754266e629ef2bad1d9e65c53826
4
+ data.tar.gz: '078928d80c10deb59f9a293fbd7135a2d9b4b52479809985b5c4cf9835332131'
5
5
  SHA512:
6
- metadata.gz: 9d1565057faaf557dcf42a17051898a3d13fac378bbb539255bfa967dcc79fe524087b861b7f9ce849f8feee9ed3b8b093f6e052dbf089eb7f648a243be868eb
7
- data.tar.gz: 11095d3c165dd9aac8146de4fffb57a61422904970547ba334597deeef269522ab1479e1422a0d2e0ae60ee97a8df608c1cfbb3268d3f8b1f44d806bcb77a8d6
6
+ metadata.gz: 1e2927b0dc2e87ba9ec5c64c8d0393a58624ce7e754183d556e1e165bb51fed61e0cac138a8e9bb9b46e2f97b74628ff75e2d24190fad30a68a1124d1425dee9
7
+ data.tar.gz: 23f2339b569cbe5f6237d1f23c89259153ac80c79830a02861ec740c5c077384a8794aadad4d462fca4d95e46c04e4b145aff09f1bf5d1bc89c1b8f44e38f805
@@ -14,6 +14,7 @@ class PhraseAppUpdaterCLI < Thor
14
14
  method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
15
15
  method_option :phraseapp_project_name, type: :string, required: true, desc: 'Name for new PhraseApp project.'
16
16
  method_option :parent_commit, type: :string, required: true, desc: 'git commit hash of initial locales'
17
+ method_option :remove_orphans, type: :boolean, default: true, desc: 'Remove keys not in the uploaded default locale'
17
18
 
18
19
  def setup(locales_path)
19
20
  validate_readable_path!('locales', locales_path)
@@ -26,7 +27,7 @@ class PhraseAppUpdaterCLI < Thor
26
27
  options[:parent_commit],
27
28
  verbose: options[:verbose])
28
29
 
29
- updater.upload_directory(locales_path)
30
+ updater.upload_directory(locales_path, remove_orphans: options[:remove_orphans])
30
31
 
31
32
  puts project_id
32
33
  end
@@ -104,6 +105,7 @@ class PhraseAppUpdaterCLI < Thor
104
105
  method_option :phraseapp_api_key, type: :string, required: true, desc: 'PhraseApp API key.'
105
106
  method_option :phraseapp_project_id, type: :string, required: true, desc: 'PhraseApp project ID.'
106
107
  method_option :parent_commit, type: :string, required: true, desc: 'git commit hash of locales being uploaded'
108
+ method_option :remove_orphans, type: :boolean, default: true, desc: 'Remove keys not in the uploaded default locale'
107
109
 
108
110
  def upload(source_path)
109
111
  validate_readable_path!('source path', source_path)
@@ -115,7 +117,7 @@ class PhraseAppUpdaterCLI < Thor
115
117
  options[:file_format],
116
118
  verbose: options[:verbose])
117
119
 
118
- updater.upload_directory(source_path)
120
+ updater.upload_directory(source_path, remove_orphans: options[:remove_orphans])
119
121
  updater.update_parent_commit(options[:parent_commit])
120
122
  end
121
123
  end
@@ -162,6 +164,23 @@ class PhraseAppUpdaterCLI < Thor
162
164
  end
163
165
  end
164
166
 
167
+ desc 'normalize <source_path> <destination_path>',
168
+ 'Normalize the locale directory at <source_path> into <destination_path>.'
169
+
170
+ long_desc <<-LONGDESC
171
+ Read, normalize, then write out the locales in <source_path> into <destination_path>.
172
+ LONGDESC
173
+
174
+ def normalize(source_path, destination_path)
175
+ validate_readable_path!('source_path', source_path)
176
+ validate_writable_path!('destination_path', destination_path)
177
+
178
+ handle_errors do
179
+ updater = PhraseAppUpdater.new(nil, nil, options[:file_format], verbose: options[:verbose])
180
+ updater.normalize_directory(source_path, destination_path)
181
+ end
182
+ end
183
+
165
184
  desc 'merge <ancestor_path> <our_path> <their_path>',
166
185
  '3-way merge locale file directories <ancestor_path>, <our_path>, <their_path> into TO.'
167
186
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'multi_json'
4
3
  require 'oj'
5
4
 
6
5
  # We're working with pure JSON, not
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PhraseAppUpdater
4
- VERSION = '3.0.1'
4
+ VERSION = '3.2.0'
5
5
  end
@@ -52,9 +52,9 @@ class PhraseAppUpdater
52
52
  write_locale_file(result, result_file)
53
53
  end
54
54
 
55
- def upload_directory(path)
55
+ def upload_directory(path, remove_orphans: true)
56
56
  locales = load_locale_directory(path)
57
- upload_locale_files(locales)
57
+ upload_locale_files(locales, remove_orphans: remove_orphans)
58
58
  end
59
59
 
60
60
  def download_to_directory(path)
@@ -62,6 +62,11 @@ class PhraseAppUpdater
62
62
  write_locale_directory(path, locale_files)
63
63
  end
64
64
 
65
+ def normalize_directory(source, destination)
66
+ locales = load_locale_directory(source)
67
+ write_locale_directory(destination, locales)
68
+ end
69
+
65
70
  def update_parent_commit(parent_commit)
66
71
  @phraseapp_api.update_parent_commit(parent_commit)
67
72
  end
@@ -98,7 +103,7 @@ class PhraseAppUpdater
98
103
  end
99
104
  end
100
105
 
101
- def upload_locale_files(locale_files)
106
+ def upload_locale_files(locale_files, remove_orphans: true)
102
107
  # We assert that the default locale contains all legitimate strings, and so
103
108
  # we clean up orphaned content on PhraseApp post-upload by removing keys not
104
109
  # in the default locale.
@@ -109,8 +114,10 @@ class PhraseAppUpdater
109
114
  upload_ids = @phraseapp_api.upload_files(locale_files, default_locale: @default_locale)
110
115
  default_upload_id = upload_ids.fetch(@default_locale)
111
116
 
112
- STDERR.puts "Removing keys not in default locale '#{@default_locale}' upload '#{default_upload_id}'"
113
- @phraseapp_api.remove_keys_not_in_upload(default_upload_id)
117
+ if remove_orphans
118
+ STDERR.puts "Removing keys not in default locale '#{@default_locale}' upload '#{default_upload_id}'"
119
+ @phraseapp_api.remove_keys_not_in_upload(default_upload_id)
120
+ end
114
121
  end
115
122
 
116
123
  def download_locale_files
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phraseapp_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iKnow Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-24 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.19'
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.19'
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: phrase
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.8.3
33
+ version: 2.20.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.8.3
40
+ version: 2.20.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashdiff
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,62 +52,48 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.1
55
- - !ruby/object:Gem::Dependency
56
- name: multi_json
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.12'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.12'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: oj
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '2.18'
61
+ version: '3.16'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '2.18'
68
+ version: '3.16'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: deep_merge
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '1.1'
75
+ version: '1.2'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '1.1'
82
+ version: '1.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: parallel
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '1.12'
89
+ version: '1.23'
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '1.12'
96
+ version: '1.23'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: bundler
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,42 +114,42 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '10.0'
117
+ version: '13.1'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '10.0'
124
+ version: '13.1'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: rspec
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '3.0'
131
+ version: '3.12'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '3.0'
138
+ version: '3.12'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: pry
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '0.10'
145
+ version: '0.14'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '0.10'
152
+ version: '0.14'
167
153
  description: A tool for merging data on PhraseApp with local changes (usually two
168
154
  git revisions)
169
155
  email:
@@ -207,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
193
  - !ruby/object:Gem::Version
208
194
  version: '0'
209
195
  requirements: []
210
- rubygems_version: 3.1.6
196
+ rubygems_version: 3.3.26
211
197
  signing_key:
212
198
  specification_version: 4
213
199
  summary: A three-way differ for PhraseApp projects.