localeapp 1.0.2 → 2.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmEzMjU2ZmQyMTM1NDcxY2MxNmY1MjA4ZGRiY2Y0ZTg0YjAzNjgyZQ==
4
+ YmVhOTI1MWRmMGYwM2YzNWYyNDU4NmM4N2Y1NGJkYWZjNTkxMmZmYQ==
5
5
  data.tar.gz: !binary |-
6
- YTEwOGFlMWY2OTVjZjQ0NjRmMmE1NmQzZDMwMTkxMmQ0Y2Y0ZTMwMQ==
6
+ NDQ5NmMyYjJkNjk5OWNjNjAyZjhjNGEzNmFkN2VkNjM4NjQzYjJlNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzViMWZmNjNlNGZlOGVjZTA4M2ZiOWZkMDMyMDM0NjhlMDVkYWFmYzQ2MzNj
10
- MDAzOWZlNDM0NWQ0NGJiMTBhYWQ3OGQ2M2U4ODVlYjI2MDRlMjdmODI3ZDZh
11
- YjM2Nzc2YjdlOWYxNDYxNzIxNjE1ZGM4YjU4Yzc4NzNiZjRlZWE=
9
+ MDAyMDU3Y2NiMjYxYzE1N2Q0OGE5ZjdlYjY5NWYxZTM0MGQzMmRiOGM5M2Rj
10
+ MzEwYzVmYjhhNTRkNGZmOWNiODFlN2VkNTk0NThjYmIyZDBhNTkxNTIyMDZm
11
+ MWQzYWZjZmIzYjVlZTljMTJmMDI5Y2M3YmQ2NTU4Njk5MmRmZjM=
12
12
  data.tar.gz: !binary |-
13
- NGY5MDhhNzZjNzE5MGU1NDI1OTIwODljZWJlNzU1OWIyNDU5ODc3MjhiMmE0
14
- ZDVlYjI4NDkzYTBkMWE3YjVmY2I0MjE0ODZkZTRhYzAxZGFhYTEzNjQxYWI5
15
- YzcwYTgwMTNiNzg0OTljYTA0ODM3Yzk1NjMyZTc1OWYxNGY2YWU=
13
+ NDQxNDMwZjg3MzA2MjYyODAwOWU0ZTgwMTJiYWQ0MGRjN2JhNjIyZDEwYThm
14
+ YjVmYzkwODUwY2IwNTg3NjRjNjZlYjFmMzI0YjEzMzQyODU0NzBiMzkwOTc1
15
+ YTZkNDc4ODEwNWU3ZGRlNzc1NzNkYmI4Y2Y3ZWMxMmRhZDQ5OWY=
data/.travis.yml CHANGED
@@ -1,28 +1,19 @@
1
1
  before_install:
2
+ - gem install bundler
2
3
  - gem update bundler
3
4
  rvm:
4
5
  - 1.9.3
5
6
  - 2.0
6
7
  - 2.1
7
8
  - 2.2
9
+ - 2.3.1
8
10
  - jruby
9
11
  - jruby-head
10
12
  gemfile:
11
- - gemfiles/i18n_0.3.gemfile
12
13
  - gemfiles/i18n_0.4.gemfile
13
14
  - gemfiles/i18n_0.5.gemfile
14
15
  - gemfiles/i18n_0.6.gemfile
15
16
  - gemfiles/i18n_0.7.gemfile
16
- matrix:
17
- exclude:
18
- - rvm: 2.0
19
- gemfile: gemfiles/i18n_0.3.gemfile
20
- - rvm: 2.1
21
- gemfile: gemfiles/i18n_0.3.gemfile
22
- - rvm: 2.2
23
- gemfile: gemfiles/i18n_0.3.gemfile
24
- - rvm: jruby-head
25
- gemfile: gemfiles/i18n_0.3.gemfile
26
17
  notifications:
27
18
  slack:
28
19
  secure: JryUWfe2JR0cfNT+TIHwryy8NS8m9/hbRhg+5UqwuYWuEp6gtcWCA05wKsajQyRrGaNGYKu81RA9jpQrirgQWzDUJl5o3sEWbqKZv3pW0ybn8Tx52N1mxW3Puar5KLZ8TPRphKKIJ8/1EhAh4zpC5Mtxv8Sz1/AHuqnlu6l+bb4=
data/Appraisals CHANGED
@@ -1,8 +1,3 @@
1
- appraise "i18n-0.3" do
2
- gem "i18n", "~> 0.3.0"
3
- gem "activesupport", "~> 2.3.18"
4
- end
5
-
6
1
  appraise "i18n-0.4" do
7
2
  gem "i18n", "~> 0.4.0"
8
3
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # master
2
2
 
3
+ * Drop i18n 0.3.x and rails 2.x support
4
+ * Remove rack dependency
5
+
3
6
  # Version 1.0.2
4
7
 
5
8
  * Fix a XSS vulnerability where translations keys could contain unescaped HTML (@grekko)
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  platform :jruby do
5
- gem 'jruby-openssl'
5
+ gem 'jruby-openssl', '~> 0.6'
6
6
  end
data/README.md CHANGED
@@ -21,7 +21,7 @@ Add the localeapp gem to your `Gemfile` and install it:
21
21
  echo "gem 'localeapp'" >> Gemfile
22
22
  bundle install
23
23
 
24
- Create a project on [Locale](https://localeapp.com) and get the api key. Then run:
24
+ Create a project on [Locale](https://www.localeapp.com) and get the api key. Then run:
25
25
 
26
26
  bundle exec localeapp install <YOUR_API_KEY>
27
27
 
@@ -29,17 +29,8 @@ This will check everything looks good and create `config/initializers/localeapp.
29
29
 
30
30
  ### Rails 2.3
31
31
 
32
- Define localeapp in `config/environment.rb`:
33
-
34
- config.gem 'localeapp'
35
-
36
- Install the gem:
37
-
38
- rake gems:install
39
-
40
- Create a project on localeapp.com and get the api key. Then run:
41
-
42
- localeapp install <YOUR_API_KEY>
32
+ Rails 2.3 support has been discontinued after 1.0.2. Please use this
33
+ version at your own risk if you really want to.
43
34
 
44
35
  ### Non rails projects
45
36
 
data/bin/localeapp CHANGED
@@ -127,7 +127,7 @@ arg_name "<file>"
127
127
  command :push do |c|
128
128
  c.action do |global_options, options, args|
129
129
  if args.empty?
130
- exit_now! "localeapp push requires an file or directory to push", 1
130
+ exit_now! "localeapp push requires a file or directory to push", 1
131
131
  else
132
132
  path = args.first
133
133
  pusher = Localeapp::CLI::Push.new(global_options)
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  gem "i18n", "~> 0.4.0"
6
6
 
7
7
  platforms :jruby do
8
- gem "jruby-openssl"
8
+ gem "jruby-openssl", "~> 0.6"
9
9
  end
10
10
 
11
11
  gemspec :path => "../"
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  gem "i18n", "~> 0.5.0"
6
6
 
7
7
  platforms :jruby do
8
- gem "jruby-openssl"
8
+ gem "jruby-openssl", "~> 0.6"
9
9
  end
10
10
 
11
11
  gemspec :path => "../"
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  gem "i18n", "~> 0.6.0"
6
6
 
7
7
  platforms :jruby do
8
- gem "jruby-openssl"
8
+ gem "jruby-openssl", "~> 0.6"
9
9
  end
10
10
 
11
11
  gemspec :path => "../"
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  gem "i18n", "~> 0.7.0"
6
6
 
7
7
  platforms :jruby do
8
- gem "jruby-openssl"
8
+ gem "jruby-openssl", "~> 0.6"
9
9
  end
10
10
 
11
11
  gemspec :path => "../"
data/lib/localeapp.rb CHANGED
@@ -1,26 +1,5 @@
1
- # AUDIT: Find a better way of doing this
2
- begin
3
- require 'i18n'
4
- rescue LoadError
5
- # we're in 2.3 and we need to load rails to get the vendored i18n
6
- require 'thread' # for rubygems > 1.6.0 support
7
- require 'active_support'
8
- # This ugliness so we can load AS in the travis env
9
- @loaded_active_support = true
10
- end
11
-
12
- begin
13
- require 'i18n/core_ext/hash'
14
- rescue LoadError
15
- # This ugliness so we can load AS in the travis env
16
- # Assume that we're in rails 2.3 and AS supplies deep_merge
17
- # Load AS if we need to
18
- unless @loaded_active_support
19
- # we're in 2.3 and we need to load rails to get the vendored i18n
20
- require 'thread' # for rubygems > 1.6.0 support
21
- require 'active_support'
22
- end
23
- end
1
+ require 'i18n'
2
+ require 'i18n/core_ext/hash'
24
3
 
25
4
  require 'localeapp/i18n_shim'
26
5
  require 'localeapp/version'
@@ -65,7 +65,7 @@ module Localeapp
65
65
  localeapp_default_code = project_data['default_locale']['code']
66
66
  @output.puts "Default Locale: #{localeapp_default_code} (#{project_data['default_locale']['name']})"
67
67
  if I18n.default_locale.to_s != localeapp_default_code
68
- @output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/environment.rb (Rails 2) or config/application.rb (Rails 3)"
68
+ @output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/application.rb (Rails 3+)"
69
69
  end
70
70
  end
71
71
 
@@ -6,10 +6,6 @@ module Localeapp
6
6
 
7
7
  ActionController::Base.send(:include, Localeapp::Rails::Controller)
8
8
 
9
- if rails_version_matches? '~> 2.3' # TODO: Check previous rails versions if required
10
- require 'localeapp/rails/2_3_translation_helper_monkeypatch'
11
- end
12
-
13
9
  # match all versions between https://github.com/rails/rails/commit/d57ce232a885b21e1d6d1f9fbf60bc5908ad880d and https://github.com/rails/rails/commit/4dbce79e95e3f56a9b48992dea4531493a5008cc on all branches
14
10
  if rails_version_matches_all?('~> 4.0.10.rc1') |
15
11
  rails_version_matches_all?('~> 4.1.0.rc1', '< 4.1.10.rc1') |
@@ -2,8 +2,13 @@ module Localeapp
2
2
  module Rails
3
3
  module Controller
4
4
  def self.included(base)
5
- base.before_filter :handle_translation_updates
6
- base.after_filter :send_missing_translations
5
+ if base.respond_to? :before_action
6
+ base.before_action :handle_translation_updates
7
+ base.after_action :send_missing_translations
8
+ else
9
+ base.before_filter :handle_translation_updates
10
+ base.after_filter :send_missing_translations
11
+ end
7
12
  end
8
13
 
9
14
  def handle_translation_updates
@@ -1,5 +1,3 @@
1
- require 'rack/utils'
2
-
3
1
  require "localeapp/routes/base"
4
2
  require "localeapp/routes/projects"
5
3
  require "localeapp/routes/translations"
@@ -21,7 +21,7 @@ module Localeapp
21
21
  end
22
22
 
23
23
  def escape_key(key)
24
- Rack::Utils.escape(key).gsub(/\./, '%2E')
24
+ URI.encode_www_form_component(key).gsub(/\./, '%2E')
25
25
  end
26
26
  end
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
data/localeapp.gemspec CHANGED
@@ -20,17 +20,17 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('i18n')
24
- s.add_dependency('json')
25
- s.add_dependency('rest-client')
26
- s.add_dependency('rack')
23
+ s.add_dependency('mime-types', '~> 2.6')
24
+ s.add_dependency('i18n', '~> 0.4')
25
+ s.add_dependency('json', '~> 1.8')
26
+ s.add_dependency('rest-client', '~> 1.8')
27
27
  s.add_dependency('ya2yaml')
28
28
  s.add_dependency('gli')
29
29
 
30
30
  s.add_development_dependency('rake')
31
31
  s.add_development_dependency('rspec', '~> 3.3')
32
32
  s.add_development_dependency('yard')
33
- s.add_development_dependency('RedCloth')
33
+ s.add_development_dependency('RedCloth', '< 4.3')
34
34
  s.add_development_dependency('aruba', '~> 0.8')
35
35
  s.add_development_dependency('cucumber', '~> 2.0')
36
36
  s.add_development_dependency('fakeweb')
@@ -126,7 +126,8 @@ describe Localeapp::CLI::Install::DefaultInstaller, '#check_default_locale' do
126
126
  it "displays warning if I18n.default_locale doesn't match what's configured on localeapp.com" do
127
127
  allow(I18n).to receive(:default_locale).and_return(:es)
128
128
  installer.check_default_locale
129
- expect(output.string).to match(%r{WARNING: I18n.default_locale is es, change in config/environment.rb \(Rails 2\) or config/application.rb \(Rails 3\)})
129
+ expect(output.string)
130
+ .to match(%r{WARNING: I18n\.default_locale is es, change in config/application\.rb \(Rails 3\+\)})
130
131
  end
131
132
  end
132
133
 
@@ -7,6 +7,13 @@ class TestController
7
7
  end
8
8
  end
9
9
 
10
+ class TestActionController
11
+ def self.before_action(*options)
12
+ end
13
+ def self.after_action(*options)
14
+ end
15
+ end
16
+
10
17
  require 'localeapp/rails/controller'
11
18
 
12
19
  describe Localeapp::Rails::Controller, '#handle_translation_updates' do
@@ -143,3 +150,33 @@ describe Localeapp::Rails::Controller, '#send_missing_translations' do
143
150
  @controller.send_missing_translations
144
151
  end
145
152
  end
153
+
154
+ describe Localeapp::Rails::Controller, 'Rails 5 before_action support' do
155
+ before do
156
+ TestActionController.send(:include, Localeapp::Rails::Controller)
157
+ configuration = {
158
+ :synchronization_data_file => LocaleappSynchronizationData::setup,
159
+ :api_key => "my_key"
160
+ }
161
+ with_configuration(configuration) do
162
+ @controller = TestActionController.new
163
+ end
164
+ now = Time.now; allow(Time).to receive(:now).and_return(now)
165
+ Localeapp.configuration.environment_name = 'development'
166
+ end
167
+
168
+ context "#handle_translation_updates" do
169
+ it "calls poller.poll! when the synchronization file's polled_at has changed" do
170
+ Localeapp.poller.write_synchronization_data!(01234, 56789)
171
+ expect(Localeapp.poller).to receive(:poll!)
172
+ @controller.handle_translation_updates
173
+ end
174
+ end
175
+
176
+ context "#send_missing_translations" do
177
+ it "proceeds when configuration is enabled" do
178
+ expect(Localeapp.sender).to receive(:post_missing_translations)
179
+ @controller.send_missing_translations
180
+ end
181
+ end
182
+ end
@@ -98,6 +98,12 @@ describe Localeapp::Routes do
98
98
  expect(@routes.remove_url(:key => 'test.key')).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey")
99
99
  end
100
100
  end
101
+
102
+ it "URL encodes the key name" do
103
+ with_configuration @config do
104
+ expect(@routes.remove_url key: "some key").to include "some+key"
105
+ end
106
+ end
101
107
  end
102
108
 
103
109
  describe "#rename_endpoint(options = {})" do
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: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Dell
@@ -10,64 +10,64 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-20 00:00:00.000000000 Z
13
+ date: 2016-08-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: i18n
16
+ name: mime-types
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '2.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ! '>='
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: '2.6'
29
29
  - !ruby/object:Gem::Dependency
30
- name: json
30
+ name: i18n
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ! '>='
33
+ - - ~>
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: '0.4'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ! '>='
40
+ - - ~>
41
41
  - !ruby/object:Gem::Version
42
- version: '0'
42
+ version: '0.4'
43
43
  - !ruby/object:Gem::Dependency
44
- name: rest-client
44
+ name: json
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ! '>='
47
+ - - ~>
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: '1.8'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ! '>='
54
+ - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: '0'
56
+ version: '1.8'
57
57
  - !ruby/object:Gem::Dependency
58
- name: rack
58
+ name: rest-client
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ! '>='
61
+ - - ~>
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: '1.8'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ! '>='
68
+ - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '1.8'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: ya2yaml
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -142,16 +142,16 @@ dependencies:
142
142
  name: RedCloth
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ! '>='
145
+ - - <
146
146
  - !ruby/object:Gem::Version
147
- version: '0'
147
+ version: '4.3'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ! '>='
152
+ - - <
153
153
  - !ruby/object:Gem::Version
154
- version: '0'
154
+ version: '4.3'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: aruba
157
157
  requirement: !ruby/object:Gem::Requirement
@@ -244,7 +244,6 @@ files:
244
244
  - features/support/env.rb
245
245
  - features/support/hooks.rb
246
246
  - features/update.feature
247
- - gemfiles/i18n_0.3.gemfile
248
247
  - gemfiles/i18n_0.4.gemfile
249
248
  - gemfiles/i18n_0.5.gemfile
250
249
  - gemfiles/i18n_0.6.gemfile
@@ -270,7 +269,6 @@ files:
270
269
  - lib/localeapp/missing_translations.rb
271
270
  - lib/localeapp/poller.rb
272
271
  - lib/localeapp/rails.rb
273
- - lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb
274
272
  - lib/localeapp/rails/backport_translation_helper_fix_to_honor_raise_option.rb
275
273
  - lib/localeapp/rails/controller.rb
276
274
  - lib/localeapp/rails/flatten.rb
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "i18n", "~> 0.3.0"
6
- gem "activesupport", "~> 2.3.18"
7
-
8
- platforms :jruby do
9
- gem "jruby-openssl"
10
- end
11
-
12
- gemspec :path => "../"
@@ -1,36 +0,0 @@
1
- # We're replacing the original method with one that doesn't set the :raise option.
2
- # This means the exception handler will be called and missing translations get sent to
3
- # localeapp. It's ugly but there's no other way to do it :(
4
-
5
- module Localeapp::TranslationHelperRails23MonkeyPatch
6
- # Delegates to I18n#translate but also performs two additional functions. First, it'll catch MissingTranslationData exceptions
7
- # and turn them into inline spans that contains the missing key, such that you can see in a view what is missing where.
8
- #
9
- # Second, it'll scope the key by the current partial if the key starts with a period. So if you call translate(".foo") from the
10
- # people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo"). This makes it less repetitive
11
- # to translate many keys within the same partials and gives you a simple framework for scoping them consistently. If you don't
12
- # prepend the key with a period, nothing is converted.
13
- def translate(keys, options = {})
14
- if multiple_keys = keys.is_a?(Array)
15
- ActiveSupport::Deprecation.warn "Giving an array to translate is deprecated, please give a symbol or a string instead", caller
16
- end
17
-
18
- keys = scope_keys_by_partial(keys)
19
-
20
- translations = I18n.translate(keys, options)
21
- translations = [translations] if !multiple_keys && translations.size > 1
22
- translations = html_safe_translation_keys(keys, translations)
23
-
24
- if multiple_keys || translations.size > 1
25
- translations
26
- else
27
- translations.first
28
- end
29
- rescue I18n::MissingTranslationData => e
30
- keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
31
- content_tag('span', keys.join(', '), :class => 'translation_missing')
32
- end
33
- alias :t :translate
34
- end
35
-
36
- ActionView::Base.send(:include, ::Localeapp::TranslationHelperRails23MonkeyPatch)