Class: Octopi::Issue
- Includes:
- Resource
- Defined in:
- lib/octopi/issue.rb
Constant Summary collapse
- STATES =
%w{open closed}
Constants inherited from Base
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#closed_at ⇒ Object
Returns the value of attribute closed_at.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#number ⇒ Object
Returns the value of attribute number.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#state ⇒ Object
Returns the value of attribute state.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#user ⇒ Object
Returns the value of attribute user.
-
#votes ⇒ Object
Returns the value of attribute votes.
Attributes inherited from Base
Class Method Summary collapse
-
.find(options = {}) ⇒ Object
TODO: Make find use hashes like find_all.
-
.find_all(options = {}) ⇒ Object
Finds all issues for a given Repository.
- .open(options = {}) ⇒ Object
- .search(options = {}) ⇒ Object
Instance Method Summary collapse
- #close! ⇒ Object
- #comment(comment) ⇒ Object
-
#reopen! ⇒ Object
Re-opens an issue.
- #save ⇒ Object
Methods included from Resource
Methods inherited from Base
#error=, #initialize, #property
Constructor Details
This class inherits a constructor from Octopi::Base
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def body @body end |
#closed_at ⇒ Object
Returns the value of attribute closed_at.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def closed_at @closed_at end |
#created_at ⇒ Object
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def created_at @created_at end |
#labels ⇒ Object
Returns the value of attribute labels.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def labels @labels end |
#number ⇒ Object
Returns the value of attribute number.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def number @number end |
#repository ⇒ Object
Returns the value of attribute repository.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def repository @repository end |
#state ⇒ Object
Returns the value of attribute state.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def state @state end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def title @title end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def updated_at @updated_at end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def user @user end |
#votes ⇒ Object
Returns the value of attribute votes.
10 11 12 |
# File 'lib/octopi/issue.rb', line 10 def votes @votes end |
Class Method Details
.find(options = {}) ⇒ Object
TODO: Make find use hashes like find_all
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/octopi/issue.rb', line 45 def self.find(={}) ensure_hash() # Do not cache issues, as they may change via other means. @cache = false user, repo = gather_details() validate_args(user => :user, repo => :repo) issue = super user, repo, [:number] issue.repository = repo issue end |
.find_all(options = {}) ⇒ Object
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
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/octopi/issue.rb', line 33 def self.find_all(={}) ensure_hash() user, repo = gather_details() state = ([: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(options = {}) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/octopi/issue.rb', line 57 def self.open(={}) ensure_hash() user, repo = gather_details() data = Api.api.post("/issues/open/#{user}/#{repo.name}", [:params]) issue = new(data['issue']) issue.repository = repo issue end |
.search(options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/octopi/issue.rb', line 12 def self.search(={}) ensure_hash() [:state] ||= "open" user, repo = gather_details() Api.api.get("/issues/search/#{user}/#{repo}/#{options[:state]}/#{options[:keyword]}") end |
Instance Method Details
#close! ⇒ Object
73 74 75 76 77 |
# File 'lib/octopi/issue.rb', line 73 def close! data = Api.api.post(command_path("close")) self.state = 'closed' self end |
#comment(comment) ⇒ Object
97 98 99 100 |
# File 'lib/octopi/issue.rb', line 97 def comment(comment) data = Api.api.post(command_path("comment"), { :comment => comment }) IssueComment.new(data['comment']) end |
#reopen! ⇒ Object
Re-opens an issue.
67 68 69 70 71 |
# File 'lib/octopi/issue.rb', line 67 def reopen! data = Api.api.post(command_path("reopen")) self.state = 'open' self end |
#save ⇒ Object
79 80 81 82 |
# File 'lib/octopi/issue.rb', line 79 def save data = Api.api.post(command_path("edit"), { :title => title, :body => body }) self end |