localeapp 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8e980b2b5650345f5dd313cc10d90565c933c80d
4
- data.tar.gz: 71fb78f68e8ba17a77f455959e5ae93afba5b167
2
+ SHA256:
3
+ metadata.gz: 805c6256d30038f1a1939798e4f26ac91f19f330b9741ed9c99c880c4baedafd
4
+ data.tar.gz: fd70529ab0d1df20710fd100ba9382e9451ac22d011a53dd047b42a25434d682
5
5
  SHA512:
6
- metadata.gz: 1a250730215706813c93ec256abc58726f1174e21cc13a9a3cb8579c6abf7a4718c2b055102ab989c82a83bf7f770a6016e7f5230aec7467b206db8ef3856495
7
- data.tar.gz: abbc4fdb58a0b443242893e96857ecee7630832e269244158354c99ea3cb231ffb5eda4bbd8bc1112070e0e944417e91d5ac28e085751dc3d16014aedc854393
6
+ metadata.gz: 957f7db15344c1406d2841581934e5be63bd795ddb3777bde5f928bee053df61dae6e5de25f813a0c07b81b4ae1eb843bc1713f039e81ec4f91490e4e7bfd2d0
7
+ data.tar.gz: 0d341f9b235d16688ce7f65de0dc5c129451823cb0562e446086d3f865a49ccede5b8a89789fc6ffd5e3ffe78f306c075871e635c6f9444788325ed7a6a88804
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ doc/*
9
9
  tmp/*
10
10
  .ruby-version
11
11
  .ruby-gemsets
12
+ .rvmrc
data/.travis.yml CHANGED
@@ -3,17 +3,18 @@ dist: trusty
3
3
  before_install:
4
4
  - gem install bundler
5
5
  rvm:
6
- - 2.4.1
7
- - 2.3.4
8
- - 2.2.7
6
+ - 2.5.0
7
+ - 2.4.3
8
+ - 2.3.6
9
+ - 2.2.9
9
10
  - 2.1.10
10
- - jruby
11
+ - jruby-9.1.15.0
11
12
  gemfile:
12
13
  - Gemfile
13
- - gemfiles/i18n_0.4.gemfile
14
- - gemfiles/i18n_0.5.gemfile
15
- - gemfiles/i18n_0.6.gemfile
16
- - gemfiles/i18n_0.7.gemfile
14
+ - spec/gemfiles/i18n_0.7.gemfile
15
+ - spec/gemfiles/i18n_0.8.gemfile
16
+ - spec/gemfiles/i18n_0.9.gemfile
17
+ - spec/gemfiles/i18n_1.0.gemfile
17
18
  notifications:
18
19
  slack:
19
20
  secure: JryUWfe2JR0cfNT+TIHwryy8NS8m9/hbRhg+5UqwuYWuEp6gtcWCA05wKsajQyRrGaNGYKu81RA9jpQrirgQWzDUJl5o3sEWbqKZv3pW0ybn8Tx52N1mxW3Puar5KLZ8TPRphKKIJ8/1EhAh4zpC5Mtxv8Sz1/AHuqnlu6l+bb4=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # master
2
2
 
3
+ # Version 3.0.0
4
+
5
+ * drop support for i18n 0.4, 0.5 and 0.6 (ℹ️ Rails [dropped those in July 2014](https://github.com/rails/rails/commit/cd7d414e48f537278043bfc77cfb4217e8c89c24)))
6
+ * add official support for i18n 0.8, 0.9 and 1.0
7
+ * prevent users to use dependencies impacted by some vulnerabilities:
8
+ * OSVDB-101157
9
+ * CVE-2015-3448 / OSVDB-117461
10
+ * CVE-2013-0269 / OSVDB-101137
11
+ * CVE-2015-1820 / OSVDB-119878
12
+ * fix a bug introduced in 2.5.0 where the exception handler was crashing with `TypeMismatch` error when `blacklisted_keys_pattern` was not explicitly configured
13
+
14
+ # Version 2.5.0
15
+
16
+ * Show fully-scoped keys in `ExceptionHandler` log messages (thanks to [@leonhooijer](https://github.com/leonhooijer))
17
+ * Don't force raising an exception for blacklisted keys (thanks to [@leonhooijer](https://github.com/leonhooijer))
18
+
19
+ # Version 2.4.0
20
+
21
+ * Support pulling of single locales (thanks to [@full-of-foo](https://github.com/full-of-foo))
22
+
3
23
  # Version 2.3.0
4
24
 
5
25
  * Report import identifier on push success
@@ -26,7 +46,7 @@
26
46
 
27
47
  # Version 1.0.2
28
48
 
29
- * Fix a XSS vulnerability where translations keys could contain unescaped HTML (@grekko)
49
+ * Fix a XSS vulnerability where translations keys could contain unescaped HTML (thanks to [@grekko](https://github.com/grekko))
30
50
 
31
51
  # Version 1.0.1
32
52
 
@@ -62,7 +82,7 @@
62
82
 
63
83
  # Version 0.8.0
64
84
 
65
- * Fix problem with line ending in three dots. (@holli)
85
+ * Fix problem with line ending in three dots. (thanks to [@holli](https://github.com/holli))
66
86
  * Change deprecated File.exists? to File.exist?
67
87
  * Fix "install --github" so it appends README.md. Before it truncated the README.md file with new content, now it appends content in a more correct manner.
68
88
  * Fix .gitignore injection so it ensures a newline.
@@ -121,7 +141,7 @@
121
141
 
122
142
  # Version 0.6.9
123
143
 
124
- * Make rack a dependency as we actually use it (Thanks @martoche)
144
+ * Make rack a dependency as we actually use it (thanks to [@martoche](https://github.com/martoche))
125
145
 
126
146
  # Version 0.6.8
127
147
 
@@ -181,21 +201,21 @@
181
201
 
182
202
  # Version 0.4.3
183
203
 
184
- * Make sure Psych is fully loaded before using it (Thanks @tenderlove)
204
+ * Make sure Psych is fully loaded before using it (thanks to [@tenderlove](https://github.com/tenderlove))
185
205
 
186
206
  # Version 0.4.2
187
207
 
188
- * Improve compatibility of Psych with ruby 1.9.2 (Thanks @ardpac)
208
+ * Improve compatibility of Psych with ruby 1.9.2 (thanks to [@ardpac](https://github.com/ardpac))
189
209
 
190
210
  # Version 0.4.1
191
211
 
192
- * Ignore HUP when backgrounded. (Thanks @xijo)
212
+ * Ignore HUP when backgrounded. (thanks to [@xijo](https://github.com/xijo))
193
213
  * Add --standalone option to install to generate a .localeapp/ config directory. This enables usage outside of rails.
194
214
 
195
215
  # Version 0.4.0
196
216
 
197
217
  * Use Psych to generate the yaml if it's available (This will completely change your yaml the first time you do a localeapp pull and Psych is available)
198
- * Report when the directory to write the yml to doesn't exist (Thanks Robin Mehner)
218
+ * Report when the directory to write the yml to doesn't exist (thanks to [@rmehner](https://github.com/rmehner))
199
219
 
200
220
  # Version 0.3.2
201
221
 
@@ -204,13 +224,13 @@
204
224
  # Version 0.3.1
205
225
 
206
226
  * Handle SocketError so we don't cause errors in client apps when they're not connected to the network
207
- * Fix bug with empty log file (Thanks Robin Mehner)
227
+ * Fix bug with empty log file (thanks to [@rmehner](https://github.com/rmehner))
208
228
 
209
229
  # Version 0.3.0
210
230
 
211
231
  * Allow symbols for environment names in config file
212
- * `localeapp push` will now push all yaml files in a directory if it's given a directory instead of a file. (Thanks Bartłomiej Danek)
213
- * Better daemon support. `daemon_pid_file` and `daemon_log_file` configuration options. (Thanks again Bartłomiej Danek)
232
+ * `localeapp push` will now push all yaml files in a directory if it's given a directory instead of a file (thanks to [@bartlomiejdanek](https://github.com/bartlomiejdanek))
233
+ * Better daemon support. `daemon_pid_file` and `daemon_log_file` configuration options (thanks to [@bartlomiejdanek](https://github.com/bartlomiejdanek))
214
234
 
215
235
  # Version 0.2.0
216
236
 
data/bin/localeapp CHANGED
@@ -138,10 +138,12 @@ module LocaleappGLIWrapper
138
138
  end
139
139
  end
140
140
 
141
- desc "Pulls all translations from localeapp.com"
141
+ desc "Pulls one or all translations from localeapp.com"
142
+ arg_name "<key> (optional)"
142
143
  command :pull do |c|
143
144
  c.action do |global_options, options, args|
144
- Localeapp::CLI::Pull.new(global_options).execute
145
+ locale_key = args[0]
146
+ Localeapp::CLI::Pull.new(global_options).execute(locale_key)
145
147
  end
146
148
  end
147
149
 
@@ -16,6 +16,27 @@ Feature: `pull' command
16
16
  Success!
17
17
  """
18
18
  And a file named "config/locales/en.yml" should exist
19
+ And a file named "config/locales/es.yml" should exist
20
+
21
+ Scenario: Pulls single translation
22
+ Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
23
+ And an initializer file
24
+ And a directory named "config/locales"
25
+ And a directory named "log"
26
+ When I successfully run `localeapp pull en`
27
+ Then the output should contain "Fetching en translations:"
28
+ And a file named "config/locales/en.yml" should exist
29
+ And a file named "config/locales/es.yml" should not exist
30
+
31
+ Scenario: Reports an error when a given locale is missing
32
+ Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
33
+ And an initializer file
34
+ When I run `localeapp pull err`
35
+ Then the exit status must be 1
36
+ And the output should contain:
37
+ """
38
+ Could not find given locale
39
+ """
19
40
 
20
41
  Scenario: Reports an error when locales directory is missing
21
42
  Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
@@ -3,11 +3,11 @@ module Localeapp
3
3
  class Pull < Command
4
4
  include ::Localeapp::ApiCall
5
5
 
6
- def execute
7
- @output.puts "Localeapp Pull"
8
- @output.puts ""
6
+ def execute(locale_key = nil)
7
+ @locale_key = locale_key
8
+ @output.puts "Localeapp Pull\n\n" \
9
+ "Fetching#{locale_key ? ' ' << locale_key : ''} translations:"
9
10
 
10
- @output.puts "Fetching translations:"
11
11
  api_call :export,
12
12
  :success => :update_backend,
13
13
  :failure => :report_failure,
@@ -17,7 +17,7 @@ module Localeapp
17
17
  def update_backend(response)
18
18
  @output.puts "Success!"
19
19
  @output.puts "Updating backend:"
20
- Localeapp.updater.dump(Localeapp.load_yaml(response))
20
+ Localeapp.updater.dump(Localeapp.yaml_data(response, @locale_key))
21
21
  @output.puts "Success!"
22
22
  Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i)
23
23
  end
@@ -46,7 +46,9 @@ module Localeapp
46
46
  # (defaults to 'development')
47
47
  attr_accessor :reloading_environments
48
48
 
49
- # The names of environments where updates aren't pulled
49
+ # The names of environments where localeapp will poll for translations from
50
+ # Localeapp API (to check for new translations there) on every page request
51
+ # to your app's website.
50
52
  # (defaults to 'development')
51
53
  attr_accessor :polling_environments
52
54
 
@@ -2,16 +2,17 @@ module Localeapp
2
2
  class ExceptionHandler
3
3
  def self.call(exception, locale, key_or_keys, options)
4
4
  keys = Array(key_or_keys).map { |key| ERB::Util.html_escape(key.to_s) }
5
+ scoped_keys = keys.map { |key| [options[:scope], key].compact.join(".") }
5
6
  Localeapp.log(exception.message)
6
7
  # Which exact exception is set up by our i18n shims
7
8
  if exception.is_a? Localeapp::I18nMissingTranslationException
8
- Localeapp.log("Detected missing translation for key(s) #{keys.inspect}")
9
+ Localeapp.log("Detected missing translation for key(s) #{scoped_keys.inspect}")
9
10
 
10
11
  keys.each do |key|
11
12
  Localeapp.missing_translations.add(locale, key, nil, options || {})
12
13
  end
13
14
 
14
- [locale, keys].join(', ')
15
+ [locale, scoped_keys].join(', ')
15
16
  else
16
17
  Localeapp.log('Raising exception')
17
18
  raise
@@ -14,7 +14,12 @@
14
14
  module Localeapp
15
15
  module ForceExceptionHandlerInTranslationHelper
16
16
  def translate(key, options = {})
17
- super(key, {:raise => false}.merge(options))
17
+ full_key = [options[:scope], key].compact.join(".")
18
+ if full_key =~ Localeapp.configuration.blacklisted_keys_pattern
19
+ super(key, options)
20
+ else
21
+ super(key, {:raise => false}.merge(options))
22
+ end
18
23
  end
19
24
  alias :t :translate
20
25
  end
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "2.3.0"
2
+ VERSION = "3.0.0"
3
3
  end
data/lib/localeapp.rb CHANGED
@@ -109,6 +109,15 @@ module Localeapp
109
109
  load_yaml(File.read(filename))
110
110
  end
111
111
 
112
+ def yaml_data(content, locale_key = nil)
113
+ yaml_data = Localeapp.load_yaml(content)
114
+ if locale_key
115
+ raise "Could not find given locale" unless yaml_data and yaml_data[locale_key]
116
+ yaml_data = {locale_key => yaml_data[locale_key]}
117
+ end
118
+ yaml_data
119
+ end
120
+
112
121
  def env_file_path
113
122
  ENV_FILE_PATH
114
123
  end
data/localeapp.gemspec CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.required_ruby_version = ">= 2.1"
24
24
 
25
- s.add_dependency('i18n', '~> 0.4')
26
- s.add_dependency('json')
27
- s.add_dependency('rest-client')
25
+ s.add_dependency('i18n', '>= 0.7', '< 2')
26
+ s.add_dependency('json', '>= 1.1.0')
27
+ s.add_dependency('rest-client', '>= 1.8.0')
28
28
  s.add_dependency('gli')
29
29
 
30
30
  s.add_development_dependency('rake')
@@ -33,5 +33,4 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency('aruba', '~> 0.8')
34
34
  s.add_development_dependency('cucumber', '~> 2.0')
35
35
  s.add_development_dependency('fakeweb')
36
- s.add_development_dependency('appraisal')
37
36
  end
@@ -1,5 +1,3 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
3
  gem "i18n", "~> 0.7.0"
@@ -8,4 +6,4 @@ platforms :jruby do
8
6
  gem "jruby-openssl", "~> 0.6"
9
7
  end
10
8
 
11
- gemspec :path => "../"
9
+ gemspec :path => "../.."
@@ -1,11 +1,9 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "i18n", "~> 0.4.0"
3
+ gem "i18n", "~> 0.8.0"
6
4
 
7
5
  platforms :jruby do
8
6
  gem "jruby-openssl", "~> 0.6"
9
7
  end
10
8
 
11
- gemspec :path => "../"
9
+ gemspec :path => "../.."
@@ -1,11 +1,9 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "i18n", "~> 0.5.0"
3
+ gem "i18n", "~> 0.9.0"
6
4
 
7
5
  platforms :jruby do
8
6
  gem "jruby-openssl", "~> 0.6"
9
7
  end
10
8
 
11
- gemspec :path => "../"
9
+ gemspec :path => "../.."
@@ -1,11 +1,9 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "i18n", "~> 0.6.0"
3
+ gem "i18n", "~> 1.0.0"
6
4
 
7
5
  platforms :jruby do
8
6
  gem "jruby-openssl", "~> 0.6"
9
7
  end
10
8
 
11
- gemspec :path => "../"
9
+ gemspec :path => "../.."
@@ -46,4 +46,9 @@ describe Localeapp::ExceptionHandler, '#call(exception, locale, key, options)' d
46
46
  Localeapp::ExceptionHandler.call(exception, :en, 'foo', {})
47
47
  }.to_not raise_error
48
48
  end
49
+
50
+ it "handles the scope option" do
51
+ expect(I18n.t('foo.bar', scope: 'scoped')).to eq 'en, scoped.foo.bar'
52
+ expect(I18n.t(%w{foo.bar foo.baz}, scope: 'scoped')).to eq 'en, scoped.foo.bar, scoped.foo.baz'
53
+ end
49
54
  end
@@ -15,3 +15,20 @@ describe Localeapp, "#load_yaml(content)" do
15
15
  end
16
16
  end
17
17
  end
18
+
19
+ describe Localeapp, "#yaml_data(content, locale_key = nil)" do
20
+ let(:content) { "en:\n foo: bar" }
21
+ let(:locale_key) { "en" }
22
+
23
+ it "raises an exception if the given locale key is missing" do
24
+ with_configuration do
25
+ expect { Localeapp.yaml_data(content, "de") }.to raise_error("Could not find given locale")
26
+ end
27
+ end
28
+
29
+ it "finds the given locale key" do
30
+ with_configuration do
31
+ expect(Localeapp.yaml_data(content, locale_key)).to eq({"en" => {"foo" => "bar"}})
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localeapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Dell
@@ -10,50 +10,56 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-23 00:00:00.000000000 Z
13
+ date: 2018-03-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0.7'
22
+ - - "<"
20
23
  - !ruby/object:Gem::Version
21
- version: '0.4'
24
+ version: '2'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0.7'
32
+ - - "<"
27
33
  - !ruby/object:Gem::Version
28
- version: '0.4'
34
+ version: '2'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: json
31
37
  requirement: !ruby/object:Gem::Requirement
32
38
  requirements:
33
39
  - - ">="
34
40
  - !ruby/object:Gem::Version
35
- version: '0'
41
+ version: 1.1.0
36
42
  type: :runtime
37
43
  prerelease: false
38
44
  version_requirements: !ruby/object:Gem::Requirement
39
45
  requirements:
40
46
  - - ">="
41
47
  - !ruby/object:Gem::Version
42
- version: '0'
48
+ version: 1.1.0
43
49
  - !ruby/object:Gem::Dependency
44
50
  name: rest-client
45
51
  requirement: !ruby/object:Gem::Requirement
46
52
  requirements:
47
53
  - - ">="
48
54
  - !ruby/object:Gem::Version
49
- version: '0'
55
+ version: 1.8.0
50
56
  type: :runtime
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
53
59
  requirements:
54
60
  - - ">="
55
61
  - !ruby/object:Gem::Version
56
- version: '0'
62
+ version: 1.8.0
57
63
  - !ruby/object:Gem::Dependency
58
64
  name: gli
59
65
  requirement: !ruby/object:Gem::Requirement
@@ -152,20 +158,6 @@ dependencies:
152
158
  - - ">="
153
159
  - !ruby/object:Gem::Version
154
160
  version: '0'
155
- - !ruby/object:Gem::Dependency
156
- name: appraisal
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- version: '0'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- version: '0'
169
161
  description: Synchronizes i18n translation keys and content with localeapp.com so
170
162
  you don't have to manage translations by hand.
171
163
  email:
@@ -180,7 +172,6 @@ files:
180
172
  - ".gitignore"
181
173
  - ".rspec"
182
174
  - ".travis.yml"
183
- - Appraisals
184
175
  - CHANGELOG.md
185
176
  - CONTRIBUTING.md
186
177
  - Gemfile
@@ -207,10 +198,6 @@ files:
207
198
  - features/support/env.rb
208
199
  - features/support/hooks.rb
209
200
  - features/update.feature
210
- - gemfiles/i18n_0.4.gemfile
211
- - gemfiles/i18n_0.5.gemfile
212
- - gemfiles/i18n_0.6.gemfile
213
- - gemfiles/i18n_0.7.gemfile
214
201
  - lib/localeapp.rb
215
202
  - lib/localeapp/api_call.rb
216
203
  - lib/localeapp/api_caller.rb
@@ -256,6 +243,10 @@ files:
256
243
  - spec/fixtures/es.yml
257
244
  - spec/fixtures/string_log.yml
258
245
  - spec/fixtures/symbol_log.yml
246
+ - spec/gemfiles/i18n_0.7.gemfile
247
+ - spec/gemfiles/i18n_0.8.gemfile
248
+ - spec/gemfiles/i18n_0.9.gemfile
249
+ - spec/gemfiles/i18n_1.0.gemfile
259
250
  - spec/localeapp/api_call_spec.rb
260
251
  - spec/localeapp/api_caller_spec.rb
261
252
  - spec/localeapp/cli/add_spec.rb
@@ -302,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
293
  version: '0'
303
294
  requirements: []
304
295
  rubyforge_project: localeapp
305
- rubygems_version: 2.6.12
296
+ rubygems_version: 2.7.6
306
297
  signing_key:
307
298
  specification_version: 4
308
299
  summary: Easy i18n translation management with localeapp.com
data/Appraisals DELETED
@@ -1,15 +0,0 @@
1
- appraise "i18n-0.4" do
2
- gem "i18n", "~> 0.4.0"
3
- end
4
-
5
- appraise "i18n-0.5" do
6
- gem "i18n", "~> 0.5.0"
7
- end
8
-
9
- appraise "i18n-0.6" do
10
- gem "i18n", "~> 0.6.0"
11
- end
12
-
13
- appraise "i18n-0.7" do
14
- gem "i18n", "~> 0.7.0"
15
- end