Class: SgtnClient::Source
- Inherits:
-
Object
- Object
- SgtnClient::Source
- Defined in:
- lib/sgtn-client/api/source.rb
Class Method Summary collapse
- .getSource(component, key, locale) ⇒ Object
- .getSources(component, locale) ⇒ Object
- .loadBundles(locale) ⇒ Object
Class Method Details
.getSource(component, key, locale) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sgtn-client/api/source.rb', line 10 def self.getSource(component, key, locale) cache_key = SgtnClient::CacheUtil.get_cachekey(component, locale) items = SgtnClient::CacheUtil.get_cache(cache_key) if items.nil? items = getBundle(component, locale) SgtnClient.logger.debug "Putting sources items into cache with key: " + cache_key SgtnClient::CacheUtil.write_cache(cache_key, items) else SgtnClient.logger.debug "Getting sources from cache with key: " + cache_key end if items.nil? return key end str = items[locale][key] return str end |
.getSources(component, locale) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sgtn-client/api/source.rb', line 27 def self.getSources(component, locale) cache_key = SgtnClient::CacheUtil.get_cachekey(component, locale) items = SgtnClient::CacheUtil.get_cache(cache_key) if items.nil? items = getBundle(component, locale) SgtnClient.logger.debug "Putting sources items into cache with key: " + cache_key SgtnClient::CacheUtil.write_cache(cache_key, items) else SgtnClient.logger.debug "Getting sources from cache with key: " + cache_key end return items end |
.loadBundles(locale) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sgtn-client/api/source.rb', line 40 def self.loadBundles(locale) env = SgtnClient::Config.default_environment SgtnClient::Config.configurations.default = locale source_bundle = SgtnClient::Config.configurations[env]["source_bundle"] SgtnClient.logger.debug "Loading [" + locale + "] source bundles from path: " + source_bundle Dir.children(source_bundle).each do |component| yamlfile = File.join(source_bundle, component + "/" + locale + ".yml") bundle = read_yml(yamlfile) cachekey = SgtnClient::CacheUtil.get_cachekey(component, locale) SgtnClient::CacheUtil.write_cache(cachekey,bundle) end end |