class Jira::Command::Attachments

Attributes

ticket[RW]

Public Class Methods

new(ticket) click to toggle source
# File lib/jira/commands/attachments.rb, line 16
def initialize(ticket)
  self.ticket = ticket
end

Public Instance Methods

run() click to toggle source
# File lib/jira/commands/attachments.rb, line 20
def run
  return if ticket.empty?
  return if metadata.empty?
  return if metadata['fields'].nil?

  attachments=metadata['fields']['attachment']
  if !attachments.nil? and attachments.count > 0
    attachments.each do |attachment|
      name=attachment['filename']
      url=attachment['content']

      puts "#{Jira::Format.user(name)} #{url}"
    end
  else
    puts "No attachments found for ticket #{ticket}."
  end
end

Private Instance Methods

metadata() click to toggle source
# File lib/jira/commands/attachments.rb, line 40
def metadata
  @metadata ||= api.get("issue/#{ticket}")
end