module Reviser::Helpers::Criteria::Labels
Manage all actions for adding, updating or getting labels of Reviser
. A label is a a group of words, describing the associated criterion (method).
@example
criterion => label all_files => all files of project
known Labels
are in the labels.yml file.
@author Yann Prono
Constants
- LABELS
Path of label.yml file
Public Class Methods
add(meth, label)
click to toggle source
Enable to associate a label to a criterion (method). The label will be saved in the ‘labels.yml’ file @param meth Method to link. @param label Label to link with the method.
# File lib/reviser/helpers/criteria.rb, line 177 def self.add meth, label res = "Create" labels = YAML.load File.read(Cfg.workspace_file LABELS) if labels.respond_to? '[]' res = "Update" if labels.key? meth labels[meth] = label File.open(LABELS, 'w') { |f| f.write labels.to_yaml } end res end
load()
click to toggle source
@return Hash all known labels by reviser. :criterion => label
# File lib/reviser/helpers/criteria.rb, line 190 def self.load self.populate YAML.load File.read(Cfg.workspace_file LABELS) end
populate(hash)
click to toggle source
# File lib/reviser/helpers/criteria.rb, line 194 def self.populate hash labels = {} if hash.respond_to?('each') hash.each do |meth, label| labels[meth.to_sym] = label end end labels end