class Takoyaki::Commands::Reviews
Attributes
target[R]
Public Class Methods
new(target = nil)
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 8 def initialize(target = nil) @target = target end
Public Instance Methods
execute()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 12 def execute output end
Private Instance Methods
client()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 18 def client @client ||= Octokit::Client.new(access_token: config["access_token"]) end
config()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 22 def config @config ||= YAML.load_file(File.expand_path("~/.takoyaki.yaml")) end
fetch_pull_requests(repository)
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 50 def fetch_pull_requests(repository) client.pull_requests(repository, state: "open") end
Also aliased as: fetch_pr
filtered_reviews()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 26 def filtered_reviews @filtered_reviews ||= reviews.each_with_object({}) do |(repo, prs), obj| obj[repo] = prs.keep_if { |pr| pr[:reviewers].include?(user) } end end
format_pull_request(pr)
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 55 def format_pull_request(pr) "- [##{pr[:number]} #{pr[:title]}](#{pr[:url]}) " \ "from #{pr[:created_at]}, " \ "reviewes: #{pr[:reviewers].join(', ')}" end
Also aliased as: format_pr
generate_pull_request_hash(pr)
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 33 def generate_pull_request_hash(pr) reviewers = pr.assignees.map(&:login).delete_if { |u| u == pr.user.login } { number: pr.number, title: pr.title, author: pr.user.login, reviewers: reviewers, created_at: pr.created_at.getlocal.strftime("%Y-%m-%d"), url: pr.html_url } end
Also aliased as: pr_hash
only_me?()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 46 def only_me? target != "all" end
output()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 62 def output output_reviews = only_me? ? filtered_reviews : reviews output_reviews.each do |repo, prs| next if prs.empty? puts "### #{repo}" prs.each { |pr| puts format_pr(pr) } end end
repositories()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 71 def repositories config["repositories"].map do |org, repos| repos.map { |repo| "#{org}/#{repo}" } end.flatten end
reviews()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 77 def reviews @reviews ||= repositories.each_with_object({}) do |repo, obj| obj[repo] = fetch_pr(repo).map { |pr| pr_hash(pr) } end end
user()
click to toggle source
# File lib/takoyaki/commands/reviews.rb, line 84 def user client.user.login end