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 26 27 28 |
# 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 s = items[locale][key] if items.nil? || s.nil? SgtnClient.logger.debug "Source not found, return key: " + key #return key return nil else return s end end |
.getSources(component, locale) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sgtn-client/api/source.rb', line 30 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
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sgtn-client/api/source.rb', line 43 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 |