Class: Pv::Command

Inherits:
Thor show all
Includes:
Thor::Actions
Defined in:
lib/pv/command.rb

Instance Method Summary collapse

Instance Method Details

#create(type, name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/pv/command.rb', line 44

def create type, name
  with_attributes = options.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’



25
26
27
28
29
30
31
32
33
# File 'lib/pv/command.rb', line 25

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

#helpObject



56
57
58
59
# File 'lib/pv/command.rb', line 56

def help
  say IO.read("#{Pv.root}/lib/templates/help.txt")
  super
end

#logObject



9
10
11
12
13
# File 'lib/pv/command.rb', line 9

def log
  Pv.tracker.stories.each do |from_data|
    preview Story.new(from_data)
  end
end

#open(story_id) ⇒ Object



62
63
64
# File 'lib/pv/command.rb', line 62

def open story_id
  run "open https://www.pivotaltracker.com/story/show/#{story_id}"
end

#show(story_id) ⇒ Object



16
17
18
19
20
21
# File 'lib/pv/command.rb', line 16

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