class Binford::Github

Attributes

token[R]

Public Class Methods

new(token:) click to toggle source
Calls superclass method
# File lib/binford/github.rb, line 7
def initialize(token:)
  super("https://api.github.com", serializer: Serializers::Json.new)
  @token = token
end

Public Instance Methods

project_cards(column_id) click to toggle source
# File lib/binford/github.rb, line 20
def project_cards(column_id)
  get("/projects/columns/#{column_id}/cards")
end
project_columns(project_id) click to toggle source
# File lib/binford/github.rb, line 16
def project_columns(project_id)
  get("/projects/#{project_id}/columns")
end
project_story_points(column_id) click to toggle source
# File lib/binford/github.rb, line 24
def project_story_points(column_id)
  regex = /SP:\s*(\d+\.*\d*)/
  project_cards(column_id)&.map do |data|
    (data[:note] || get(data[:content_url].sub(base_url, ""))[:body]).scan(regex).flatten.first
  end&.compact
end
projects(owner, repo) click to toggle source
# File lib/binford/github.rb, line 12
def projects(owner, repo)
  get("repos/#{owner}/#{repo}/projects")
end

Private Instance Methods

default_headers() click to toggle source
# File lib/binford/github.rb, line 35
def default_headers
  {
    "Content-Type" => "application/json",
    "Accept" => "application/vnd.github.inertia-preview+json",
    "Authorization" => "token #{token}"
  }
end