sinatra-r18n 2.2.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: 980560087822a104c3e8e0bd634444fc0725ac8b
4
- data.tar.gz: 14181c56941803446262a83b7105f6f9d1473f06
2
+ SHA256:
3
+ metadata.gz: 9d3c2992234343118814eef964dbc36ecc55acccc76505b2808abf4e31e3091c
4
+ data.tar.gz: 424ba607babdf58467c73bc70e8a077b050485635620e967be5d4c67c7319f48
5
5
  SHA512:
6
- metadata.gz: 077f01b3aa5e3bc591f90026629135d6932b13cad19a22e46fae16344156ef04c8457eaefb147213b51f10807b119ce086d558268141071a8ddb0caf245a1bd4
7
- data.tar.gz: ac2ad288826447161062adebcb852596ec812b133c793676d9832c30e096deec8914cce0a48ae71ac8fc06081157d80883d8a2295c1e09813df60937b43cca6a
6
+ metadata.gz: cab53364047a6d1a10153256094eda43ecdbbf1d8680e7258d876bfd1e99c7346fbfb302834e76d6d3fa014dd400deb5d87390708255d3b3d0bc129d6dd1c3d6
7
+ data.tar.gz: 0fd56d9c6a3ec7f5f2757075e9e546ef2e4255d82521ac0ce1f5ede75f963bff4cbb5ae4cec5dde292a971d3f0ce7e0653ef2302c07feff6f8bc8d872253d64e
data/.rspec CHANGED
@@ -1 +1 @@
1
- --format documentation --colour
1
+ --format documentation --colour --warnings --require spec_helper
data/README.md CHANGED
@@ -46,7 +46,7 @@ information.
46
46
  ```ruby
47
47
  class YourApp < Sinatra::Base
48
48
  register Sinatra::R18n
49
- set :root, File.dirname(__FILE__)
49
+ set :root, __dir__
50
50
  ```
51
51
 
52
52
  4. Add locale to your URLs. For example:
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
4
6
  require 'rspec/core/rake_task'
5
7
  RSpec::Core::RakeTask.new
6
- task :default => :spec
8
+ task default: :spec
7
9
 
8
10
  task :clobber_package do
9
- rm_r 'pkg' rescue nil
11
+ rm_rf 'pkg'
10
12
  end
11
- task :clobber => [:clobber_package]
13
+ task clobber: [:clobber_package]
data/lib/sinatra/r18n.rb CHANGED
@@ -1,21 +1,21 @@
1
- =begin
2
- Sinatra extension to i18n support.
3
-
4
- Copyright (C) 2009 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU Lesser General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- =end
1
+ # frozen_string_literal: true
2
+
3
+ # Sinatra extension to i18n support.
4
+ #
5
+ # Copyright (C) 2009 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  require 'sinatra/base'
21
21
  require 'r18n-core'
@@ -24,10 +24,10 @@ module Sinatra
24
24
  module R18n
25
25
  def self.registered(app)
26
26
  app.helpers ::R18n::Helpers
27
- app.set :default_locale, Proc.new { ::R18n::I18n.default }
28
- app.set :translations, Proc.new { ::R18n.default_places }
27
+ app.set :default_locale, (proc { ::R18n::I18n.default })
28
+ app.set :translations, (proc { ::R18n.default_places })
29
29
 
30
- ::R18n.default_places { File.join(app.root, 'i18n/') }
30
+ ::R18n.default_places { File.join(app.root, 'i18n') }
31
31
 
32
32
  app.before do
33
33
  ::R18n.clear_cache! if self.class.development?
@@ -44,8 +44,10 @@ module Sinatra
44
44
  locales.insert(0, session[:locale])
45
45
  end
46
46
 
47
- ::R18n::I18n.new(locales, ::R18n.default_places,
48
- off_filters: :untranslated, on_filters: :untranslated_html)
47
+ ::R18n::I18n.new(
48
+ locales, ::R18n.default_places,
49
+ off_filters: :untranslated, on_filters: :untranslated_html
50
+ )
49
51
  end
50
52
  end
51
53
  end
data/sinatra-r18n.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- require File.expand_path('../../r18n-core/lib/r18n-core/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../r18n-core/lib/r18n-core/version'
2
4
 
3
5
  Gem::Specification.new do |s|
4
6
  s.platform = Gem::Platform::RUBY
@@ -7,14 +9,14 @@ Gem::Specification.new do |s|
7
9
  s.date = Time.now.strftime('%Y-%m-%d')
8
10
 
9
11
  s.summary = 'A Sinatra extension that provides i18n support'
10
- s.description = <<-EOF
12
+ s.description = <<-DESC
11
13
  A Sinatra extension that provides i18n support to translate your web
12
14
  application. It is just a wrapper for R18n core library.
13
15
  It has nice Ruby-style syntax, filters, flexible locales, custom loaders,
14
16
  translation support for any classes, time and number localization, several
15
17
  user language support, agnostic core package with out-of-box support for
16
18
  Rails, Sinatra and desktop applications.
17
- EOF
19
+ DESC
18
20
 
19
21
  s.files = `git ls-files`.split("\n")
20
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -26,6 +28,6 @@ Gem::Specification.new do |s|
26
28
  s.homepage = 'https://github.com/ai/r18n/tree/master/sinatra-r18n'
27
29
  s.license = 'LGPL-3'
28
30
 
29
- s.add_dependency 'sinatra', ">= 1.3"
30
31
  s.add_dependency 'r18n-core', "= #{R18n::VERSION}"
32
+ s.add_dependency 'sinatra', '>= 1.3'
31
33
  end
data/spec/app/app.rb CHANGED
@@ -1,4 +1,6 @@
1
- require File.join(File.dirname(__FILE__), '../../lib/sinatra/r18n')
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../lib/sinatra/r18n'
2
4
  require 'sinatra'
3
5
 
4
6
  get '/:locale/posts/:name' do
@@ -31,5 +33,5 @@ get '/warning' do
31
33
  end
32
34
 
33
35
  get '/untranslated' do
34
- "#{t.post.no}"
36
+ t.post.no.to_s
35
37
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe Sinatra::R18n do
4
4
  before(:all) do
@@ -10,81 +10,81 @@ describe Sinatra::R18n do
10
10
  app.set :environment, :test
11
11
  end
12
12
 
13
- it "translates messages" do
13
+ it 'translates messages' do
14
14
  get '/en/posts/1'
15
15
  expect(last_response).to be_ok
16
16
  expect(last_response.body).to eq "<h1>Post 1</h1>\n"
17
17
  end
18
18
 
19
- it "uses translations from default locale" do
19
+ it 'uses translations from default locale' do
20
20
  get '/ru/posts/1/comments'
21
21
  expect(last_response).to be_ok
22
22
  expect(last_response.body).to eq '3 comments'
23
23
  end
24
24
 
25
- it "uses default locale" do
25
+ it 'uses default locale' do
26
26
  app.set :default_locale, 'ru'
27
27
  get '/locale'
28
28
  expect(last_response).to be_ok
29
29
  expect(last_response.body).to eq 'Русский'
30
30
  end
31
31
 
32
- it "autodetects user locale" do
33
- get '/locale', { }, { 'HTTP_ACCEPT_LANGUAGE' => 'ru,en;q=0.9' }
32
+ it 'autodetects user locale' do
33
+ get '/locale', {}, 'HTTP_ACCEPT_LANGUAGE' => 'ru,en;q=0.9'
34
34
  expect(last_response).to be_ok
35
35
  expect(last_response.body).to eq 'Русский'
36
36
  end
37
37
 
38
- it "uses locale from param" do
39
- get '/locale', { locale: 'ru' }
38
+ it 'uses locale from param' do
39
+ get '/locale', locale: 'ru'
40
40
  expect(last_response).to be_ok
41
41
  expect(last_response.body).to eq 'Русский'
42
42
  end
43
43
 
44
- it "ignore empty param" do
45
- get '/locale', { locale: '' }
44
+ it 'ignore empty param' do
45
+ get '/locale', locale: ''
46
46
  expect(last_response).to be_ok
47
47
  expect(last_response.body).to eq 'English'
48
48
  end
49
49
 
50
- it "uses locale from session" do
51
- get '/locale', { }, { 'rack.session' => { locale: 'ru' } }
50
+ it 'uses locale from session' do
51
+ get '/locale', {}, 'rack.session' => { locale: 'ru' }
52
52
  expect(last_response).to be_ok
53
53
  expect(last_response.body).to eq 'Русский'
54
54
  end
55
55
 
56
- it "ignore empty session" do
57
- get '/locale', { }, { 'rack.session' => { locale: '' } }
56
+ it 'ignore empty session' do
57
+ get '/locale', {}, 'rack.session' => { locale: '' }
58
58
  expect(last_response).to be_ok
59
59
  expect(last_response.body).to eq 'English'
60
60
  end
61
61
 
62
- it "ignores empty locale" do
63
- get '/locale', { }
62
+ it 'ignores empty locale' do
63
+ get '/locale', {}
64
64
  expect(last_response).to be_ok
65
65
  expect(last_response.body).to eq 'English'
66
66
  end
67
67
 
68
- it "returns locales list" do
68
+ it 'returns locales list' do
69
69
  get '/locales'
70
70
  expect(last_response).to be_ok
71
71
  expect(last_response.body).to eq 'en: English; ru: Русский'
72
72
  end
73
73
 
74
- it "formats untranslated string" do
74
+ it 'formats untranslated string' do
75
75
  get '/untranslated'
76
76
  expect(last_response).to be_ok
77
77
  expect(last_response.body).to eq 'post.<span style="color: red">[no]</span>'
78
78
  end
79
79
 
80
- it "localizes objects" do
80
+ it 'localizes objects' do
81
81
  get '/time'
82
82
  expect(last_response).to be_ok
83
- expect(last_response.body).to eq "1970-01-01 00:00"
83
+ expect(last_response.body).to eq '1970-01-01 00:00'
84
84
  end
85
85
 
86
- it "sets default places" do
87
- path = Pathname(__FILE__).dirname.expand_path.join('app/i18n/').to_s
86
+ it 'sets default places' do
87
+ path = File.join(__dir__, 'app', 'i18n')
88
88
  expect(R18n.default_places).to eq path
89
89
  R18n.set('en')
90
90
  expect(R18n.get.post.title(1)).to eq 'Post 1'
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pp'
2
4
 
3
5
  ENV['RACK_ENV'] = 'test'
4
- require File.join(File.dirname(__FILE__), 'app/app')
6
+ require_relative 'app/app'
5
7
 
6
8
  require 'rack/test'
7
9
 
8
10
  module RSpecMixinExample
9
11
  include Rack::Test::Methods
10
- def app(); Sinatra::Application; end
12
+
13
+ def app
14
+ Sinatra::Application
15
+ end
11
16
  end
12
17
 
13
18
  RSpec.configure { |c| c.include RSpecMixinExample }
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-r18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-22 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sinatra
14
+ name: r18n-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 3.0.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: '1.3'
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: r18n-core
28
+ name: sinatra
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.0
33
+ version: '1.3'
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.2.0
40
+ version: '1.3'
41
41
  description: |2
42
42
  A Sinatra extension that provides i18n support to translate your web
43
43
  application. It is just a wrapper for R18n core library.
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project:
87
- rubygems_version: 2.5.2.2
87
+ rubygems_version: 2.7.6
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: A Sinatra extension that provides i18n support