web_translate_it 2.5.1 → 2.5.4

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: bb952e216ebe7b504b0c40dfcc1659795e527b0822c4d952cdba9d251b0f32b5
4
- data.tar.gz: 685717f0eb53fe6e5f42c35896cedcfeeb39555e8e7eaf0a4fad7caa3edf237a
3
+ metadata.gz: bc4a1374f3018354d15fea035305984fa839a6786526cc88e8d3151f176d8f79
4
+ data.tar.gz: fbc8868713a8d691169eea12318bb0c288853c25cedf24ddaaac10b44b461d09
5
5
  SHA512:
6
- metadata.gz: 49894fbc42db771158b68e233bbfc1e197d4eb1299f47a25270d4fdd3dbccd846e2018e86b291109bd4195bcdab31188fc518d8bbbf3f65cbd33deb2d0bd6a18
7
- data.tar.gz: 1f78011a382d2d4e8ffc9e21135c6e2899420d04403fa3481ce1ced2a9194610285abcec8b78ae8214519cde9106048f2fe1c4ea1e6b1a257e7f4739fe3e1886
6
+ metadata.gz: c8ec5eae4ac2941ca048cc798fb4ae5cb5c539345d11286d9aa35a68dca5e35cc3e138cbcb95c0ebf5d8adaffda69938cf41613762612a9ba33836e6f95f2871
7
+ data.tar.gz: 20af38470f30300f01d260e17d15d16ef90597b72d5e1e5f5d9869cf70a192c65d84f3dc9771ada30264f65c75ebfb0855da9b9f0e94e966cfc908cc872b3eda
data/history.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## Version 2.5.4 / 2022-03-08
2
+
3
+ * Better support for `before_pull`, `after_pull`, `before_push`, `after_push` hooks. They now display the command output, and write an error message if the exit status of the command was not successful.
4
+
5
+ ## Version 2.5.3 / 2022-02-04
6
+
7
+ * Properly fix ruby compatibility issues.
8
+
9
+ ## Version 2.5.2 / 2022-02-02
10
+
11
+ * Fix compatibility issues with rubies < 2.6.
12
+
1
13
  ## Version 2.5.1 / 2021-11-15
2
14
 
3
15
  * Ruby 3.1.0 compatible.
@@ -36,7 +36,7 @@ module WebTranslateIt
36
36
  def pull
37
37
  complete_success = true
38
38
  STDOUT.sync = true
39
- `#{configuration.before_pull}` if configuration.before_pull
39
+ before_pull_hook
40
40
  # Selecting files to pull
41
41
  files = []
42
42
  fetch_locales_to_pull.each do |locale|
@@ -70,15 +70,37 @@ module WebTranslateIt
70
70
  threads.each { |thread| thread.join }
71
71
  time = Time.now - time
72
72
  puts "Pulled #{files.size} files at #{(files.size/time).round} files/sec, using #{n_threads} threads."
73
- `#{configuration.after_pull}` if configuration.after_pull
73
+ after_pull_hook
74
74
  complete_success
75
75
  end
76
76
  end
77
-
77
+
78
+ def before_pull_hook
79
+ if configuration.before_pull
80
+ output = `#{configuration.before_pull}`
81
+ if $?.success?
82
+ puts output
83
+ else
84
+ abort 'Error: exit code for before_pull command is not zero'
85
+ end
86
+ end
87
+ end
88
+
89
+ def after_pull_hook
90
+ if configuration.after_pull
91
+ output = `#{configuration.after_pull}`
92
+ if $?.success?
93
+ puts output
94
+ else
95
+ abort 'Error: exit code for after_pull command is not zero'
96
+ end
97
+ end
98
+ end
99
+
78
100
  def push
79
101
  complete_success = true
80
102
  STDOUT.sync = true
81
- `#{configuration.before_push}` if configuration.before_push
103
+ before_push_hook
82
104
  WebTranslateIt::Connection.new(configuration.api_key) do |http|
83
105
  fetch_locales_to_push(configuration).each do |locale|
84
106
  if parameters.any?
@@ -96,9 +118,31 @@ module WebTranslateIt
96
118
  end
97
119
  end
98
120
  end
99
- `#{configuration.after_push}` if configuration.after_push
121
+ after_push_hook
100
122
  complete_success
101
123
  end
124
+
125
+ def before_push_hook
126
+ if configuration.before_push
127
+ output = `#{configuration.before_push}`
128
+ if $?.success?
129
+ puts output
130
+ else
131
+ abort 'Error: exit code for before_push command is not zero'
132
+ end
133
+ end
134
+ end
135
+
136
+ def after_push_hook
137
+ if configuration.after_push
138
+ output = `#{configuration.after_push}`
139
+ if $?.success?
140
+ puts output
141
+ else
142
+ abort 'Error: exit code for after_push command is not zero'
143
+ end
144
+ end
145
+ end
102
146
 
103
147
  def add
104
148
  complete_success = true
@@ -25,7 +25,11 @@ module WebTranslateIt
25
25
  self.after_pull = configuration['after_pull']
26
26
  self.before_push = configuration['before_push']
27
27
  self.after_push = configuration['after_push']
28
- project_info = YAML.safe_load WebTranslateIt::Project.fetch_info(api_key), permitted_classes: [Time]
28
+ project_info = if RUBY_VERSION >= '3.1.0'
29
+ YAML.safe_load WebTranslateIt::Project.fetch_info(api_key), permitted_classes: [Time]
30
+ else
31
+ YAML.load WebTranslateIt::Project.fetch_info(api_key)
32
+ end
29
33
  set_locales_to_ignore(configuration)
30
34
  set_locales_needed(configuration)
31
35
  set_files(project_info['project'])
data/readme.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # WebTranslateIt Synchronization Tool : wti
2
2
 
3
- [RubyDoc](http://rubydoc.info/github/AtelierConvivialite/webtranslateit/) |
4
- [Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
5
- [Support](https://webtranslateit.com/support) |
6
- [WebTranslateIt.com Homepage](https://webtranslateit.com)
3
+ [RubyDoc](https://rubydoc.info/github/webtranslateit/webtranslateit/master) |
4
+ [Report a bug](https://github.com/webtranslateit/webtranslateit/issues) |
5
+ [Support](https://webtranslateit.com/en/support) |
6
+ [WebTranslateIt.com Homepage](https://webtranslateit.com/en)
7
7
 
8
8
  wti lets you easily sync your language files with [WebTranslateIt.com](https://webtranslateit.com), a web-based tool to translation software.
9
9
 
@@ -17,14 +17,14 @@ wti lets you easily sync your language files with [WebTranslateIt.com](https://w
17
17
  ### Optionally, wti does...
18
18
 
19
19
  * include a rack middleware you can use in your Rails app to automatically fetch new translations from WebTranslateIt.com.
20
- * include libraries you can use to programmatically fetch your segments from WebTranslateIt.com. See [Extras](https://github.com/AtelierConvivialite/webtranslateit/wiki/Extras)
21
- * include a web interface for your translation team to update your language files. [Learn more on the web_translate_it_server project page](https://github.com/AtelierConvivialite/web_translate_it_server).
20
+ * include libraries you can use to programmatically fetch your segments from WebTranslateIt.com. See [Extras](https://github.com/webtranslateit/webtranslateit/wiki/Extras)
21
+ * include a web interface for your translation team to update your language files. [Learn more on the web_translate_it_server project page](https://github.com/webtranslateit/web_translate_it_server).
22
22
 
23
23
  ---
24
24
 
25
25
  ## Installation
26
26
 
27
- You will also need ruby to run `wti`. On Linux or a Mac, it’s already installed. Install [RubyInstaller](http://rubyinstaller.org/) if you’re using Windows. [See detailed installation instructions for Windows users](https://github.com/AtelierConvivialite/webtranslateit/wiki/Install-wti-on-Windows).
27
+ You will also need ruby to run `wti`. On Linux or a Mac, it’s already installed. Install [RubyInstaller](http://rubyinstaller.org/) if you’re using Windows. [See detailed installation instructions for Windows users](https://github.com/webtranslateit/webtranslateit/wiki/Install-wti-on-Windows).
28
28
 
29
29
  ``` bash
30
30
  $ gem install web_translate_it
@@ -213,7 +213,7 @@ There are 4 hooks:
213
213
  * `before_push`
214
214
  * `after_push`
215
215
 
216
- Check the [sample `.wti`](https://github.com/AtelierConvivialite/webtranslateit/blob/master/examples/.wti#L9..L13) file for implementation.
216
+ Check the [sample `.wti`](https://github.com/webtranslateit/webtranslateit/blob/master/examples/.wti#L9..L13) file for implementation.
217
217
 
218
218
  ## Exit codes
219
219
 
@@ -276,4 +276,4 @@ fr: 100% translated, 100% completed.
276
276
 
277
277
  # License
278
278
 
279
- Copyright (c) 2009-2021 WebTranslateIt Software S.L, released under the MIT License.
279
+ Copyright (c) 2009-2022 [WebTranslateIt Software S.L](https://webtranslateit.com), released under the MIT License.
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,8 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+
1
6
  require File.expand_path('../../lib/web_translate_it', __FILE__)
2
7
  require 'rspec'
3
8
 
@@ -53,8 +53,8 @@ describe WebTranslateIt::Term do
53
53
  term.save
54
54
  term_fetched = WebTranslateIt::Term.find(term.id)
55
55
  term_fetched.translation_for("fr").should_not be_nil
56
- term_fetched.translation_for("fr")[0].text.should == "Bonjour"
57
- term_fetched.translation_for("fr")[1].text.should == "Salut"
56
+ term_fetched.translation_for("fr")[0].text.should == "Salut"
57
+ term_fetched.translation_for("fr")[1].text.should == "Bonjour"
58
58
  term_fetched.translation_for("es").should be_nil
59
59
  term.delete
60
60
  end
@@ -75,8 +75,8 @@ describe WebTranslateIt::Term do
75
75
 
76
76
  term_fetched = WebTranslateIt::Term.find(term.id)
77
77
  term_fetched.translation_for("fr").should_not be_nil
78
- term_fetched.translation_for("fr")[0].text.should == "Bonjour"
79
- term_fetched.translation_for("fr")[1].text.should == "Salut"
78
+ term_fetched.translation_for("fr")[0].text.should == "Salut"
79
+ term_fetched.translation_for("fr")[1].text.should == "Bonjour"
80
80
  term.delete
81
81
  end
82
82
  end
@@ -100,6 +100,9 @@ describe WebTranslateIt::Term do
100
100
  describe "#find_all" do
101
101
  it "should fetch many terms" do
102
102
  WebTranslateIt::Connection.new(api_key) do
103
+ terms = WebTranslateIt::Term.find_all
104
+ count = terms.count
105
+
103
106
  term1 = WebTranslateIt::Term.new({ "text" => "greeting 1" })
104
107
  term1.save
105
108
  term2 = WebTranslateIt::Term.new({ "text" => "greeting 2" })
@@ -108,7 +111,7 @@ describe WebTranslateIt::Term do
108
111
  term3.save
109
112
 
110
113
  terms = WebTranslateIt::Term.find_all
111
- terms.count.should == 3
114
+ count - terms.count.should == 3
112
115
 
113
116
  term1.delete
114
117
  term2.delete
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.5.1
4
+ version: 2.5.4
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-01-14 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: guard-rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -141,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
155
  - !ruby/object:Gem::Version
142
156
  version: '0'
143
157
  requirements: []
144
- rubygems_version: 3.0.9
158
+ rubygems_version: 3.1.6
145
159
  signing_key:
146
160
  specification_version: 4
147
161
  summary: A CLI to sync locale files with WebTranslateIt.com.