i18n-js 3.8.0 → 3.8.1

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.
data/i18njs.png ADDED
Binary file
data/lib/i18n/js.rb CHANGED
@@ -4,6 +4,7 @@ require "i18n"
4
4
 
5
5
  require "i18n/js/utils"
6
6
  require "i18n/js/private/hash_with_symbol_keys"
7
+ require "i18n/js/private/config_store"
7
8
 
8
9
  module I18n
9
10
  module JS
@@ -26,6 +27,8 @@ module I18n
26
27
 
27
28
  def self.config_file_path=(new_path)
28
29
  @config_file_path = new_path
30
+ # new config file path = need to re-read config from new file
31
+ Private::ConfigStore.instance.flush_cache
29
32
  end
30
33
 
31
34
  # Allow using a different backend than the one globally configured
@@ -108,14 +111,16 @@ module I18n
108
111
  # Load configuration file for partial exporting and
109
112
  # custom output directory
110
113
  def self.config
111
- if config_file_exists?
112
- erb_result_from_yaml_file = ERB.new(File.read(config_file_path)).result
113
- Private::HashWithSymbolKeys.new(
114
- (::YAML.load(erb_result_from_yaml_file) || {})
115
- )
116
- else
117
- Private::HashWithSymbolKeys.new({})
118
- end.freeze
114
+ Private::ConfigStore.instance.fetch do
115
+ if config_file_exists?
116
+ erb_result_from_yaml_file = ERB.new(File.read(config_file_path)).result
117
+ Private::HashWithSymbolKeys.new(
118
+ (::YAML.load(erb_result_from_yaml_file) || {})
119
+ )
120
+ else
121
+ Private::HashWithSymbolKeys.new({})
122
+ end.freeze
123
+ end
119
124
  end
120
125
 
121
126
  # @api private
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "singleton"
4
+
5
+ module I18n
6
+ module JS
7
+ # @api private
8
+ module Private
9
+ # Caching implementation for I18n::JS.config
10
+ #
11
+ # @api private
12
+ class ConfigStore
13
+ include Singleton
14
+
15
+ def fetch
16
+ return @config if @config
17
+
18
+ yield.tap do |obj|
19
+ raise AugumentError, "unexpected falsy object from block" unless obj
20
+
21
+ @config = obj
22
+ end
23
+ end
24
+
25
+ def flush_cache
26
+ @config = nil
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module JS
5
- VERSION = "3.8.0"
5
+ VERSION = "3.8.1"
6
6
  end
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -64,6 +64,7 @@ RSpec.configure do |config|
64
64
 
65
65
  config.after do
66
66
  FileUtils.rm_rf(temp_path)
67
+ I18n::JS::Private::ConfigStore.instance.flush_cache
67
68
  end
68
69
 
69
70
  config.include Helpers
data/yarn.lock CHANGED
@@ -91,8 +91,8 @@ jasmine-reporters@~1.0.0:
91
91
  mkdirp "~0.3.5"
92
92
 
93
93
  lodash@~4.17.10:
94
- version "4.17.10"
95
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
94
+ version "4.17.20"
95
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
96
96
 
97
97
  minimatch@^3.0.4, minimatch@~3.0.2:
98
98
  version "3.0.4"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2021-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -102,9 +102,10 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".editorconfig"
105
+ - ".github/FUNDING.yml"
106
+ - ".github/workflows/tests.yaml"
105
107
  - ".gitignore"
106
108
  - ".npmignore"
107
- - ".travis.yml"
108
109
  - Appraisals
109
110
  - CHANGELOG.md
110
111
  - Gemfile
@@ -128,6 +129,7 @@ files:
128
129
  - gemfiles/i18n_1_7.gemfile
129
130
  - gemfiles/i18n_1_8.gemfile
130
131
  - i18n-js.gemspec
132
+ - i18njs.png
131
133
  - lib/i18n-js.rb
132
134
  - lib/i18n/js.rb
133
135
  - lib/i18n/js/dependencies.rb
@@ -137,6 +139,7 @@ files:
137
139
  - lib/i18n/js/formatters/js.rb
138
140
  - lib/i18n/js/formatters/json.rb
139
141
  - lib/i18n/js/middleware.rb
142
+ - lib/i18n/js/private/config_store.rb
140
143
  - lib/i18n/js/private/hash_with_symbol_keys.rb
141
144
  - lib/i18n/js/segment.rb
142
145
  - lib/i18n/js/utils.rb
@@ -223,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
226
  - !ruby/object:Gem::Version
224
227
  version: '0'
225
228
  requirements: []
226
- rubygems_version: 3.1.4
229
+ rubygems_version: 3.2.11
227
230
  signing_key:
228
231
  specification_version: 4
229
232
  summary: It's a small library to provide the Rails I18n translations on the Javascript.
data/.travis.yml DELETED
@@ -1,39 +0,0 @@
1
- # Send builds to container-based infrastructure
2
- # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
3
- sudo: false
4
- language: ruby
5
- cache:
6
- bundler: true
7
- yarn: true
8
- directories:
9
- - node_modules
10
- rvm:
11
- - 2.3
12
- - 2.4
13
- - 2.5
14
- - 2.6
15
- - 2.7
16
- - ruby-head
17
- before_install:
18
- # Needed to test JS
19
- - yarn install
20
- gemfile:
21
- - gemfiles/i18n_0_6.gemfile
22
- - gemfiles/i18n_0_7.gemfile
23
- - gemfiles/i18n_0_8.gemfile
24
- - gemfiles/i18n_0_9.gemfile
25
- - gemfiles/i18n_1_0.gemfile
26
- - gemfiles/i18n_1_1.gemfile
27
- - gemfiles/i18n_1_2.gemfile
28
- - gemfiles/i18n_1_3.gemfile
29
- - gemfiles/i18n_1_4.gemfile
30
- - gemfiles/i18n_1_5.gemfile
31
- - gemfiles/i18n_1_6.gemfile
32
- - gemfiles/i18n_1_7.gemfile
33
- - gemfiles/i18n_1_8.gemfile
34
- matrix:
35
- fast_finish: true
36
- allow_failures:
37
- - rvm: ruby-head
38
- notifications:
39
- webhooks: https://www.travisbuddy.com/?insertMode=update