Class: SgtnClient::Config
- Inherits:
-
Object
- Object
- SgtnClient::Config
- Includes:
- Observable, Singleton
- Defined in:
- lib/sgtn-client/core/config.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#cache_expiry_period ⇒ Object
Returns the value of attribute cache_expiry_period.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
- #logger ⇒ Object
-
#product_name ⇒ Object
Returns the value of attribute product_name.
- #pseudo_tag ⇒ Object
-
#source_bundle ⇒ Object
Returns the value of attribute source_bundle.
-
#translation_bundle ⇒ Object
Returns the value of attribute translation_bundle.
-
#version ⇒ Object
Returns the value of attribute version.
-
#vip_server ⇒ Object
Returns the value of attribute vip_server.
Instance Method Summary collapse
- #available_bundles ⇒ Object
- #available_components ⇒ Object
- #available_locales(component) ⇒ Object
- #loader ⇒ Object
- #update(options) ⇒ Object
Instance Attribute Details
#cache_expiry_period ⇒ Object
Returns the value of attribute cache_expiry_period.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def cache_expiry_period @cache_expiry_period end |
#log_file ⇒ Object
Returns the value of attribute log_file.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def log_file @log_file end |
#log_level ⇒ Object
Returns the value of attribute log_level.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def log_level @log_level end |
#logger ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sgtn-client/core/config.rb', line 22 def logger @logger ||= if log_file puts "create log file: '#{log_file}', level: #{log_level}" require 'logging' logger = Logging.logger(log_file, 4, 1_048_576) logger.level = log_level logger else require 'logger' Logger.new(STDOUT, level: log_level || Logger::INFO) end end |
#product_name ⇒ Object
Returns the value of attribute product_name.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def product_name @product_name end |
#pseudo_tag ⇒ Object
18 19 20 |
# File 'lib/sgtn-client/core/config.rb', line 18 def pseudo_tag @pseudo_tag ||= '@@' end |
#source_bundle ⇒ Object
Returns the value of attribute source_bundle.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def source_bundle @source_bundle end |
#translation_bundle ⇒ Object
Returns the value of attribute translation_bundle.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def translation_bundle @translation_bundle end |
#version ⇒ Object
Returns the value of attribute version.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def version @version end |
#vip_server ⇒ Object
Returns the value of attribute vip_server.
14 15 16 |
# File 'lib/sgtn-client/core/config.rb', line 14 def vip_server @vip_server end |
Instance Method Details
#available_bundles ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/sgtn-client/core/config.rb', line 39 def available_bundles loader.available_bundles rescue StandardError => e SgtnClient.logger.error 'failed to get available bundles' SgtnClient.logger.error e Set.new end |
#available_components ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/sgtn-client/core/config.rb', line 47 def available_components bundles = available_bundles return Set.new if bundles.nil? || bundles.empty? define_bundles_methods(bundles) unless bundles.respond_to?(:components) bundles.components end |
#available_locales(component) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/sgtn-client/core/config.rb', line 55 def available_locales(component) bundles = available_bundles return Set.new if bundles.nil? || bundles.empty? define_bundles_methods(bundles) unless bundles.respond_to?(:locales) bundles.locales(component) end |
#loader ⇒ Object
35 36 37 |
# File 'lib/sgtn-client/core/config.rb', line 35 def loader @loader ||= TranslationLoader::LoaderFactory.create(self) end |
#update(options) ⇒ Object
63 64 65 66 67 |
# File 'lib/sgtn-client/core/config.rb', line 63 def update() .each do |key, value| send("#{key}=", value) end end |