class ForemanThemeSatellite::ReplacerRepository
This repository is a wrapper above other repository, it replaces branded words with their downstream counterparts.
Public Class Methods
new(old_repo)
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 8 def initialize(old_repo) @repo = old_repo end
Public Instance Methods
[](key)
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 20 def [](key) original = @repo[key] val = original || key return original unless val.is_a? String val = val.dup if val replaced = replace_string(val) replaced == val ? original : replaced end
available_locales()
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 16 def available_locales @repo.available_locales end
plural(*keys)
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 32 def plural(*keys) @repo.plural(*keys) end
pluralisation_rule()
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 12 def pluralisation_rule @repo.pluralisation_rule end
reload()
click to toggle source
# File lib/foreman_theme_satellite/replacer_repository.rb, line 36 def reload @repo.reload end
Private Instance Methods
replace_string(val)
click to toggle source
'babcb'.split(/b/, -1) => ['', 'a', 'c', ''].join('z') => 'zazcz'
# File lib/foreman_theme_satellite/replacer_repository.rb, line 43 def replace_string(val) return '' if val.empty? ForemanThemeSatellite::FOREMAN_BRAND.each do |foreman_word, value| parts = val.split(foreman_word, -1) next if parts.size == 1 # no match, try the next word parts = parts.map { |part| replace_string(part) } return parts.join(value) end val # no match found at all end