Class: Octopi::Issue

Included Modules

Octopi::Resource

Attributes

Instance Attributes

body [RW] public

Sets the attribute body.

closed_at [RW] public

Sets the attribute closed_at.

created_at [RW] public

Sets the attribute created_at.

labels [RW] public

Sets the attribute labels.

number [RW] public

Sets the attribute number.

repository [RW] public

Sets the attribute repository.

state [RW] public

Sets the attribute state.

title [RW] public

Sets the attribute title.

updated_at [RW] public

Sets the attribute updated_at.

user [RW] public

Sets the attribute user.

votes [RW] public

Sets the attribute votes.

Constants

STATES
%w{open closed}

Constants Inherited from Octopi::Base

VALID

Constructor Summary

This class inherits a constructor from Octopi::Base.

Public Visibility

Public Class Method Summary

find(opts = {})

TODO: Make find use hashes like find_all.

find_all(opts = {})

Finds all issues for a given Repository.

open(opts = {})

Public Instance Method Summary

#close!
#comment(comment)
#reopen!

Re-opens an issue.

#save

Public Instance Methods Inherited from Octopi::Base

error=, property

Public Class Method Details

find

public find(opts = {})

TODO: Make find use hashes like find_all

[View source]


37
38
39
40
41
42
43
44
# File 'lib/octopi/issue.rb', line 37

def self.find(opts={})
  user, repo = gather_details(opts)
  
  validate_args(user => :user, repo => :repo)
  issue = super user, repo, opts[:number]
  issue.repository = repo
  issue
end

find_all

public find_all(opts = {})

Finds all issues for a given Repository

You can provide the user and repo parameters as String or as User and Repository objects. When repo is provided as a Repository object, user is superfluous.

If no state is given, "open" is assumed.

Sample usage:

  find_all(repo, :state => "closed") # repo must be an object
  find_all("octopi", :user => "fcoury") # user must be provided
  find_all(:user => "fcoury", :repo => "octopi") # state defaults to open
[View source]


26
27
28
29
30
31
32
33
34
# File 'lib/octopi/issue.rb', line 26

def self.find_all(opts={})
  user, repo = gather_details(opts)
  state = (opts[:state] || "open").downcase
  validate_args(user => :user, repo.name => :repo, state => :state)

  issues = super user, repo.name, state
  issues.each { |i| i.repository = repo }
  issues
end

open

public open(opts = {})
[View source]


46
47
48
49
50
51
52
# File 'lib/octopi/issue.rb', line 46

def self.open(opts={})
  user, repo = gather_details(opts)
  data = Api.api.post("/issues/open/#{user}/#{repo.name}", opts[:params])
  issue = new(data['issue'])
  issue.repository = repo
  issue
end

Public Instance Method Details

close!

public close!
[View source]


61
62
63
64
65
# File 'lib/octopi/issue.rb', line 61

def close!
  data = Api.api.post(command_path("close"))
  self.state = 'closed'
  self
end

comment

public comment(comment)
[View source]


85
86
87
88
# File 'lib/octopi/issue.rb', line 85

def comment(comment)
  data = Api.api.post(command_path("comment"), { :comment => comment })
  IssueComment.new(data['comment'])
end

reopen!

public reopen!

Re-opens an issue.

[View source]


55
56
57
58
59
# File 'lib/octopi/issue.rb', line 55

def reopen!
  data = Api.api.post(command_path("reopen"))
  self.state = 'open'
  self
end

save

public save
[View source]


67
68
69
70
# File 'lib/octopi/issue.rb', line 67

def save
  data = Api.api.post(command_path("edit"), { :title => title, :body => body })
  self
end
Generated on Friday, July 31 2009 at 05:01:54 PM by YARD 0.2.3.2 (ruby-1.8.6).