Sha256: fad3b393c7fd5d596c16e2ee2ea812d0d0632769f51ccfe8c54038dc66159b4d

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

require 'metasploit/model/configuration/child'

# Defines methods for adding paths to `I18n.load_path`
class Metasploit::Model::Configuration::I18n < Metasploit::Model::Configuration::Child
  #
  # Attributes
  #

  # @!attribute [rw] relative_directories
  #   Paths relative to root that point to directories that contain locale files like `en.yml`.
  #
  #   @return [Array<String>] Defaults to ['config/locales']

  # Absolute paths to directories under which to find I18n .yml files.
  #
  # @return [Array<String>]
  def directories
    @directories ||= relative_directories.collect { |relative_path|
      configuration.root.join(relative_path).to_path
    }
  end

  # Absolute paths to I18n .yml files.
  #
  # @return [Array<String>]
  def paths
    @paths ||= directories.flat_map { |directory|
      glob = File.join(directory, '*.yml')
      Dir.glob(glob)
    }
  end

  # Relative paths to I18n directories.
  #
  # @return [Array<String>] Defaults to 'config/locales'
  def relative_directories
    @relative_directories ||= [
        File.join('config', 'locales')
    ]
  end

  attr_writer :relative_directories

  # Adds {#paths} to `I18n.load_path` if they are not already there.
  #
  # @return [void]
  def setup
    paths.each do |path|
      unless ::I18n.load_path.include? path
        ::I18n.load_path << path
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
metasploit-model-0.27.0.pre.dep.pre.railties lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.26.1-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.26.1 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.7 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.7-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.6 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.6-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.3 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.3-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.2 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.2-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.1 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.1-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.1.pre.metasploit.pre.model.pre.search.pre.operator.pre.and.pre.operation.pre.groups-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.25.1.pre.metasploit.pre.model.pre.search.pre.operator.pre.and.pre.operation.pre.groups lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.24.1-java lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.24.1 lib/metasploit/model/configuration/i18n.rb
metasploit-model-0.24.1.pre.semantic.pre.versioning.pre.2.pre.0 lib/metasploit/model/configuration/i18n.rb