i18n_multitenant 0.0.2 → 1.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: df671c97a3bab010dc11c20ae0843a32829be66a
4
- data.tar.gz: 4048ac20539337ae5e6f6b3210ac64d924ea3fee
2
+ SHA256:
3
+ metadata.gz: 7dbda6fcab7fa556f25c5156a8d3fff69e206e353fcaf8f8071522efeeb11b2d
4
+ data.tar.gz: 83805f25a2147d1a9d0808298053bdc84b9852c8d4e9b26883615bc069a44731
5
5
  SHA512:
6
- metadata.gz: 37764caf34088612a0764abb9a9143422712ecfdf58f17a6253ba6024acf183938998d48bb4e2a382bb1e1915b55121bfd592b619250343bf244a9d637fc7e94
7
- data.tar.gz: bbd601c72ccb03bfe84cb3687178e0abb3bfd7a510a7f5f7b8edd14c2322f1d1a55f06d51b238fc93b83d546ebb6cf82c250d92f23fc17094c586ada8d1b833f
6
+ metadata.gz: 4c6b91eccdde995714c9198b950571d04c1debf75e5da97f94b72996355bb8707fb3fb7cc9a74e1bcc21ac69bed82194ac1c2cc83a7ed1bcaeac40ab94db8b74
7
+ data.tar.gz: dfe4ba88a27514f7f213794e0f8b995724b421ca915a8e3e3726f27584aee9aabfb1b166a008b084d5a1e120b457560fcbd9a0e26ed0018d48d34864b44ec9ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## I18nMultitenant 1.0.0 (2022-02-27) ##
2
+
3
+ * Use keywords in `set` and `with_locale` to support Ruby 3. Thanks @tekin!
4
+
1
5
  ## I18nMultitenant 0.0.2 (2017-01-26) ##
2
6
 
3
7
  * Added `I18nMultitenant#with_locale`. Fixed non-Rails compatibility issue.
data/README.md CHANGED
@@ -10,9 +10,16 @@ i18n Multi-Tenant
10
10
  This gem is a small utility that provides the basic configuration to perform
11
11
  tenant-specific translations in multi-tenant apps.
12
12
 
13
+ Read more about it in the [blog announcement](https://maximomussini.com/posts/i18n-multitenant/).
14
+
13
15
  ## Setting the locale
14
16
  ```ruby
15
17
  I18nMultitenant.set(locale: :en, tenant: 'Tenant Name')
18
+
19
+ # Or:
20
+ I18nMultitenant.with_locale(locale: :en, tenant: 'Tenant Name') do
21
+ ...
22
+ end
16
23
  ```
17
24
 
18
25
  ## Locale files
@@ -47,7 +54,7 @@ you will need to sanitize the names yourself before handing them over to `set`.
47
54
  Add this line to your application's Gemfile and run `bundle install`:
48
55
 
49
56
  ```ruby
50
- gem 'i18n_multitenant'
57
+ gem 'i18n_multitenant'
51
58
  ```
52
59
 
53
60
  Or install it yourself running:
@@ -1,3 +1,3 @@
1
1
  module I18nMultitenant
2
- VERSION = '0.0.2'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -20,14 +20,14 @@ module I18nMultitenant
20
20
  #
21
21
  # I18nMultitenant.set(locale: :es)
22
22
  # => :es
23
- def self.set(options)
24
- I18n.locale = locale_for(options)
23
+ def self.set(**options)
24
+ I18n.locale = locale_for(**options)
25
25
  end
26
26
 
27
27
  # Public: Executes block using the specified locale configuration, restoring
28
28
  # it after the block is executed.
29
- def self.with_locale(options)
30
- I18n.with_locale(locale_for(options)) { yield }
29
+ def self.with_locale(**options)
30
+ I18n.with_locale(locale_for(**options)) { yield }
31
31
  end
32
32
 
33
33
  # Internal: Get the internal locale for a tenant-specific locale.
@@ -11,9 +11,10 @@ RSpec.describe I18nMultitenant do
11
11
  }
12
12
 
13
13
  describe 'set' do
14
- context 'passing an incorrect option' do
15
- When(:result) { I18nMultitenant.set(locales: [:en, :es]) }
16
- Then { expect(result).to have_failed(ArgumentError, /unknown keyword: locales/) }
14
+ it 'fails on incorrect options' do
15
+ expect {
16
+ I18nMultitenant.set(locales: [:en, :es])
17
+ }.to raise_error(ArgumentError, /unknown keyword: :locales/)
17
18
  end
18
19
 
19
20
  context 'setting only the locale' do
@@ -33,7 +34,7 @@ RSpec.describe I18nMultitenant do
33
34
 
34
35
  context 'non existing locale' do
35
36
  Given(:locale) { 'en-US' }
36
- Then { expect(result).to have_failed(I18n::InvalidLocale, /not a valid locale/) }
37
+ Then { result == Failure(I18n::InvalidLocale, /not a valid locale/) }
37
38
  end
38
39
  end
39
40
 
@@ -78,7 +79,7 @@ RSpec.describe I18nMultitenant do
78
79
  context 'non existing tenant/locale combination' do
79
80
  Given(:locale) { 'en-US' }
80
81
  Given(:tenant) { 'Enterprise' }
81
- Then { expect(result).to have_failed(I18n::InvalidLocale, /"en-US-ENTERPRISE" is not a valid locale/) }
82
+ Then { result == Failure(I18n::InvalidLocale, /"en-US-ENTERPRISE" is not a valid locale/) }
82
83
  end
83
84
  end
84
85
  end
@@ -119,7 +120,7 @@ RSpec.describe I18nMultitenant do
119
120
 
120
121
  context 'non-existing locale' do
121
122
  When(:locale) { I18n.locale = 'en-US' }
122
- Then { expect(locale).to have_failed(I18n::InvalidLocale, /not a valid locale/) }
123
+ Then { locale == Failure(I18n::InvalidLocale, /not a valid locale/) }
123
124
  end
124
125
 
125
126
  context 'locale and tenant (internal representation)' do
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'simplecov'
3
- SimpleCov.start do
4
- add_filter '/spec/'
5
- end
6
-
7
2
  require 'rspec/given'
8
- require 'pry'
3
+ require 'pry-byebug'
9
4
  require 'pathname'
10
5
  require 'i18n_multitenant'
11
6
 
@@ -1,2 +1,3 @@
1
1
  es:
2
+ app_name: I18n
2
3
  greeting: 'Bienvenido!'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_multitenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-26 00:00:00.000000000 Z
11
+ date: 2022-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -59,7 +59,7 @@ homepage: https://github.com/ElMassimo/i18n_multitenant
59
59
  licenses:
60
60
  - MIT
61
61
  metadata: {}
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options:
64
64
  - "--charset=UTF-8"
65
65
  require_paths:
@@ -75,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubyforge_project:
79
- rubygems_version: 2.5.1
80
- signing_key:
78
+ rubygems_version: 3.3.7
79
+ signing_key:
81
80
  specification_version: 4
82
81
  summary: Translation for multi-tenant applications.
83
82
  test_files: