Class: Pv::Command
- Includes:
- Thor::Actions
- Defined in:
- lib/pv/command.rb
Instance Method Summary collapse
- #create(type, name) ⇒ Object
-
#edit(story_id, status) ⇒ Object
method_option :message, default: “”, alias: ‘m’.
- #help ⇒ Object
- #log ⇒ Object
- #open(story_id) ⇒ Object
- #show(story_id) ⇒ Object
Instance Method Details
#create(type, name) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pv/command.rb', line 47 def create type, name with_attributes = .merge(story_type: type, name: name) story = Story.create with_attributes if story.saved? say "Created #{type.titleize} ##{story.id}: '#{name}'" else say "Error saving #{type} with '#{name}'" end end |
#edit(story_id, status) ⇒ Object
method_option :message, default: “”, alias: ‘m’
28 29 30 31 32 33 34 35 36 |
# File 'lib/pv/command.rb', line 28 def edit story_id, status story = Story.find(story_id) or raise "Error: Story not found" if story.update(status) say "#{status.titleize} ##{story_id}" else say "Error: Story did not update." end end |
#help ⇒ Object
59 60 61 62 |
# File 'lib/pv/command.rb', line 59 def help say IO.read("#{Pv.root}/lib/templates/help.txt") super end |
#log ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/pv/command.rb', line 9 def log Pv.tracker.stories.each do |story| id = set_color "#{story.id}", Thor::Shell::Color::YELLOW = set_color story.requested_by, Thor::Shell::Color::WHITE say "* #{id} #{story.name} #{}" end end |
#open(story_id) ⇒ Object
65 66 67 |
# File 'lib/pv/command.rb', line 65 def open story_id run "open https://www.pivotaltracker.com/story/show/#{story_id}" end |
#show(story_id) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/pv/command.rb', line 19 def show story_id sha = Digest::HMAC.hexdigest story_id.to_s, Time.now.to_s, Digest::SHA1 File.write "/tmp/story-#{sha}", Story.find(story_id).render system "$PAGER /tmp/story-#{sha}" system "rm -rf /tmp/story-#{sha}" end |