Sha256: 31314c6034de0b026d64b86f0f0e741456e2bd1ce3b2e9318d9373f3e9e6fc58

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

##
# Definitions for issue objects
module Taskit
  Label = Struct.new(:name, :color)

  ##
  # An issue object, used to normalize the GitHub API response
  class Issue
    attr_reader :repo, :repo_url, :owner,
                :url, :id, :number, :title, :body, :reporter,
                :labels, :state

    def initialize(data)
      load_repo_info data
      load_issue_info data
      load_state_info data
    end

    def load_repo_info(data)
      repo_info = data[:repository]
      @repo = repo_info[:name]
      @repo_url = repo_info[:html_url]
      @owner = repo_info[:owner][:login]
    end

    def load_issue_info(data)
      @url, @id, @number, @title, @body = data.to_h.values_at(
        :html_url, :id, :number, :title, :body
      )
      @reporter = data[:user][:login]
    end

    def load_state_info(data)
      @state = data[:state]
      @labels = data[:labels].map { |x| Label.new(x[:name], x[:color]) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
taskit-0.0.3 lib/taskit/issue.rb