Class: See::Plugins::GitHub

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

Instance Method Summary collapse

Methods inherited from Plugin

#access_token

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
# File 'lib/see/plugins/github.rb', line 14

def run(config, plugin_config)
  info = []
  token = access_token('GITHUB_ACCESS_TOKEN')

   = plugin_config['account']
  repository = plugin_config['repository']
  github_name = [, repository].join '/'

  client = Octokit::Client.new :access_token => token
  pull_requests = client.pull_requests(github_name)
  info.concat(show_collection('Pull Requests', pull_requests))

  issues = client.issues(github_name)
  info.concat(show_collection('Issues', issues))
  info
end

#show_collection(name, collection) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/see/plugins/github.rb', line 31

def show_collection(name, collection)
  if collection.count == 0
    return ["  No open #{name.downcase}".yellow]
  end

  info = []
  info << "  Open #{name.downcase}:".light_blue
  info << collection.map do |github_object|
    username = "[#{github_object.user.}]".cyan
    time = "- #{github_object.updated_at.strftime("%b %e,%l:%M %p")}".black
    "    - #{github_object.title} #{username} #{time}"
  end
end