Class: Commands::Unblock
Constant Summary collapse
- PlaceholderLabel =
"."
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Unblock
constructor
A new instance of Unblock.
- #run! ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(*args) ⇒ Unblock
Returns a new instance of Unblock.
8 9 10 11 |
# File 'lib/commands/unblock.rb', line 8 def initialize(*args) @story_id = args.shift if args.first =~ /^(\d+)$/ super(*args) end |
Instance Method Details
#run! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/commands/unblock.rb', line 13 def run! super unless story_id put "No story id was supplied and you aren't on a topic branch!" return 1 end unless story.labels.to_s.include?(Block::Label) put "Story #{story_id} is already unblocked." return 0 end labels = story.labels.to_s.split(",") - [Block::Label] # this line is to work aroudn Pivotal Tracker's broken API for removing the last # label on a card. http://community.pivotaltracker.com/pivotal/topics/api_v3_cannot_remove_labels_from_a_story_anymore if labels.empty? labels << PlaceholderLabel put "Note: a '.' label will be placed on this card due to a bug in the v3 API of Pivotal Tracker." end story.update :labels => labels.join(",") put "Story #{story_id} has been unblocked." return 0 end |