Class: Mistilteinn::Ticket::GitConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/mistilteinn/ticket/git_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GitConfig

Returns a new instance of GitConfig.



21
22
# File 'lib/mistilteinn/ticket/git_config.rb', line 21

def initialize(config)
end

Instance Method Details

#checkObject



24
25
26
# File 'lib/mistilteinn/ticket/git_config.rb', line 24

def check
  'ok'
end

#create(title = "") ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mistilteinn/ticket/git_config.rb', line 37

def create(title = "")
  tmpfile = Tempfile.new 'tmp'
  tmpfile.content = ticket_format({
    :subject => title,
    :author  => ::Mistilteinn::Git::config("user.name"),
    :date    => Time.now,
    :status  => "new"
  })
  tmpfile.edit default_editor

  ticket_id = (::Mistilteinn::Git.config("ticket.last") || "1").to_i
  issue_ticket(tmpfile, ticket_id)
  ::Mistilteinn::Git.config("ticket.last", (ticket_id+1).to_s)

  tmpfile.unlink
end

#edit(ticket_id) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/mistilteinn/ticket/git_config.rb', line 54

def edit(ticket_id)
  tmpfile = Tempfile.new 'tmp'
  tmpfile.content = ticket_format({
    :subject     => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.subject"),
    :author      => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.author"),
    :date        => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.date"),
    :status      => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.status"),
    :description => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.description")
  })
  modified = tmpfile.edit default_editor

  issue_ticket(tmpfile, ticket_id) if modified

  tmpfile.unlink
end

#ticketsObject



28
29
30
31
32
33
34
35
# File 'lib/mistilteinn/ticket/git_config.rb', line 28

def tickets
  last_ticket_id = ::Mistilteinn::Git.config "ticket.last"
  (1...last_ticket_id.to_i).map do |id|
    subject = ::Mistilteinn::Git.config "ticket.id/#{id}.subject"
    status  = ::Mistilteinn::Git.config "ticket.id/#{id}.status"
    ::Mistilteinn::Ticket::Entry.new(id, subject, status)
  end
end