Skip to content

Commit

Permalink
Rename LazyLoad to LazyLoadable backend
Browse files Browse the repository at this point in the history
  • Loading branch information
paarthmadan committed Jan 28, 2022
1 parent 6756e97 commit 1a8c5ce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/backend.rb
Expand Up @@ -12,7 +12,7 @@ module Backend
autoload :Gettext, 'i18n/backend/gettext'
autoload :InterpolationCompiler, 'i18n/backend/interpolation_compiler'
autoload :KeyValue, 'i18n/backend/key_value'
autoload :LazyLoad, 'i18n/backend/lazy_load'
autoload :LazyLoadable, 'i18n/backend/lazy_loadable'
autoload :Memoize, 'i18n/backend/memoize'
autoload :Metadata, 'i18n/backend/metadata'
autoload :Pluralization, 'i18n/backend/pluralization'
Expand Down
Expand Up @@ -36,9 +36,6 @@ module Backend
#
# To backend has two working modes: lazy_load and eager_load.
#
# This is configured using I18n.lazy_loadable_backed.lazy_load
# which defaults to false.
#
# We recommend enabling this to true in test environments only.
# When the mode is set to false, the backend behaves exactly like the
# Simple backend, with an additional check that the paths being loaded
Expand All @@ -49,13 +46,11 @@ module Backend
#
# # In test environments
#
# I18n.lazy_loadable_backend.lazy_load = true
# I18n.backend = I18n::Backend::LazyLoad.new
# I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: true)
#
# # In other environments, such as Prod and CI
#
# I18n.lazy_loadable_backend.lazy_load = false # default
# I18n.backend = I18n::Backend::LazyLoad.new
# I18n.backend = I18n::Backend::LazyLoadable.new(lazy_load: false) # default
#
class LocaleExtractor
class << self
Expand All @@ -69,7 +64,7 @@ def locale_from_path(path)
end
end

class LazyLoad < Simple
class LazyLoadable < Simple
def initialize(lazy_load: false)
@lazy_load = lazy_load
end
Expand Down
8 changes: 4 additions & 4 deletions test/api/lazy_load_test.rb → test/api/lazy_loadable_test.rb
@@ -1,8 +1,8 @@
require 'test_helper'

class I18nLazyLoadBackendApiTest < I18n::TestCase
class I18nLazyLoadableBackendApiTest < I18n::TestCase
def setup
I18n.backend = I18n::Backend::LazyLoad.new
I18n.backend = I18n::Backend::LazyLoadable.new
super
end

Expand All @@ -18,7 +18,7 @@ def setup
include I18n::Tests::Localization::Time
include I18n::Tests::Localization::Procs

test "make sure we use the LazyLoad backend" do
assert_equal I18n::Backend::LazyLoad, I18n.backend.class
test "make sure we use the LazyLoadable backend" do
assert_equal I18n::Backend::LazyLoadable, I18n.backend.class
end
end
@@ -1,11 +1,11 @@
require 'test_helper'

class I18nBackendLazyLoadTest < I18n::TestCase
class I18nBackendLazyLoadableTest < I18n::TestCase
def setup
super

@lazy_mode_backend = I18n::Backend::LazyLoad.new(lazy_load: true)
@eager_mode_backend = I18n::Backend::LazyLoad.new(lazy_load: false)
@lazy_mode_backend = I18n::Backend::LazyLoadable.new(lazy_load: true)
@eager_mode_backend = I18n::Backend::LazyLoadable.new(lazy_load: false)

I18n.load_path = [File.join(locales_dir, '/en.yml'), File.join(locales_dir, '/fr.yml')]
end
Expand Down Expand Up @@ -69,7 +69,7 @@ def setup
test "lazy mode: eager_load! raises UnsupportedMethod exception" do
with_lazy_mode do
exception = assert_raises(I18n::UnsupportedMethod) { @backend.eager_load! }
assert_equal "I18n::Backend::LazyLoad does not support the #eager_load! method", exception.message
assert_equal "I18n::Backend::LazyLoadable does not support the #eager_load! method", exception.message
end
end

Expand Down
Expand Up @@ -2,9 +2,9 @@
require 'benchmark'
require 'securerandom'

class BenchmarkLazyLoadTest < I18n::TestCase
class BenchmarkLazyLoadableTest < I18n::TestCase
test "lazy load performance" do
benchmark(backend: I18n::Backend::LazyLoad.new(lazy_load: true))
benchmark(backend: I18n::Backend::LazyLoadable.new(lazy_load: true))
end

test "simple performance" do
Expand Down

0 comments on commit 1a8c5ce

Please sign in to comment.