lazier 3.5.7 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis-gemfile +5 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +65 -8
- data/Gemfile +9 -8
- data/README.md +4 -0
- data/doc/Lazier.html +178 -110
- data/doc/Lazier/Boolean.html +7 -7
- data/doc/Lazier/Configuration.html +24 -50
- data/doc/Lazier/DateTime.html +50 -305
- data/doc/Lazier/DateTime/ClassMethods.html +116 -806
- data/doc/Lazier/Exceptions.html +2 -2
- data/doc/Lazier/Exceptions/Debug.html +1 -1
- data/doc/Lazier/Exceptions/MissingTranslation.html +18 -14
- data/doc/Lazier/Exceptions/TranslationExceptionHandler.html +213 -0
- data/doc/Lazier/Hash.html +19 -155
- data/doc/Lazier/I18n.html +1735 -230
- data/doc/Lazier/Math.html +1 -1
- data/doc/Lazier/Math/ClassMethods.html +13 -13
- data/doc/Lazier/Object.html +353 -339
- data/doc/Lazier/Pathname.html +4 -4
- data/doc/Lazier/Settings.html +150 -304
- data/doc/Lazier/String.html +39 -199
- data/doc/Lazier/TimeZone.html +244 -746
- data/doc/Lazier/TimeZone/ClassMethods.html +109 -127
- data/doc/Lazier/Version.html +4 -4
- data/doc/_index.html +15 -15
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +5 -1
- data/doc/index.html +5 -1
- data/doc/method_list.html +97 -169
- data/doc/top-level-namespace.html +1 -1
- data/lazier.gemspec +9 -6
- data/lib/lazier.rb +41 -50
- data/lib/lazier/boolean.rb +0 -1
- data/lib/lazier/configuration.rb +26 -28
- data/lib/lazier/datetime.rb +33 -127
- data/lib/lazier/exceptions.rb +14 -6
- data/lib/lazier/hash.rb +7 -15
- data/lib/lazier/i18n.rb +130 -48
- data/lib/lazier/math.rb +6 -7
- data/lib/lazier/object.rb +79 -97
- data/lib/lazier/pathname.rb +0 -1
- data/lib/lazier/settings.rb +12 -25
- data/lib/lazier/string.rb +17 -38
- data/lib/lazier/timezone.rb +168 -164
- data/lib/lazier/version.rb +3 -4
- data/locales/en.yml +52 -51
- data/locales/it.yml +51 -50
- data/spec/coverage_helper.rb +0 -1
- data/spec/lazier/boolean_spec.rb +2 -3
- data/spec/lazier/configuration_spec.rb +3 -5
- data/spec/lazier/datetime_spec.rb +34 -95
- data/spec/lazier/exceptions_spec.rb +25 -0
- data/spec/lazier/hash_spec.rb +0 -21
- data/spec/lazier/i18n_spec.rb +135 -51
- data/spec/lazier/math_spec.rb +0 -1
- data/spec/lazier/object_spec.rb +105 -100
- data/spec/lazier/pathname_spec.rb +0 -1
- data/spec/lazier/settings_spec.rb +25 -28
- data/spec/lazier/string_spec.rb +7 -20
- data/spec/lazier/timezone_spec.rb +101 -87
- data/spec/lazier_spec.rb +25 -8
- data/spec/spec_helper.rb +3 -2
- metadata +15 -44
- data/doc/Lazier/Localizer.html +0 -545
- data/lib/lazier/localizer.rb +0 -41
- data/spec/lazier/localizer_spec.rb +0 -45
data/lib/lazier/localizer.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Lazier
|
8
|
-
# A utility class to localize messages
|
9
|
-
class Localizer
|
10
|
-
include Lazier::I18n
|
11
|
-
|
12
|
-
# Initialize a new localizer.
|
13
|
-
#
|
14
|
-
# @param root [Symbol] The root level of the translation.
|
15
|
-
# @param path [String] The path where the translations are stored.
|
16
|
-
# @param locale [String|Symbol] The locale to use for localization.
|
17
|
-
def initialize(root = nil, path = nil, locale = nil)
|
18
|
-
i18n_setup(root || :lazier, path || ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/"))
|
19
|
-
self.i18n = locale
|
20
|
-
end
|
21
|
-
|
22
|
-
# Localize a message.
|
23
|
-
#
|
24
|
-
# @param message [String|Symbol] The message to localize.
|
25
|
-
# @param args [Array] Optional arguments to localize the message.
|
26
|
-
# @return [String|R18n::Untranslated] The localized message.
|
27
|
-
def self.localize(message, *args)
|
28
|
-
new.i18n.send(message, *args)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Localize a message in a specified locale.
|
32
|
-
#
|
33
|
-
# @param locale [String|Symbol] The locale to use for localization.
|
34
|
-
# @param message [String|Symbol] The message to localize.
|
35
|
-
# @param args [Array] Optional arguments to localize the message.
|
36
|
-
# @return [String|R18n::Untranslated] The localized message.
|
37
|
-
def self.localize_on_locale(locale, message, *args)
|
38
|
-
new(nil, nil, locale).i18n.send(message, *args)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
require "spec_helper"
|
8
|
-
|
9
|
-
describe Lazier::Localizer do
|
10
|
-
describe "#initialize" do
|
11
|
-
it "should call i18n_setup and then i18n=" do
|
12
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n_setup).with("ROOT", "PATH")
|
13
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n=).with(:it)
|
14
|
-
::Lazier::Localizer.new("ROOT", "PATH", :it)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should setup default arguments" do
|
18
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n_setup).with(:lazier, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/"))
|
19
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n=).with(nil)
|
20
|
-
::Lazier::Localizer.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe ".localize" do
|
25
|
-
it "should create a new localizer and forward the message" do
|
26
|
-
obj = ::Object.new
|
27
|
-
expect(obj).to receive(:string).with("ARGUMENT")
|
28
|
-
|
29
|
-
expect(::Lazier::Localizer).to receive(:new).and_call_original
|
30
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n).and_return(obj)
|
31
|
-
::Lazier::Localizer.localize(:string, "ARGUMENT")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe ".localize_on_locale" do
|
36
|
-
it "should create a new localizer and forward the message" do
|
37
|
-
obj = ::Object.new
|
38
|
-
expect(obj).to receive(:string).with("ARGUMENT")
|
39
|
-
|
40
|
-
expect(::Lazier::Localizer).to receive(:new).with(nil, nil, :it).and_call_original
|
41
|
-
expect_any_instance_of(::Lazier::Localizer).to receive(:i18n).and_return(obj)
|
42
|
-
::Lazier::Localizer.localize_on_locale(:it, :string, "ARGUMENT")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|