Extract Github::Representation::Issuable

parent f35573f1
module Github
module Representation
class Issuable < Representation::Base
def iid
raw['number']
end
def title
raw['title']
end
def description
raw['body'] || ''
end
def milestone
return unless raw['milestone'].present?
@milestone ||= Github::Representation::Milestone.new(raw['milestone'])
end
def author
@author ||= Github::Representation::User.new(raw['user'])
end
def assignee
return unless assigned?
@assignee ||= Github::Representation::User.new(raw['assignee'])
end
def assigned?
raw['assignee'].present?
end
end
end
end
module Github
module Representation
class Issue < Representation::Base
def iid
raw['number']
end
def title
raw['title']
end
def description
raw['body'] || ''
end
class Issue < Representation::Issuable
def labels
raw['labels']
end
def milestone
return unless raw['milestone'].present?
@milestone ||= Github::Representation::Milestone.new(raw['milestone'])
end
def author
@author ||= Github::Representation::User.new(raw['user'])
end
def assignee
return unless assigned?
@assignee ||= Github::Representation::User.new(raw['assignee'])
end
def state
raw['state'] == 'closed' ? 'closed' : 'opened'
end
def assigned?
raw['assignee'].present?
end
def has_comments?
raw['comments'] > 0
end
......
module Github
module Representation
class PullRequest < Representation::Base
class PullRequest < Representation::Issuable
attr_reader :project
delegate :user, :repo, :ref, :sha, to: :source_branch, prefix: true
......@@ -11,18 +11,6 @@ module Github
@raw = raw
end
def iid
raw['number']
end
def title
raw['title']
end
def description
raw['body'] || ''
end
def source_project
project
end
......@@ -48,22 +36,6 @@ module Github
@target_branch_name ||= target_branch_exists? ? target_branch_ref : target_branch_name_prefixed
end
def milestone
return unless raw['milestone'].present?
@milestone ||= Github::Representation::Milestone.new(raw['milestone'])
end
def author
@author ||= Github::Representation::User.new(raw['user'])
end
def assignee
return unless assigned?
@assignee ||= Github::Representation::User.new(raw['assignee'])
end
def state
return 'merged' if raw['state'] == 'closed' && raw['merged_at'].present?
return 'closed' if raw['state'] == 'closed'
......@@ -71,10 +43,6 @@ module Github
'opened'
end
def assigned?
raw['assignee'].present?
end
def opened?
state == 'opened'
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment