lib/card.rb in trollolo-0.0.8 vs lib/card.rb in trollolo-0.0.9
- old
+ new
@@ -16,10 +16,11 @@
# you may find current contact information at www.suse.com
class Card
# Assuming we have card titles as follows '(8) This is the card name'
ESTIMATED_REGEX = /\(([\d.]+)\)/
+ PRIORITY_REGEX = /^(?:\([\d.]+\) )?P(\d+): /
SPRINT_NUMBER_REGEX = /\ASprint (\d+)/
def initialize(board_data, card_id)
init_data(board_data, card_id)
end
@@ -40,10 +41,23 @@
def story_points
return 0.0 unless estimated?
name.match(ESTIMATED_REGEX).captures.first.to_f
end
+ def priority
+ return unless m = name.match(PRIORITY_REGEX)
+ m.captures.first.to_i
+ end
+
+ def priority=(n)
+ if priority
+ @card_data["name"].sub!(/P\d+: /, "P#{n}: ")
+ else
+ @card_data["name"] = "P#{n}: #{name}"
+ end
+ end
+
def done_tasks
count = 0
@card_data["checklists"].each do |checklist|
if checklist["name"] != "Feedback"
checklist["checkItems"].each do |checklist_item|
@@ -120,7 +134,15 @@
end
end
def name
@card_data["name"]
+ end
+
+ def name=(str)
+ @card_data["name"] = str
+ end
+
+ def id
+ @card_data["id"]
end
end