class GettextSwap::Configuration
Attributes
rules[R]
Public Class Methods
new()
click to toggle source
# File lib/gettext_swap/configuration.rb, line 7 def initialize @rules = [] end
Public Instance Methods
read_yaml(yaml)
click to toggle source
# File lib/gettext_swap/configuration.rb, line 11 def read_yaml(yaml) root = yaml['swap'] raise( GettextSwap::Exception, "root 'swap' element must be specified") unless root # Be atomic, either load the whole file, or don't load it at all tuples = root.map { |tuple| read_tuple(tuple) } @rules = tuples.freeze true end
Private Instance Methods
read_tuple(tuple)
click to toggle source
# File lib/gettext_swap/configuration.rb, line 25 def read_tuple(tuple) regex = tuple['search'] value = tuple['replace'] raise( GettextSwap::Exception, "search element must be specified for tuple #{tuple}") unless regex raise( GettextSwap::Exception, "replace element must be specified for tuple #{tuple}") unless value [Regexp.new(regex), value] end