Module: Reviser::Helpers::Criteria::Labels
- Defined in:
- lib/reviser/helpers/criteria.rb
Overview
Manage all actions for adding, updating or getting labels of Reviser. A label is a a group of words, describing the associated criterion (method).
all_files => all files of project
known Labels are in the labels.yml file.
Constant Summary collapse
- PWD =
Current directory of this file
File.dirname __FILE__
- LABELS =
Path of label.yml file
File.join File.dirname(File.dirname(File.dirname(PWD))), 'labels.yml'
Class Method Summary collapse
-
.add(meth, label) ⇒ Object
Enable to associate a label to a criterion (method).
-
.load ⇒ Object
:criterion => label.
- .populate(hash) ⇒ Object
Class Method Details
.add(meth, label) ⇒ Object
Enable to associate a label to a criterion (method). The label will be saved in the 'labels.yml' file
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/reviser/helpers/criteria.rb', line 181 def self.add meth, label res = "Create" labels = YAML.load File.open(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 ⇒ Object
:criterion => label
194 195 196 |
# File 'lib/reviser/helpers/criteria.rb', line 194 def self.load Labels.populate(YAML.load(File.open(LABELS))) end |
.populate(hash) ⇒ Object
198 199 200 201 202 203 204 205 206 |
# File 'lib/reviser/helpers/criteria.rb', line 198 def self.populate hash labels = {} if hash.respond_to?('each') hash.each do |meth, label| labels[meth.to_sym] = label end end labels end |