lazier 3.5.7 → 4.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.travis-gemfile +5 -4
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +65 -8
  5. data/Gemfile +9 -8
  6. data/README.md +4 -0
  7. data/doc/Lazier.html +178 -110
  8. data/doc/Lazier/Boolean.html +7 -7
  9. data/doc/Lazier/Configuration.html +24 -50
  10. data/doc/Lazier/DateTime.html +50 -305
  11. data/doc/Lazier/DateTime/ClassMethods.html +116 -806
  12. data/doc/Lazier/Exceptions.html +2 -2
  13. data/doc/Lazier/Exceptions/Debug.html +1 -1
  14. data/doc/Lazier/Exceptions/MissingTranslation.html +18 -14
  15. data/doc/Lazier/Exceptions/TranslationExceptionHandler.html +213 -0
  16. data/doc/Lazier/Hash.html +19 -155
  17. data/doc/Lazier/I18n.html +1735 -230
  18. data/doc/Lazier/Math.html +1 -1
  19. data/doc/Lazier/Math/ClassMethods.html +13 -13
  20. data/doc/Lazier/Object.html +353 -339
  21. data/doc/Lazier/Pathname.html +4 -4
  22. data/doc/Lazier/Settings.html +150 -304
  23. data/doc/Lazier/String.html +39 -199
  24. data/doc/Lazier/TimeZone.html +244 -746
  25. data/doc/Lazier/TimeZone/ClassMethods.html +109 -127
  26. data/doc/Lazier/Version.html +4 -4
  27. data/doc/_index.html +15 -15
  28. data/doc/class_list.html +1 -1
  29. data/doc/file.README.html +5 -1
  30. data/doc/index.html +5 -1
  31. data/doc/method_list.html +97 -169
  32. data/doc/top-level-namespace.html +1 -1
  33. data/lazier.gemspec +9 -6
  34. data/lib/lazier.rb +41 -50
  35. data/lib/lazier/boolean.rb +0 -1
  36. data/lib/lazier/configuration.rb +26 -28
  37. data/lib/lazier/datetime.rb +33 -127
  38. data/lib/lazier/exceptions.rb +14 -6
  39. data/lib/lazier/hash.rb +7 -15
  40. data/lib/lazier/i18n.rb +130 -48
  41. data/lib/lazier/math.rb +6 -7
  42. data/lib/lazier/object.rb +79 -97
  43. data/lib/lazier/pathname.rb +0 -1
  44. data/lib/lazier/settings.rb +12 -25
  45. data/lib/lazier/string.rb +17 -38
  46. data/lib/lazier/timezone.rb +168 -164
  47. data/lib/lazier/version.rb +3 -4
  48. data/locales/en.yml +52 -51
  49. data/locales/it.yml +51 -50
  50. data/spec/coverage_helper.rb +0 -1
  51. data/spec/lazier/boolean_spec.rb +2 -3
  52. data/spec/lazier/configuration_spec.rb +3 -5
  53. data/spec/lazier/datetime_spec.rb +34 -95
  54. data/spec/lazier/exceptions_spec.rb +25 -0
  55. data/spec/lazier/hash_spec.rb +0 -21
  56. data/spec/lazier/i18n_spec.rb +135 -51
  57. data/spec/lazier/math_spec.rb +0 -1
  58. data/spec/lazier/object_spec.rb +105 -100
  59. data/spec/lazier/pathname_spec.rb +0 -1
  60. data/spec/lazier/settings_spec.rb +25 -28
  61. data/spec/lazier/string_spec.rb +7 -20
  62. data/spec/lazier/timezone_spec.rb +101 -87
  63. data/spec/lazier_spec.rb +25 -8
  64. data/spec/spec_helper.rb +3 -2
  65. metadata +15 -44
  66. data/doc/Lazier/Localizer.html +0 -545
  67. data/lib/lazier/localizer.rb +0 -41
  68. data/spec/lazier/localizer_spec.rb +0 -45
@@ -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