Class: See::Plugins::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/see/plugins/github.rb

Instance Method Summary collapse

Instance Method Details

#config_nameObject



10
11
12
# File 'lib/see/plugins/github.rb', line 10

def config_name
  'github'
end

#display_nameObject



6
7
8
# File 'lib/see/plugins/github.rb', line 6

def display_name
  'GitHub'
end

#run(config, plugin_config) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/see/plugins/github.rb', line 14

def run(config, plugin_config)
  info = []
  token = ENV['GITHUB_ACCESS_TOKEN']
  unless token
    info << "  You must set GITHUB_ACCESS_TOKEN env variable".red
    return info
  end

  client = Octokit::Client.new :access_token => token
   = plugin_config['account']
  repository = plugin_config['repository']
  github_name = [, repository].join '/'

  pull_requests = client.pull_requests(github_name)
  if pull_requests.count > 0
    info << "  Open pull requests:".light_blue
    pull_requests.each do |pull_request|
      username = "[#{pull_request.user.}]".cyan
      time = "- #{pull_request.updated_at.strftime("%b %e,%l:%M %p")}".black
      info << "    - #{pull_request.title} #{username} #{time}"
    end
  else
    info << "  No open pull requests".yellow
  end

  issues = client.issues(github_name)
  if issues.count > 0
    info << "  Open issues:".light_blue
    issues.each do |issue|
      username = "[#{issue.user.}]".cyan
      time = "- #{issue.updated_at.strftime("%b %e,%l:%M %p")}".black
      info << "    - #{issue.title} #{username} #{time}"
    end
  else
    info << "No open issues".yellow
  end
  info
end