Class: TaskWarrior::TaskMapper
- Inherits:
-
Object
- Object
- TaskWarrior::TaskMapper
- Defined in:
- lib/taskwarrior/task_mapper.rb
Overview
A DataMapper that makes new Tasks from a JSON representation
Class Method Summary collapse
Class Method Details
.map(json) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/taskwarrior/task_mapper.rb', line 7 def map(json) Task.new(json['description']).tap{|t| t.id = json['id'].to_i t.uuid = json['uuid'] t.entry = DateTime.parse(json['entry']) t.status = json['status'].to_sym t.project = json['project'] if json['depends'] if json['depends'].respond_to?(:split) t.dependencies = json['depends'].split(',') else t.dependencies = json['depends'] end end t.parent = json['parent'] # Children will be cross-indexed in the repository t.priority = PriorityMapper.map(json['priority']) json['tags'].each{|tag| t. << tag} if json['tags'] json['annotations'].each{|annotation| t.annotations << AnnotationMapper.map(annotation)} if json['annotations'] %w{start wait end due}.each do |datish| t.send("#{datish}_at=", DateTime.parse(json[datish])) if json[datish] end } end |