class WhatsupGithub::Row

Row to be converted to entry in future table

Attributes

assignee[R]
author[R]
author_url[R]
body[R]
is_private[R]
labels[R]
membership[R]
merge_commit[R]
pr_number[R]
title[R]

Public Class Methods

new(args) click to toggle source
# File lib/whatsup_github/row.rb, line 18
def initialize(args)
  @repo = args[:repo]
  @repo_url = args[:repo_url]
  @is_private = args[:private]
  @title = args[:pr_title]
  @body = args[:pr_body]
  @date = args[:date]
  @labels = args[:pr_labels]
  @assignee = args[:assignee]
  @author = args[:author]
  @author_url = args[:author_url]
  @pr_number = args[:pr_number]
  @link = args[:pr_url]
  @merge_commit = args[:merge_commit_sha]
  @membership = args[:membership]
  @config = Config.instance
end

Public Instance Methods

date() click to toggle source
# File lib/whatsup_github/row.rb, line 53
def date
  @date.strftime('%B %-e, %Y')
end
description() click to toggle source
# File lib/whatsup_github/row.rb, line 72
def description
  # If a PR body includes a phrase 'whatsnew', then parse the body.
  # If there are at least one required label but PR body does not include what's new, warn about missing 'whatsnew'
  if body.include?(magic_word)
    parse_body
  else
    message = "MISSING #{magic_word} in the #{type} PR \##{pr_number}: \"#{title}\" assigned to #{assignee} (#{link})"
    puts message
    message
  end
end
labels_from_config() click to toggle source
# File lib/whatsup_github/row.rb, line 36
def labels_from_config
  @config.labels
end
magic_word() click to toggle source
# File lib/whatsup_github/row.rb, line 44
def magic_word
  @config.magic_word
end
parse_body() click to toggle source
# File lib/whatsup_github/row.rb, line 61
def parse_body
  # Split PR description in two parts by 'magic word', and take the second half
  description_splited = body.split(magic_word)[-1]
  # Convert new line separators to <br> tags
  newline_splited = description_splited.split("\n")
  cleaned_array = newline_splited.map { |e| e.delete "\r\*" }
  cleaned_array.delete('')
  striped_array = cleaned_array.map(&:strip)
  striped_array.join('<br/>')
end
required_labels() click to toggle source
# File lib/whatsup_github/row.rb, line 40
def required_labels
  @config.required_labels
end
type() click to toggle source
# File lib/whatsup_github/row.rb, line 57
def type
  (labels & labels_from_config).join(', ')
end
versions() click to toggle source
# File lib/whatsup_github/row.rb, line 48
def versions
  label_versions = labels.select { |label| label.start_with?(/\d\./) }
  label_versions.join(', ')
end