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
- #comments ⇒ 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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/octopi/issue.rb', line 47 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 43 44 |
# File 'lib/octopi/issue.rb', line 33 def self.find_all(={}) ensure_hash() user, repo = gather_details() states = [[:state]] if [:state] states ||= ["open", "closed"] issues = [] states.each do |state| validate_args(user => :user, repo.name => :repo, state => :state) issues << super(user, repo.name, state) end issues.flatten.each { |i| i.repository = repo } end |
Instance Method Details
#close! ⇒ Object
75 76 77 78 79 |
# File 'lib/octopi/issue.rb', line 75 def close! data = Api.api.post(command_path("close")) self.state = 'closed' self end |
#comment(comment) ⇒ Object
99 100 101 102 |
# File 'lib/octopi/issue.rb', line 99 def comment(comment) data = Api.api.post(command_path("comment"), { :comment => comment }) IssueComment.new(data['comment']) end |
#comments ⇒ Object
104 105 106 107 |
# File 'lib/octopi/issue.rb', line 104 def comments data = Api.api.get(command_path("comments")) data["comments"].map { |c| IssueComment.new(c) } end |