web_translate_it 2.6.2 → 2.6.3.pre1

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: 8816da80bd99107be31a26af0c6853b28e46018df5d114c4114ed9b109eada9b
4
- data.tar.gz: 1ed5126b65809c231cdee660d53ec00f004a6b6c9e08d2676fd2b0c7e4d64319
3
+ metadata.gz: 173ab262e04fc47e5c64636a93414ca39f69ee400950a57fb6df13f0df2cd9e2
4
+ data.tar.gz: d0e5e1acc433b7fd4b42c685b55d9df142fe93e1f09e99ca86c3f1f4f722e52e
5
5
  SHA512:
6
- metadata.gz: 9d121c3b05ef8eafb848fb6719c40c252ea257beeca42d72571e9eb651aa6b0c9f1cc3a6fadacda102ad4746798efc4bc8802c0547ee746d77cb281237f79849
7
- data.tar.gz: ab9f038f9cc74746c6c4f844c8142472fb808824274835ac37f5291ce724af68bd477421fecfaad771efab88524334cbce98e9659f0194a9aa4632e961724d21
6
+ metadata.gz: 5460467df6c3b1276fe83c9c7d60f80810c4f91211251babd3d1fd7d37e9619b2793d39063cccb9731267074d52197f2c5dc2288c95f9d9ac03d90930a80a5f1
7
+ data.tar.gz: 390ff085d8d5ede3e6d146c9f5b7620aa62b8d1502a4d97410f42a9b7fe4f0ccaf643b5c633b110546a666716f0fae41d238b65400ee9aae78babbdca73db109
data/history.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Version 2.6.3.pre1 / 2022-06-14
2
+
3
+ * Fix deprecation warning. #181
4
+ * Set minimum ruby version to 2.6. It is [EOL since December 2018](https://endoflife.date/ruby), but it’s still the default ruby shipped with Mac OS Monterey.
5
+
1
6
  ## Version 2.6.2 / 2022-04-05
2
7
 
3
8
  * Fix `wti init` command with ruby 3.1. #177
@@ -17,7 +17,7 @@ module WebTranslateIt
17
17
  self.path = root_path
18
18
  self.logger = logger
19
19
  if File.exist?(File.expand_path(path_to_config_file, path))
20
- self.api_key = ENV['WTI_PROJECT_API_KEY'] || configuration['api_key']
20
+ self.api_key = ENV.fetch('WTI_PROJECT_API_KEY') { configuration['api_key'] }
21
21
  self.before_pull = configuration['before_pull']
22
22
  self.after_pull = configuration['after_pull']
23
23
  self.before_push = configuration['before_push']
@@ -99,7 +99,7 @@ module WebTranslateIt
99
99
  if File.exist?(file_path)
100
100
  if force || (remote_checksum != local_checksum)
101
101
  File.open(file_path) do |file|
102
- params = { 'file' => UploadIO.new(file, 'text/plain', file.path), 'merge' => merge, 'ignore_missing' => ignore_missing, 'label' => label, 'low_priority' => low_priority, 'minor_changes' => minor_changes }
102
+ params = { 'file' => Multipart::Post::UploadIO.new(file, 'text/plain', file.path), 'merge' => merge, 'ignore_missing' => ignore_missing, 'label' => label, 'low_priority' => low_priority, 'minor_changes' => minor_changes }
103
103
  params['name'] = destination_path unless destination_path.nil?
104
104
  params['rename_others'] = rename_others
105
105
  request = Net::HTTP::Put::Multipart.new(api_url, params)
@@ -150,7 +150,7 @@ module WebTranslateIt
150
150
  display.push "#{StringUtil.checksumify(local_checksum.to_s)}..[ ]"
151
151
  if File.exist?(file_path)
152
152
  File.open(file_path) do |file|
153
- request = Net::HTTP::Post::Multipart.new(api_url_for_create, { 'name' => file_path, 'file' => UploadIO.new(file, 'text/plain', file.path), 'low_priority' => low_priority })
153
+ request = Net::HTTP::Post::Multipart.new(api_url_for_create, { 'name' => file_path, 'file' => Multipart::Post::UploadIO.new(file, 'text/plain', file.path), 'low_priority' => low_priority })
154
154
  WebTranslateIt::Util.add_fields(request)
155
155
  display.push Util.handle_response(http_connection.request(request))
156
156
  puts ArrayUtil.to_columns(display)
@@ -1,7 +1,7 @@
1
1
  class ArrayUtil
2
2
  def self.to_columns(arr)
3
3
  if arr[0][0] == '*'
4
- "*#{StringUtil.backward_truncate(arr[0][1..-1])} | #{arr[1]} #{arr[2]}\n"
4
+ "*#{StringUtil.backward_truncate(arr[0][1..])} | #{arr[1]} #{arr[2]}\n"
5
5
  else
6
6
  " #{StringUtil.backward_truncate(arr[0])} | #{arr[1]} #{arr[2]}\n"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_translate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.3.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -156,12 +156,6 @@ files:
156
156
  - man/wti.1.html
157
157
  - man/wti.1.ron
158
158
  - readme.md
159
- - spec/examples/config/translation.yml
160
- - spec/examples/en.yml
161
- - spec/spec_helper.rb
162
- - spec/web_translate_it/auto_fetch_spec.rb
163
- - spec/web_translate_it/string_spec.rb
164
- - spec/web_translate_it/term_spec.rb
165
159
  homepage: https://webtranslateit.com
166
160
  licenses:
167
161
  - MIT
@@ -183,21 +177,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
177
  requirements:
184
178
  - - ">="
185
179
  - !ruby/object:Gem::Version
186
- version: '2.5'
180
+ version: '2.6'
187
181
  required_rubygems_version: !ruby/object:Gem::Requirement
188
182
  requirements:
189
- - - ">="
183
+ - - ">"
190
184
  - !ruby/object:Gem::Version
191
- version: '0'
185
+ version: 1.3.1
192
186
  requirements: []
193
- rubygems_version: 3.3.3
187
+ rubygems_version: 3.3.13
194
188
  signing_key:
195
189
  specification_version: 4
196
190
  summary: A CLI tool to sync locale files with WebTranslateIt.com.
197
- test_files:
198
- - spec/examples/config/translation.yml
199
- - spec/examples/en.yml
200
- - spec/spec_helper.rb
201
- - spec/web_translate_it/auto_fetch_spec.rb
202
- - spec/web_translate_it/string_spec.rb
203
- - spec/web_translate_it/term_spec.rb
191
+ test_files: []
@@ -1,9 +0,0 @@
1
- # The Project API Token from Web Translate It
2
- api_key: 4af21ce1fb3a4f7127a60b31ebc41c1446b38bb2
3
-
4
- # Optional: locales not to sync with Web Translate It.
5
- # eg. [:en, :fr] or just 'en'
6
- # ignore_locales: :en
7
-
8
- # Silence SSL errors
9
- # silence_errors: true
data/spec/examples/en.yml DELETED
@@ -1,38 +0,0 @@
1
- en:
2
- activerecord:
3
- errors:
4
- templates:
5
- header:
6
- one: "1 error prohibited this {{model}} from being saved"
7
- other: "{{count}} errors prohibited this {{model}} from being saved"
8
- body: "there were problems with the following fields:"
9
- messages:
10
- accepted: "must be accepted"
11
- blank: "can't be blank"
12
- confirmation: "doesn't match confirmation"
13
- empty: "can't be empty"
14
- equal_to: "must be equal to {{count}}"
15
- even: "must be even"
16
- exclusion: "is reserved"
17
- greater_than: "must be greater than {{count}}"
18
- greater_than_or_equal_to: "must be greater than or equal to {{count}}"
19
- inclusion: "is not included in the list"
20
- invalid: "is invalid"
21
- less_than: "must be less than {{count}}"
22
- less_than_or_equal_to: "must be less than or equal to {{count}}"
23
- not_a_number: "is not a number"
24
- odd: "must be odd"
25
- taken: "is already taken"
26
- too_long: "is too long (maximum is {{count}} characters)"
27
- too_short: "is too short (minimum is {{count}} characters)"
28
- wrong_length: "is the wrong length (should be {{count}} characters)"
29
- models:
30
- invitation:
31
- attributes:
32
- email:
33
- user_already_invited: "This user has already been invited"
34
- user_already_member: "This user is already a member"
35
- project_file:
36
- attributes:
37
- file:
38
- file_format_not_supported: "Sorry, we currenly support only Gettext .pot/.po, .yml/.yaml and .strings"
data/spec/spec_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- if ENV['COVERAGE']
2
- require 'simplecov'
3
- SimpleCov.start
4
- end
5
-
6
- require File.expand_path('../lib/web_translate_it', __dir__)
7
- require 'rspec'
8
-
9
- class I18n
10
- def self.reload!; end
11
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe WebTranslateIt::AutoFetch do
4
- let(:application) { double(:application, call: []) }
5
-
6
- let(:env) do
7
- { 'PATH_INFO' => path }
8
- end
9
-
10
- subject { described_class.new(application) }
11
-
12
- before { WebTranslateIt.stub(:fetch_translations) }
13
-
14
- after { subject.call(env) }
15
-
16
- context 'path is /' do
17
- let(:path) { '/' }
18
-
19
- it 'should call the application' do
20
- application.should_receive(:call).with(env)
21
- end
22
-
23
- it 'should update the translations' do
24
- WebTranslateIt.should_receive(:fetch_translations)
25
- end
26
-
27
- it 'should reload the I18n definitions' do
28
- I18n.should_receive(:reload!)
29
- end
30
- end
31
-
32
- context 'path is /assets/application.js' do
33
- let(:path) { '/assets/application.js' }
34
-
35
- it 'should call the application' do
36
- application.should_receive(:call).with(env)
37
- end
38
-
39
- it 'should not update the translations' do
40
- WebTranslateIt.should_not_receive(:fetch_translations)
41
- end
42
-
43
- it 'should not reload the I18n definitions' do
44
- I18n.should_not_receive(:reload!)
45
- end
46
- end
47
- end
@@ -1,153 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe WebTranslateIt::String do
4
- let(:api_key) { 'proj_pvt_glzDR250FLXlMgJPZfEyHQ' }
5
-
6
- describe '#initialize' do
7
- it 'should assign api_key and many parameters' do
8
- string = WebTranslateIt::String.new({ 'id' => 1234, 'key' => 'bacon' })
9
- string.id.should == 1234
10
- string.key.should == 'bacon'
11
- end
12
-
13
- it 'should assign parameters using symbols' do
14
- string = WebTranslateIt::String.new({ id: 1234, key: 'bacon' })
15
- string.id.should == 1234
16
- string.key.should == 'bacon'
17
- end
18
- end
19
-
20
- describe '#save' do
21
- it 'should create a new String' do
22
- WebTranslateIt::Connection.new(api_key) do
23
- string = WebTranslateIt::String.new({ 'key' => 'bacon' })
24
- string.save
25
- string.id.should_not be_nil
26
- string_fetched = WebTranslateIt::String.find(string.id)
27
- string_fetched.should_not be_nil
28
- string_fetched.should be_a(WebTranslateIt::String)
29
- string_fetched.id.should == string.id
30
- string.delete
31
- end
32
- end
33
-
34
- it 'should update an existing String' do
35
- WebTranslateIt::Connection.new(api_key) do
36
- string = WebTranslateIt::String.new({ 'key' => 'bacony' })
37
- string.save
38
- string.key = 'bacon changed'
39
- string.save
40
- string_fetched = WebTranslateIt::String.find(string.id)
41
- string_fetched.key.should == 'bacon changed'
42
- string.delete
43
- end
44
- end
45
-
46
- it 'should create a new String with Translation' do
47
- translation1 = WebTranslateIt::Translation.new({ 'locale' => 'en', 'text' => 'Hello' })
48
- translation2 = WebTranslateIt::Translation.new({ 'locale' => 'fr', 'text' => 'Bonjour' })
49
-
50
- string = WebTranslateIt::String.new({ 'key' => 'bacon', 'translations' => [translation1, translation2] })
51
- WebTranslateIt::Connection.new(api_key) do
52
- string.save
53
- string_fetched = WebTranslateIt::String.find(string.id)
54
- string_fetched.translation_for('en').should_not be_nil
55
- string_fetched.translation_for('en').text.should == 'Hello'
56
- string_fetched.translation_for('fr').should_not be_nil
57
- string_fetched.translation_for('fr').text.should == 'Bonjour'
58
- string_fetched.translation_for('es').should be_nil
59
- string.delete
60
- end
61
- end
62
-
63
- it 'should update a String and save its Translation' do
64
- translation1 = WebTranslateIt::Translation.new({ 'locale' => 'en', 'text' => 'Hello' })
65
- translation2 = WebTranslateIt::Translation.new({ 'locale' => 'fr', 'text' => 'Bonjour' })
66
-
67
- string = WebTranslateIt::String.new({ 'key' => 'bacon' })
68
- WebTranslateIt::Connection.new(api_key) do
69
- string.save
70
- string_fetched = WebTranslateIt::String.find(string.id)
71
- string_fetched.translation_for('fr').should be_nil
72
-
73
- string_fetched.translations = [translation1, translation2]
74
- string_fetched.save
75
-
76
- string_fetched = WebTranslateIt::String.find(string.id)
77
- string_fetched.translation_for('en').should_not be_nil
78
- string_fetched.translation_for('en').text.should == 'Hello'
79
- string_fetched.translation_for('fr').should_not be_nil
80
- string_fetched.translation_for('fr').text.should == 'Bonjour'
81
- string.delete
82
- end
83
- end
84
- end
85
-
86
- describe '#delete' do
87
- it 'should delete a String' do
88
- string = WebTranslateIt::String.new({ 'key' => 'bacon' })
89
- WebTranslateIt::Connection.new(api_key) do
90
- string.save
91
- string_fetched = WebTranslateIt::String.find(string.id)
92
- string_fetched.should_not be_nil
93
-
94
- string_fetched.delete
95
- WebTranslateIt::String.find(string.id).should be_nil
96
- end
97
- end
98
- end
99
-
100
- describe '#find_all' do
101
- it 'should find many strings' do
102
- WebTranslateIt::Connection.new(api_key) do
103
- string1 = WebTranslateIt::String.new({ 'key' => 'one two three' })
104
- string1.save
105
- string2 = WebTranslateIt::String.new({ 'key' => 'four five six' })
106
- string2.save
107
- string3 = WebTranslateIt::String.new({ 'key' => 'six seven eight' })
108
- string3.save
109
-
110
- strings = WebTranslateIt::String.find_all({ 'key' => 'six' })
111
- strings.count.should == 2
112
- strings[0].key.should == 'four five six'
113
- strings[1].key.should == 'six seven eight'
114
-
115
- strings = WebTranslateIt::String.find_all({ key: 'six' })
116
- strings.count.should == 2
117
- strings[0].key.should == 'four five six'
118
- strings[1].key.should == 'six seven eight'
119
-
120
- strings = WebTranslateIt::String.find_all({ 'key' => 'eight' })
121
- strings.count.should == 1
122
- strings[0].key.should == 'six seven eight'
123
-
124
- strings = WebTranslateIt::String.find_all({ 'key' => 'three' })
125
- strings.count.should == 1
126
- strings[0].key.should == 'one two three'
127
- end
128
- end
129
- end
130
-
131
- describe '#translation_for' do
132
- it 'should fetch translations' do
133
- translation = WebTranslateIt::Translation.new({ 'locale' => 'en', 'text' => 'Hello' })
134
- string = WebTranslateIt::String.new({ 'key' => 'greetings', 'translations' => [translation] })
135
- WebTranslateIt::Connection.new(api_key) do
136
- string.save
137
- string_fetched = WebTranslateIt::String.find(string.id)
138
- string_fetched.translation_for('en').should_not be_nil
139
- string_fetched.translation_for('en').text.should == 'Hello'
140
- string_fetched.translation_for('fr').should be_nil
141
- string.delete
142
- end
143
- end
144
-
145
- it 'should not return a stale object' do
146
- string = WebTranslateIt::String.new({ key: 'greetings 2' })
147
- translation = WebTranslateIt::Translation.new({ locale: 'es', text: 'text', string_id: string.id })
148
- string.translations << translation
149
- string.translation_for('fr').should be_nil
150
- string.translation_for('es').should_not be_nil
151
- end
152
- end
153
- end
@@ -1,121 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe WebTranslateIt::Term do
4
- let(:api_key) { 'proj_pvt_glzDR250FLXlMgJPZfEyHQ' }
5
-
6
- describe '#initialize' do
7
- it 'should assign api_key and many parameters' do
8
- term = WebTranslateIt::Term.new({ 'id' => 1234, 'text' => 'bacon' })
9
- term.id.should == 1234
10
- term.text.should == 'bacon'
11
- end
12
-
13
- it 'should assign parameters using symbols' do
14
- term = WebTranslateIt::Term.new({ id: 1234, text: 'bacon' })
15
- term.id.should == 1234
16
- term.text.should == 'bacon'
17
- end
18
- end
19
-
20
- describe '#save' do
21
- it 'should create a new Term' do
22
- WebTranslateIt::Connection.new(api_key) do
23
- term = WebTranslateIt::Term.new({ 'text' => 'Term', 'description' => 'A description' })
24
- term.save
25
- term.id.should_not be_nil
26
- term_fetched = WebTranslateIt::Term.find(term.id)
27
- term_fetched.should_not be_nil
28
- term_fetched.should be_a(WebTranslateIt::Term)
29
- term_fetched.id.should == term.id
30
- term.delete
31
- end
32
- end
33
-
34
- it 'should update an existing Term' do
35
- WebTranslateIt::Connection.new(api_key) do
36
- term = WebTranslateIt::Term.new({ 'text' => 'Term 2', 'description' => 'A description' })
37
- term.save
38
- term.text = 'A Term'
39
- term.save
40
- term_fetched = WebTranslateIt::Term.find(term.id)
41
- term_fetched.text.should == 'A Term'
42
- term.delete
43
- end
44
- end
45
-
46
- it 'should create a new Term with a TermTranslation' do
47
- translation1 = WebTranslateIt::TermTranslation.new({ 'locale' => 'fr', 'text' => 'Bonjour' })
48
- translation2 = WebTranslateIt::TermTranslation.new({ 'locale' => 'fr', 'text' => 'Salut' })
49
-
50
- term = WebTranslateIt::Term.new({ 'text' => 'Hello', 'translations' => [translation1, translation2] })
51
- WebTranslateIt::Connection.new(api_key) do
52
- term.save
53
- term_fetched = WebTranslateIt::Term.find(term.id)
54
- term_fetched.translation_for('fr').should_not be_nil
55
- term_fetched.translation_for('fr')[0].text.should == 'Salut'
56
- term_fetched.translation_for('fr')[1].text.should == 'Bonjour'
57
- term_fetched.translation_for('es').should be_nil
58
- term.delete
59
- end
60
- end
61
-
62
- it 'should update a Term and save its Translation' do
63
- translation1 = WebTranslateIt::TermTranslation.new({ 'locale' => 'fr', 'text' => 'Bonjour' })
64
- translation2 = WebTranslateIt::TermTranslation.new({ 'locale' => 'fr', 'text' => 'Salut' })
65
-
66
- term = WebTranslateIt::Term.new({ 'text' => 'Hi!' })
67
- WebTranslateIt::Connection.new(api_key) do
68
- term.save
69
- term_fetched = WebTranslateIt::Term.find(term.id)
70
- term_fetched.translation_for('fr').should be_nil
71
-
72
- term_fetched.translations = [translation1, translation2]
73
- term_fetched.save
74
-
75
- term_fetched = WebTranslateIt::Term.find(term.id)
76
- term_fetched.translation_for('fr').should_not be_nil
77
- term_fetched.translation_for('fr')[0].text.should == 'Salut'
78
- term_fetched.translation_for('fr')[1].text.should == 'Bonjour'
79
- term.delete
80
- end
81
- end
82
- end
83
-
84
- describe '#delete' do
85
- it 'should delete a Term' do
86
- term = WebTranslateIt::Term.new({ 'text' => 'bacon' })
87
- WebTranslateIt::Connection.new(api_key) do
88
- term.save
89
- term_fetched = WebTranslateIt::Term.find(term.id)
90
- term_fetched.should_not be_nil
91
-
92
- term_fetched.delete
93
- term_fetched = WebTranslateIt::Term.find(term.id)
94
- term_fetched.should be_nil
95
- end
96
- end
97
- end
98
-
99
- describe '#find_all' do
100
- it 'should fetch many terms' do
101
- WebTranslateIt::Connection.new(api_key) do
102
- terms = WebTranslateIt::Term.find_all
103
- count = terms.count
104
-
105
- term1 = WebTranslateIt::Term.new({ 'text' => 'greeting 1' })
106
- term1.save
107
- term2 = WebTranslateIt::Term.new({ 'text' => 'greeting 2' })
108
- term2.save
109
- term3 = WebTranslateIt::Term.new({ 'text' => 'greeting 3' })
110
- term3.save
111
-
112
- terms = WebTranslateIt::Term.find_all
113
- count - terms.count.should == 3
114
-
115
- term1.delete
116
- term2.delete
117
- term3.delete
118
- end
119
- end
120
- end
121
- end