Class: EacRubyUtils::Locales::FromGem
- Defined in:
- lib/eac_ruby_utils/locales/from_gem.rb
Constant Summary collapse
- LOCALES_DIR_SUBPATH =
'locale'
- LOCALES_FILES_GLOB_PATTERNS =
%w[*.yaml *.yml].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.include_all(i18n_obj = nil) ⇒ Object
11 12 13 |
# File 'lib/eac_ruby_utils/locales/from_gem.rb', line 11 def include_all(i18n_obj = nil) ::Gem::Specification.each { |gemspec| new(gemspec, i18n_obj).include } end |
Instance Method Details
#exist? ⇒ Boolean
24 |
# File 'lib/eac_ruby_utils/locales/from_gem.rb', line 24 delegate :exist?, to: :path |
#include ⇒ Pathname?
27 28 29 30 31 32 |
# File 'lib/eac_ruby_utils/locales/from_gem.rb', line 27 def include return nil unless exist? ::I18n.load_path += paths_to_load.map(&:to_path) path end |
#path ⇒ Pathname
35 36 37 |
# File 'lib/eac_ruby_utils/locales/from_gem.rb', line 35 def path gemspec.gem_dir.to_pathname.join(LOCALES_DIR_SUBPATH) end |
#paths_to_load ⇒ Pathname
40 41 42 43 44 |
# File 'lib/eac_ruby_utils/locales/from_gem.rb', line 40 def paths_to_load return [] unless exist? LOCALES_FILES_GLOB_PATTERNS.inject([]) { |a, e| a + path.glob(e) } end |