Parent

Class/Module Index [+]

Quicksearch

Object

Public Instance Methods

add_headline(hash) click to toggle source
# File lib/configcheck.rb, line 66
def add_headline(hash)
  hash.each do |key, subhash|
    subhash['headline'] = '_("' + key + '")' if KNOWN_KEYS.include?(key)
  end
end
check_config() click to toggle source
# File lib/configcheck.rb, line 37
def check_config()
  if File.exist?(PATH)
    hash = Hash.new
    hash = YAML.load(File.open(PATH))

    if node_exist?(hash)
      #find headlines
      unless subnode_exist?(hash, "headline")
        add_headline(hash)

        #check label translation
        unless !subnode_exist?(hash, "y_label")
          check_label_translation(hash)
        end 
      end
    end
    #save changes
    save_config(hash)
  end
end
check_label_translation(hash) click to toggle source
# File lib/configcheck.rb, line 72
def check_label_translation(hash)
  hash.each do |key, subhash|
    subhash['y_label'] = '_("' + subhash["y_label"] + '")' unless subhash['y_label'] =~ /^_\(\"/ &&  subhash["y_label"] =~ /\"\)$/
  end
end
node_exist?(hash) click to toggle source
# File lib/configcheck.rb, line 58
def node_exist?(hash)
    KNOWN_KEYS.any? { |e| hash.has_key?(e) }
end
save_config(hash) click to toggle source
# File lib/configcheck.rb, line 78
def save_config(hash)
  file_name = File.join(PATH)
  File.open(file_name, "w") do |f|
    f.write(hash.to_yaml)
  end
end
subnode_exist?(hash, string) click to toggle source
# File lib/configcheck.rb, line 62
def subnode_exist?(hash, string)
  hash.any? { |key,subhash| subhash.has_key?(string) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.