class HornOfPlenty::Adapters::Github::Parsers::Issue

Attributes

raw[RW]

Public Class Methods

new(raw:) click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 16
def initialize(raw:)
  self.raw = raw
end
to_model(raw_item) click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 85
def self.to_model(raw_item)
  return NullObjects::Issue.instance unless raw_item

  Models::Issue.from_parser(parser: new(raw: raw_item))
end

Public Instance Methods

assignee_ids() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 28
def assignee_ids
  @assignee_ids                          ||= begin
    parse_key(raw, 'assignees').map { |assignee| assignee['login'] }
  end
end
author_id() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 24
def author_id
  @author_id                             ||= parse_text(raw, 'user/:/login')
end
closed_at() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 69
def closed_at
  @closed_at                             ||= parse_time(raw, 'closed_at')
end
closer_id() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 34
def closer_id
  @closer_id                             ||= parse_text(raw, 'closed_by/:/login')
end
created_at() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 73
def created_at
  @created_at                            ||= parse_time(raw, 'created_at')
end
description() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 54
def description
  @description                           ||= parse_text(raw, 'body') do |description|
    description.delete("\r")
  end
end
has_pull_request?() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 81
def has_pull_request?
  @has_pull_request                      ||= parse_existance(raw, 'pull_request')
end
id() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 20
def id
  @id                                    ||= parse_text(raw, 'number')
end
labels() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 60
def labels
  @labels                                ||= begin
    labels    = parse_key(raw, 'labels').map { |label| label['name'] }
    milestone = Array(parse_key(raw, 'milestone/:/title'))

    labels + milestone
  end
end
repository() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 38
def repository
  @repository                            ||= parse_text(raw, 'url') do |url|
    repo_name = url.match(%r{\A.*/repos/((?:[^/]+/){2}).*\z})[1]

    repo_name && repo_name[0..-2]
  end
end
status() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 46
def status
  @status                                ||= parse_text(raw, 'state')
end
title() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 50
def title
  @title                                 ||= parse_text(raw, 'title')
end
updated_at() click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/issue.rb, line 77
def updated_at
  @updated_at                            ||= parse_time(raw, 'updated_at')
end