Class: RubyGitIssue
- Inherits:
-
Object
- Object
- RubyGitIssue
- Defined in:
- lib/ruby_git_issue.rb
Instance Attribute Summary collapse
-
#column_id ⇒ Object
Returns the value of attribute column_id.
-
#exception_data ⇒ Object
Returns the value of attribute exception_data.
-
#issue_options ⇒ Object
Returns the value of attribute issue_options.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#project ⇒ Object
Returns the value of attribute project.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#request ⇒ Object
Returns the value of attribute request.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#add_issue_to_project(issue_data, column_id) ⇒ Object
issue_data ## Stringyied Hash column_id ## Integer Method will assign issue to project column on the github project board.
-
#client ⇒ Object
github client from octokit.
-
#generate_issue(column_id = nil) ⇒ Object
Generate Github issue column_id ## Integer => Get column id from project and its columns column_id can be blank as well.
-
#get_org_projects ⇒ Object
Get Github project based on the organization passed while initializing client.
-
#get_projects_columns(project_id) ⇒ Object
project_id ## Integer => Get project columns based on the Github project_id.
- #initialize(options) ⇒ RubyGitIssue constructor
Constructor Details
#initialize(options) ⇒ RubyGitIssue
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_git_issue.rb', line 13 def initialize() self.token = [:token] self.request = [:request] self.exception_data = [:exception_data] self.organization = [:organization] self.repo = [:repo] self. = [:issue_options] self.project = nil self.column_id = nil end |
Instance Attribute Details
#column_id ⇒ Object
Returns the value of attribute column_id.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def column_id @column_id end |
#exception_data ⇒ Object
Returns the value of attribute exception_data.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def exception_data @exception_data end |
#issue_options ⇒ Object
Returns the value of attribute issue_options.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def end |
#organization ⇒ Object
Returns the value of attribute organization.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def organization @organization end |
#project ⇒ Object
Returns the value of attribute project.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def project @project end |
#repo ⇒ Object
Returns the value of attribute repo.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def repo @repo end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def request @request end |
#token ⇒ Object
Returns the value of attribute token.
5 6 7 |
# File 'lib/ruby_git_issue.rb', line 5 def token @token end |
Instance Method Details
#add_issue_to_project(issue_data, column_id) ⇒ Object
issue_data ## Stringyied Hash column_id ## Integer Method will assign issue to project column on the github project board
59 60 61 62 63 64 65 66 |
# File 'lib/ruby_git_issue.rb', line 59 def add_issue_to_project(issue_data, column_id) payload = { content_type: "Issue", content_id: issue_data['id'] } client.create_project_card(column_id, payload) # url = "#{BASE_URL}/projects/columns/#{column_id}/cards" end |
#client ⇒ Object
github client from octokit
25 26 27 |
# File 'lib/ruby_git_issue.rb', line 25 def client Octokit::Client.new(:access_token => "#{token}") end |
#generate_issue(column_id = nil) ⇒ Object
Generate Github issue column_id ## Integer => Get column id from project and its columns column_id can be blank as well. Issue will not be assigned to and project column if column_id is blank
32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_git_issue.rb', line 32 def generate_issue(column_id=nil) existing_issue = client.list_issues("#{organization}/#{repo}").select{|issue| issue[:title] == [:title]}.try(:first) if existing_issue.nil? issue_data = client.create_issue("#{organization}/#{repo}", [:title], compose_body(exception_data, request), ) add_issue_to_project(issue_data, column_id) unless column_id.nil? else client.add_comment("#{organization}/#{repo}", existing_issue.number, compose_body(exception_data, request)) end end |
#get_org_projects ⇒ Object
Get Github project based on the organization passed while initializing client
43 44 45 46 47 |
# File 'lib/ruby_git_issue.rb', line 43 def get_org_projects unless organization.nil? client.org_projects(organization) end end |
#get_projects_columns(project_id) ⇒ Object
project_id ## Integer => Get project columns based on the Github project_id
50 51 52 53 54 |
# File 'lib/ruby_git_issue.rb', line 50 def get_projects_columns(project_id) unless organization.nil? client.project_columns(project_id) end end |