module Translatomatic::Config::Options
A collection of all translatomatic options available
Public Class Methods
check_valid_key(key)
click to toggle source
Test if key is a recognised configuration option name. Raise an exception if it isn't @param key [Symbol] Option
name
# File lib/translatomatic/config/options.rb, line 28 def check_valid_key(key) key = key ? key.to_sym : nil raise t('config.invalid_key', key: key) unless valid_key?(key) key end
option(key)
click to toggle source
@param key [Symbol] Option
name @return [Translatomatic::Option] The specified option
# File lib/translatomatic/config/options.rb, line 20 def option(key) check_valid_key(key) options[key.to_sym] end
options()
click to toggle source
@return [Hash<String,Translatomatic::Option>] options
# File lib/translatomatic/config/options.rb, line 7 def options @config_options ||= begin # create mapping from option name to option object map = {} config_sources.each do |source| map.merge!(source_options(source)) end map end end
valid_key?(key)
click to toggle source
@return [Boolean] True if key is a recognised configuration option
# File lib/translatomatic/config/options.rb, line 35 def valid_key?(key) options.include?(key.to_sym) end
Private Class Methods
config_sources()
click to toggle source
# File lib/translatomatic/config/options.rb, line 43 def config_sources [ Translatomatic::CLI::CommonOptions, Translatomatic::CLI::Translate, Translatomatic::CLI::Config, Translatomatic::Provider.types, Translatomatic::ResourceFile.types, Translatomatic::Database, Translatomatic::Converter, Translatomatic::FileTranslator ].freeze end
source_options(source)
click to toggle source
# File lib/translatomatic/config/options.rb, line 56 def source_options(source) map = {} source_options = Translatomatic::Option.options_from_object(source) source_options.each do |sopt| optname = sopt.name.to_sym map[optname] = sopt end map end