i18n-object 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +72 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/i18n-object.gemspec +28 -0
- data/lib/generators/i18n/object/USAGE +5 -0
- data/lib/generators/i18n/object/install_generator.rb +15 -0
- data/lib/generators/i18n/object/templates/initializer.tt +26 -0
- data/lib/i18n/object.rb +18 -0
- data/lib/i18n/object/config.rb +11 -0
- data/lib/i18n/object/railtie.rb +32 -0
- data/lib/i18n/object/translation_methods.rb +38 -0
- data/lib/i18n/object/version.rb +5 -0
- metadata +135 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: b5f747082d7edff8f1dcc331a1de47fa5d3d881a6d64a178d5943839a6edd574
         | 
| 4 | 
            +
              data.tar.gz: 0e3174d2bd7597cc5694ea2adcfa1eef225d8751522736c21aee6ab139b5de96
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: b6c99af1ead5e26aa02fff24f71bf2ed7b49dfff032ea7376699a6ec5d774deabedd3d1b9454e1cc611d1753512354f89007dca201b7dad08afad40823fbbda2
         | 
| 7 | 
            +
              data.tar.gz: 3245f17013fc0b8932b6069d32635cf455d07aa07c440e039cd10e250aa1cb610bb4cb61bc0e2089407e1cbb1202d76a1b53080d78b4253ada94768846885b3c
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                i18n-object (0.1.0)
         | 
| 5 | 
            +
                  activesupport (>= 5.0)
         | 
| 6 | 
            +
                  i18n
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            GEM
         | 
| 9 | 
            +
              remote: https://rubygems.org/
         | 
| 10 | 
            +
              specs:
         | 
| 11 | 
            +
                activesupport (5.2.3)
         | 
| 12 | 
            +
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         | 
| 13 | 
            +
                  i18n (>= 0.7, < 2)
         | 
| 14 | 
            +
                  minitest (~> 5.1)
         | 
| 15 | 
            +
                  tzinfo (~> 1.1)
         | 
| 16 | 
            +
                ast (2.4.0)
         | 
| 17 | 
            +
                concurrent-ruby (1.1.5)
         | 
| 18 | 
            +
                diff-lcs (1.3)
         | 
| 19 | 
            +
                i18n (1.6.0)
         | 
| 20 | 
            +
                  concurrent-ruby (~> 1.0)
         | 
| 21 | 
            +
                jaro_winkler (1.5.2)
         | 
| 22 | 
            +
                minitest (5.11.3)
         | 
| 23 | 
            +
                onkcop (0.53.0.3)
         | 
| 24 | 
            +
                  rubocop (>= 0.53.0)
         | 
| 25 | 
            +
                  rubocop-rspec (>= 1.24.0)
         | 
| 26 | 
            +
                parallel (1.17.0)
         | 
| 27 | 
            +
                parser (2.6.2.1)
         | 
| 28 | 
            +
                  ast (~> 2.4.0)
         | 
| 29 | 
            +
                psych (3.1.0)
         | 
| 30 | 
            +
                rainbow (3.0.0)
         | 
| 31 | 
            +
                rake (10.5.0)
         | 
| 32 | 
            +
                rspec (3.8.0)
         | 
| 33 | 
            +
                  rspec-core (~> 3.8.0)
         | 
| 34 | 
            +
                  rspec-expectations (~> 3.8.0)
         | 
| 35 | 
            +
                  rspec-mocks (~> 3.8.0)
         | 
| 36 | 
            +
                rspec-core (3.8.0)
         | 
| 37 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 38 | 
            +
                rspec-expectations (3.8.3)
         | 
| 39 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 40 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 41 | 
            +
                rspec-mocks (3.8.0)
         | 
| 42 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 43 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 44 | 
            +
                rspec-support (3.8.0)
         | 
| 45 | 
            +
                rubocop (0.67.2)
         | 
| 46 | 
            +
                  jaro_winkler (~> 1.5.1)
         | 
| 47 | 
            +
                  parallel (~> 1.10)
         | 
| 48 | 
            +
                  parser (>= 2.5, != 2.5.1.1)
         | 
| 49 | 
            +
                  psych (>= 3.1.0)
         | 
| 50 | 
            +
                  rainbow (>= 2.2.2, < 4.0)
         | 
| 51 | 
            +
                  ruby-progressbar (~> 1.7)
         | 
| 52 | 
            +
                  unicode-display_width (>= 1.4.0, < 1.6)
         | 
| 53 | 
            +
                rubocop-rspec (1.32.0)
         | 
| 54 | 
            +
                  rubocop (>= 0.60.0)
         | 
| 55 | 
            +
                ruby-progressbar (1.10.0)
         | 
| 56 | 
            +
                thread_safe (0.3.6)
         | 
| 57 | 
            +
                tzinfo (1.2.5)
         | 
| 58 | 
            +
                  thread_safe (~> 0.1)
         | 
| 59 | 
            +
                unicode-display_width (1.5.0)
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            PLATFORMS
         | 
| 62 | 
            +
              ruby
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            DEPENDENCIES
         | 
| 65 | 
            +
              bundler (~> 2.0)
         | 
| 66 | 
            +
              i18n-object!
         | 
| 67 | 
            +
              onkcop
         | 
| 68 | 
            +
              rake (~> 10.0)
         | 
| 69 | 
            +
              rspec (~> 3.0)
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            BUNDLED WITH
         | 
| 72 | 
            +
               2.0.1
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2019 Yoshiyuki Hirano
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,94 @@ | |
| 1 | 
            +
            # I18n::Object
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            `I18n::Object` provides you can use wrapper classes for easy handling/testing of I18n by just only configuration.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## The Value of I18n::Object
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            This gem resolves these problems:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - It's not a easy to deal with deep nested YAML files from both product and test codes.
         | 
| 10 | 
            +
            - We need wrapper class for easy handling/testing of `I18n#translate` to **avoid TYPOs and translation missings**!!
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            This `i18n-object` provides you can get to use wrapper classes just only assign namespaces in the initializer file:
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ```ruby
         | 
| 15 | 
            +
            # config/initializers/i18n_object.rb
         | 
| 16 | 
            +
            I18n::Object.namespaces = %w[
         | 
| 17 | 
            +
              notification
         | 
| 18 | 
            +
              slack_notificaiton/admin
         | 
| 19 | 
            +
              slack_notificaiton/consumer
         | 
| 20 | 
            +
            ]
         | 
| 21 | 
            +
            ```
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            And you have to define YAML files on `config/locales` like this:
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ```yaml
         | 
| 26 | 
            +
            en:
         | 
| 27 | 
            +
              notification:
         | 
| 28 | 
            +
                say: Hi, %{name}!
         | 
| 29 | 
            +
              slack_notification:
         | 
| 30 | 
            +
                admin:
         | 
| 31 | 
            +
                  say: Hi, admin!
         | 
| 32 | 
            +
                consumer:
         | 
| 33 | 
            +
                  say: Hi, consumer!
         | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Then you can use wrapper classes:
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            ```ruby
         | 
| 39 | 
            +
            Notificaiton.say(name: 'alice') # Hi, alice!
         | 
| 40 | 
            +
            SlackNotification::Admin.say # Hi, admin!
         | 
| 41 | 
            +
            SlackNotification::Consumer.say # Hi, consumer!
         | 
| 42 | 
            +
            Notification.hello # No Method Error
         | 
| 43 | 
            +
            ```
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            Finally you can get relief from **pain of TYPOs and translation missings**.
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            ## Installation
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            1. Add `i18n-object` to your `Gemfile`:
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            ```ruby
         | 
| 52 | 
            +
            gem 'i18n-object'
         | 
| 53 | 
            +
            ```
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            2. Execute this command to generate an initializer:
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            ```
         | 
| 58 | 
            +
            $ bin/rails generate i18n:object:install
         | 
| 59 | 
            +
            ```
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            3. Assign namespaces and prepare locale files:
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            ```ruby
         | 
| 64 | 
            +
            # Assign I18n Object names:
         | 
| 65 | 
            +
            #
         | 
| 66 | 
            +
            # e.g.)
         | 
| 67 | 
            +
            #
         | 
| 68 | 
            +
            # I18n::Object.namespaces = %w[
         | 
| 69 | 
            +
            #   notification
         | 
| 70 | 
            +
            #   slack_notificaiton/admin
         | 
| 71 | 
            +
            #   slack_notificaiton/consumer
         | 
| 72 | 
            +
            # ]
         | 
| 73 | 
            +
            #
         | 
| 74 | 
            +
            # en:
         | 
| 75 | 
            +
            #   notification:
         | 
| 76 | 
            +
            #     say: Hi, %{name}!
         | 
| 77 | 
            +
            #   slack_notification:
         | 
| 78 | 
            +
            #     admin:
         | 
| 79 | 
            +
            #       say: Hi, admin!
         | 
| 80 | 
            +
            #     consumer:
         | 
| 81 | 
            +
            #       say: Hi, consumer!
         | 
| 82 | 
            +
            #
         | 
| 83 | 
            +
            # Notificaiton.say(name: 'alice') # Hi, alice!
         | 
| 84 | 
            +
            # Notification.hello # NoMethodError
         | 
| 85 | 
            +
            # SlackNotification::Admin.say # Hi, admin!
         | 
| 86 | 
            +
            # SlackNotification::Consumer.say # Hi, consumer!
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            I18n::Object.namespaces = %w[
         | 
| 89 | 
            +
            ]
         | 
| 90 | 
            +
            ```
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            ## License
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "i18n/object"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start(__FILE__)
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/i18n-object.gemspec
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            lib = File.expand_path("./lib", __dir__)
         | 
| 2 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 3 | 
            +
            require "i18n/object/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name          = "i18n-object"
         | 
| 7 | 
            +
              s.version       = I18n::Object::VERSION
         | 
| 8 | 
            +
              s.authors       = ["Yoshiyuki Hirano"]
         | 
| 9 | 
            +
              s.email         = ["yhirano@me.com"]
         | 
| 10 | 
            +
              s.homepage      = "https://github.com/yhirano55/i18n-object"
         | 
| 11 | 
            +
              s.summary       = "I18n::Object provides you can get to use wrapper classes for easy handling/testing of I18n by just only configuration."
         | 
| 12 | 
            +
              s.description   = s.summary
         | 
| 13 | 
            +
              s.license       = "MIT"
         | 
| 14 | 
            +
              s.files         = Dir.chdir(File.expand_path(".", __dir__)) do
         | 
| 15 | 
            +
                `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              s.bindir        = "exe"
         | 
| 18 | 
            +
              s.executables   = s.files.grep(%r{^exe/}) {|f| File.basename(f) }
         | 
| 19 | 
            +
              s.require_paths = ["lib"]
         | 
| 20 | 
            +
              s.required_ruby_version = ">= 2.5.0"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              s.add_dependency "activesupport", ">= 5.0"
         | 
| 23 | 
            +
              s.add_dependency "i18n"
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              s.add_development_dependency "bundler", "~> 2.0"
         | 
| 26 | 
            +
              s.add_development_dependency "rake", "~> 10.0"
         | 
| 27 | 
            +
              s.add_development_dependency "rspec", "~> 3.0"
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require "rails/generators/migration"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module I18n
         | 
| 4 | 
            +
              module Object
         | 
| 5 | 
            +
                module Generators
         | 
| 6 | 
            +
                  class InstallGenerator < ::Rails::Generators::Base
         | 
| 7 | 
            +
                    source_root File.expand_path("./templates", __dir__)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    def copy_file_for_initializer
         | 
| 10 | 
            +
                      copy_file "initializer.tt", "config/initializers/i18n_object.rb"
         | 
| 11 | 
            +
                    end
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # Assign I18n Object names:
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # e.g.)
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # I18n::Object.namespaces = %w[
         | 
| 6 | 
            +
            #   notification
         | 
| 7 | 
            +
            #   slack_notificaiton/admin
         | 
| 8 | 
            +
            #   slack_notificaiton/consumer
         | 
| 9 | 
            +
            # ]
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # en:
         | 
| 12 | 
            +
            #   notification:
         | 
| 13 | 
            +
            #     say: Hi, %{name}!
         | 
| 14 | 
            +
            #   slack_notification:
         | 
| 15 | 
            +
            #     admin:
         | 
| 16 | 
            +
            #       say: Hi, admin!
         | 
| 17 | 
            +
            #     consumer:
         | 
| 18 | 
            +
            #       say: Hi, consumer!
         | 
| 19 | 
            +
            #
         | 
| 20 | 
            +
            # Notificaiton.say(name: 'alice') # Hi, alice!
         | 
| 21 | 
            +
            # Notification.hello # NoMethodError
         | 
| 22 | 
            +
            # SlackNotification::Admin.say # Hi, admin!
         | 
| 23 | 
            +
            # SlackNotification::Consumer.say # Hi, consumer!
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            I18n::Object.namespaces = %w[
         | 
| 26 | 
            +
            ]
         | 
    
        data/lib/i18n/object.rb
    ADDED
    
    | @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require "i18n/object/version"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            begin
         | 
| 4 | 
            +
              require "rails"
         | 
| 5 | 
            +
              require_relative "object/railtie"
         | 
| 6 | 
            +
            rescue LoadError
         | 
| 7 | 
            +
              nil
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            require "i18n"
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            module I18n
         | 
| 13 | 
            +
              module Object
         | 
| 14 | 
            +
                class << self
         | 
| 15 | 
            +
                  attr_accessor :namespaces
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            require "active_support/core_ext/string/inflections"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module I18n
         | 
| 4 | 
            +
              module Object
         | 
| 5 | 
            +
                class Railtie < ::Rails::Railtie
         | 
| 6 | 
            +
                  initializer "i18n-object.configs" do
         | 
| 7 | 
            +
                    config.after_initialize do
         | 
| 8 | 
            +
                      require "i18n/object/translation_methods"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      ::I18n::Object.namespaces.each do |namespace|
         | 
| 11 | 
            +
                        class_name = namespace.classify
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                        parent_object = ::Object
         | 
| 14 | 
            +
                        target_object = nil
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                        class_name.split("::").each do |const_name|
         | 
| 17 | 
            +
                          parent_object = if parent_object.const_defined?(const_name)
         | 
| 18 | 
            +
                                            parent_object.const_get(const_name)
         | 
| 19 | 
            +
                                          else
         | 
| 20 | 
            +
                                            parent_object.const_set(const_name, ::Class.new)
         | 
| 21 | 
            +
                                          end
         | 
| 22 | 
            +
                          target_object = parent_object
         | 
| 23 | 
            +
                        end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                        target_object.include ::I18n::Object::TranslationMethods
         | 
| 26 | 
            +
                        target_object.scope = class_name.underscore.split("/").freeze
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
                    end
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            require "active_support/core_ext/string/inflections"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module I18n
         | 
| 4 | 
            +
              module Object
         | 
| 5 | 
            +
                module TranslationMethods
         | 
| 6 | 
            +
                  def self.included(klass)
         | 
| 7 | 
            +
                    klass.extend ClassMethods
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  module ClassMethods
         | 
| 11 | 
            +
                    def scope
         | 
| 12 | 
            +
                      @scope
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def scope=(value)
         | 
| 16 | 
            +
                      @scope = value
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    private
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                      def respond_to_missing?(method_name, *args)
         | 
| 22 | 
            +
                        !!translate(method_name, args) || super
         | 
| 23 | 
            +
                      end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                      def method_missing(method_name, *args, &block)
         | 
| 26 | 
            +
                        translate(method_name, args) || super
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                      def translate(method_name, args)
         | 
| 30 | 
            +
                        options = args.first || {}
         | 
| 31 | 
            +
                        ::I18n.t!(method_name, **options.merge(scope: scope))
         | 
| 32 | 
            +
                      rescue ::I18n::MissingTranslationData
         | 
| 33 | 
            +
                        nil
         | 
| 34 | 
            +
                      end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,135 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: i18n-object
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Yoshiyuki Hirano
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2019-04-28 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: activesupport
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '5.0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '5.0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: i18n
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: bundler
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '2.0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '2.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rake
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '10.0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '10.0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rspec
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '3.0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '3.0'
         | 
| 83 | 
            +
            description: I18n::Object provides you can get to use wrapper classes for easy handling/testing
         | 
| 84 | 
            +
              of I18n by just only configuration.
         | 
| 85 | 
            +
            email:
         | 
| 86 | 
            +
            - yhirano@me.com
         | 
| 87 | 
            +
            executables: []
         | 
| 88 | 
            +
            extensions: []
         | 
| 89 | 
            +
            extra_rdoc_files: []
         | 
| 90 | 
            +
            files:
         | 
| 91 | 
            +
            - ".gitignore"
         | 
| 92 | 
            +
            - ".rspec"
         | 
| 93 | 
            +
            - ".rubocop.yml"
         | 
| 94 | 
            +
            - ".travis.yml"
         | 
| 95 | 
            +
            - Gemfile
         | 
| 96 | 
            +
            - Gemfile.lock
         | 
| 97 | 
            +
            - LICENSE.txt
         | 
| 98 | 
            +
            - README.md
         | 
| 99 | 
            +
            - Rakefile
         | 
| 100 | 
            +
            - bin/console
         | 
| 101 | 
            +
            - bin/setup
         | 
| 102 | 
            +
            - i18n-object.gemspec
         | 
| 103 | 
            +
            - lib/generators/i18n/object/USAGE
         | 
| 104 | 
            +
            - lib/generators/i18n/object/install_generator.rb
         | 
| 105 | 
            +
            - lib/generators/i18n/object/templates/initializer.tt
         | 
| 106 | 
            +
            - lib/i18n/object.rb
         | 
| 107 | 
            +
            - lib/i18n/object/config.rb
         | 
| 108 | 
            +
            - lib/i18n/object/railtie.rb
         | 
| 109 | 
            +
            - lib/i18n/object/translation_methods.rb
         | 
| 110 | 
            +
            - lib/i18n/object/version.rb
         | 
| 111 | 
            +
            homepage: https://github.com/yhirano55/i18n-object
         | 
| 112 | 
            +
            licenses:
         | 
| 113 | 
            +
            - MIT
         | 
| 114 | 
            +
            metadata: {}
         | 
| 115 | 
            +
            post_install_message: 
         | 
| 116 | 
            +
            rdoc_options: []
         | 
| 117 | 
            +
            require_paths:
         | 
| 118 | 
            +
            - lib
         | 
| 119 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 120 | 
            +
              requirements:
         | 
| 121 | 
            +
              - - ">="
         | 
| 122 | 
            +
                - !ruby/object:Gem::Version
         | 
| 123 | 
            +
                  version: 2.5.0
         | 
| 124 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 125 | 
            +
              requirements:
         | 
| 126 | 
            +
              - - ">="
         | 
| 127 | 
            +
                - !ruby/object:Gem::Version
         | 
| 128 | 
            +
                  version: '0'
         | 
| 129 | 
            +
            requirements: []
         | 
| 130 | 
            +
            rubygems_version: 3.0.3
         | 
| 131 | 
            +
            signing_key: 
         | 
| 132 | 
            +
            specification_version: 4
         | 
| 133 | 
            +
            summary: I18n::Object provides you can get to use wrapper classes for easy handling/testing
         | 
| 134 | 
            +
              of I18n by just only configuration.
         | 
| 135 | 
            +
            test_files: []
         |