Class: Octopolo::GitHub::Issue
- Inherits:
-
Object
- Object
- Octopolo::GitHub::Issue
- Defined in:
- lib/octopolo/github/issue.rb
Direct Known Subclasses
Constant Summary collapse
- MissingParameter =
Class.new StandardError
- NotFound =
Class.new StandardError
- CommentFailed =
Class.new StandardError
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#number ⇒ Object
Returns the value of attribute number.
-
#repo_name ⇒ Object
Returns the value of attribute repo_name.
Class Method Summary collapse
-
.create(repo_name, options) ⇒ Object
Public: Create a issue for the given repo.
Instance Method Summary collapse
-
#add_labels(*labels) ⇒ Object
Public: Adds labels to a pull-request.
- #body ⇒ Object
- #commenter_names ⇒ Object
- #comments ⇒ Object
- #exclude_octopolo_user(user_list) ⇒ Object
- #external_urls ⇒ Object
- #human_app_name ⇒ Object
-
#initialize(repo_name, number, data = nil) ⇒ Issue
constructor
A new instance of Issue.
-
#remove_labels(*labels) ⇒ Object
Public: Removes labels from a pull-request,.
- #title ⇒ Object
- #url ⇒ Object
-
#write_comment(message) ⇒ Object
Public: Add a comment to the issue.
Constructor Details
#initialize(repo_name, number, data = nil) ⇒ Issue
Returns a new instance of Issue.
10 11 12 13 14 15 16 |
# File 'lib/octopolo/github/issue.rb', line 10 def initialize repo_name, number, data = nil raise MissingParameter if repo_name.nil? or number.nil? self.repo_name = repo_name self.number = number self.data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/octopolo/github/issue.rb', line 6 def data @data end |
#number ⇒ Object
Returns the value of attribute number.
8 9 10 |
# File 'lib/octopolo/github/issue.rb', line 8 def number @number end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
7 8 9 |
# File 'lib/octopolo/github/issue.rb', line 7 def repo_name @repo_name end |
Class Method Details
.create(repo_name, options) ⇒ Object
Public: Create a issue for the given repo
repo_name - Full name (“account/repo”) of the repo in question options - Hash of issue information
title: Title of the issue
description: Brief description of the issue
Returns a Issue instance
26 27 28 29 30 31 |
# File 'lib/octopolo/github/issue.rb', line 26 def self.create(repo_name, ) # create via the API creator = IssueCreator.perform(repo_name, ) # wrap in our class new repo_name, creator.number, creator.data end |
Instance Method Details
#add_labels(*labels) ⇒ Object
Public: Adds labels to a pull-request
labels - label objects, can be a single label, an array of labels,
or a list of labels
86 87 88 89 |
# File 'lib/octopolo/github/issue.rb', line 86 def add_labels(*labels) built_labels = Label.build_label_array(labels) GitHub.add_labels_to_issue(repo_name, number, built_labels.map(&:name) ) end |
#body ⇒ Object
55 56 57 |
# File 'lib/octopolo/github/issue.rb', line 55 def body data.body || "" end |
#commenter_names ⇒ Object
47 48 49 |
# File 'lib/octopolo/github/issue.rb', line 47 def commenter_names exclude_octopolo_user (comments.map{ |comment| GitHub::User.new(comment.user.login). }.uniq) end |
#comments ⇒ Object
69 70 71 |
# File 'lib/octopolo/github/issue.rb', line 69 def comments @comments ||= GitHub.issue_comments(repo_name, number) end |
#exclude_octopolo_user(user_list) ⇒ Object
51 52 53 |
# File 'lib/octopolo/github/issue.rb', line 51 def exclude_octopolo_user(user_list) user_list.reject{|u| GitHub.excluded_users.include?(u) } end |
#external_urls ⇒ Object
59 60 61 62 |
# File 'lib/octopolo/github/issue.rb', line 59 def external_urls # extract http and https URLs from the body URI.extract body, %w(http https) end |
#human_app_name ⇒ Object
64 65 66 67 |
# File 'lib/octopolo/github/issue.rb', line 64 def human_app_name repo = repo_name.split("/").last repo.split("_").map(&:capitalize).join(" ") end |
#remove_labels(*labels) ⇒ Object
Public: Removes labels from a pull-request,
labels - label objects, can be a single label, an array of labels,
or a list of labels
95 96 97 98 99 |
# File 'lib/octopolo/github/issue.rb', line 95 def remove_labels(*labels) Label.build_label_array(labels).each do |built_label| GitHub.remove_label(repo_name, number, built_label.name) end end |
#title ⇒ Object
39 40 41 |
# File 'lib/octopolo/github/issue.rb', line 39 def title data.title end |
#url ⇒ Object
43 44 45 |
# File 'lib/octopolo/github/issue.rb', line 43 def url data.html_url end |
#write_comment(message) ⇒ Object
Public: Add a comment to the issue
message - A String containing the desired comment body
76 77 78 79 80 |
# File 'lib/octopolo/github/issue.rb', line 76 def write_comment() GitHub.add_comment repo_name, number, ":octocat: #{}" rescue Octokit::UnprocessableEntity => error raise CommentFailed, "Unable to write the comment: '#{error.}'" end |