see 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/see.rb +1 -4
- data/lib/see/config.rb +18 -0
- data/lib/see/plugins.rb +36 -14
- data/lib/see/plugins/circle.rb +25 -25
- data/lib/see/plugins/github.rb +19 -27
- data/lib/see/plugins/pivotal.rb +11 -15
- data/lib/see/runner.rb +33 -33
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e47f55852b907f2b8f9a11d0c25d87cffe20f70
|
4
|
+
data.tar.gz: 54a4f9a4e89dc083415c94745b71689dbc79160f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfdd63c1919cdbf72082b65e3f5c7374d51c8f2c83558ffac215a70ecc176f64e5fcf815f4a3a0e9bc22a4683e6d76b85ae62c991ad1ca813f0b6b9865fb79ff
|
7
|
+
data.tar.gz: f3e9e3bef0b665e1fa860b87dafe026fec90fba94c1676f90eb8a19c2de2d9b2c7841fcd5d656d9e3e423eac28b7d9f2a31efb686c381c1d5d4c68f38d3e84d1
|
data/lib/see.rb
CHANGED
data/lib/see/config.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module See
|
4
|
+
module Config
|
5
|
+
def self.load
|
6
|
+
config_path = "#{Dir.pwd}/see.yml"
|
7
|
+
begin
|
8
|
+
config = YAML.load_file(config_path)
|
9
|
+
rescue => error
|
10
|
+
puts "No configuration file found (tried #{config_path})".yellow
|
11
|
+
puts ' (if the file exists it may be malformed)'
|
12
|
+
puts " #{error}".light_red
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
config
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/see/plugins.rb
CHANGED
@@ -1,25 +1,47 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
1
3
|
module See
|
2
4
|
module Plugins
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def self.find_plugins(name)
|
6
|
+
See::Plugins.constants.select do |const|
|
7
|
+
const != :Plugin
|
8
|
+
end.map do |const|
|
9
|
+
See::Plugins.const_get(const).new
|
8
10
|
end.select do |plugin|
|
9
11
|
plugin.config_name == name
|
10
12
|
end
|
11
|
-
|
12
|
-
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.run_plugin(name, config)
|
16
|
+
plugins = find_plugins(name)
|
13
17
|
if plugins.empty?
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
return ["\nNo plugin found with the name \"#{name}\"".light_red]
|
19
|
+
end
|
20
|
+
|
21
|
+
lines = ["\n"]
|
22
|
+
lines << plugins.map do |plugin|
|
23
|
+
lines_from_plugin = [plugin.display_name.light_magenta]
|
24
|
+
begin
|
25
|
+
lines_from_plugin << plugin.run(config, config[plugin.config_name])
|
26
|
+
rescue => error
|
27
|
+
lines_from_plugin << [" #{error.message}".red]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Plugin
|
33
|
+
def access_token(name)
|
34
|
+
token = ENV[name]
|
35
|
+
unless token
|
36
|
+
raise " You must set #{name} env variable"
|
20
37
|
end
|
38
|
+
token
|
21
39
|
end
|
22
|
-
lines
|
23
40
|
end
|
24
41
|
end
|
25
42
|
end
|
43
|
+
|
44
|
+
require_relative 'plugins/github'
|
45
|
+
require_relative 'plugins/pivotal'
|
46
|
+
require_relative 'plugins/travis'
|
47
|
+
require_relative 'plugins/circle'
|
data/lib/see/plugins/circle.rb
CHANGED
@@ -3,7 +3,7 @@ require 'circleci'
|
|
3
3
|
|
4
4
|
module See
|
5
5
|
module Plugins
|
6
|
-
class Circle
|
6
|
+
class Circle < Plugin
|
7
7
|
def display_name
|
8
8
|
'CircleCi'
|
9
9
|
end
|
@@ -12,43 +12,43 @@ module See
|
|
12
12
|
'circle'
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
token = ENV['CIRCLE_CI_ACCESS_TOKEN']
|
18
|
-
unless token
|
19
|
-
lines << " You must set CIRCLE_CI_ACCESS_TOKEN env variable".red
|
20
|
-
return lines
|
21
|
-
end
|
22
|
-
|
15
|
+
def latest_builds(account, repository, lines)
|
16
|
+
token = access_token('CIRCLE_CI_ACCESS_TOKEN')
|
23
17
|
CircleCi.configure do |cfg|
|
24
18
|
cfg.token = token
|
25
19
|
end
|
26
20
|
|
27
|
-
response = CircleCi::Project.recent_builds(
|
21
|
+
response = CircleCi::Project.recent_builds(account, repository)
|
28
22
|
if response.errors.length > 0
|
29
23
|
lines << " Errors encountered:".red
|
30
24
|
response.errors.each do |error|
|
31
25
|
lines << " - " + "Error #{error.code}:".red + " #{JSON.parse(error.message)['message'].strip}"
|
26
|
+
raise
|
32
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
response.body[0..4]
|
31
|
+
end
|
32
|
+
|
33
|
+
def run(config, plugin_config)
|
34
|
+
lines = []
|
35
|
+
|
36
|
+
begin
|
37
|
+
builds = latest_builds(plugin_config['account'], plugin_config['repository'], lines)
|
38
|
+
rescue => error
|
33
39
|
return lines
|
34
40
|
end
|
35
41
|
|
36
42
|
lines << " Latest Builds:".light_blue
|
37
|
-
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
if thing['committer_name']
|
47
|
-
name = "[#{thing['committer_name']}]".cyan
|
48
|
-
else
|
49
|
-
name = ""
|
50
|
-
end
|
51
|
-
lines << " - #{status.capitalize} #{thing["vcs_revision"][0..8].light_yellow} #{("#"+thing['build_num'].to_s).light_green} #{thing['subject']} #{name} #{time}"
|
43
|
+
lines << builds.map do |build|
|
44
|
+
time = "- #{Date.parse(build['committer_date']).strftime("%b %e,%l:%M %p")}".black if build['committer_date']
|
45
|
+
was_bad = build['status'].match(/failed|not_run/)
|
46
|
+
status = build['status'].capitalize.send(was_bad ? :red : :green)
|
47
|
+
name = "[#{build['committer_name']}]".cyan ||= ''
|
48
|
+
commit_id = build["vcs_revision"][0..8].light_yellow
|
49
|
+
build_number = ("#"+build['build_num'].to_s).light_green
|
50
|
+
|
51
|
+
" - #{status} #{commit_id} #{build_number} #{build['subject']} #{name} #{time}"
|
52
52
|
end
|
53
53
|
lines
|
54
54
|
end
|
data/lib/see/plugins/github.rb
CHANGED
@@ -2,7 +2,7 @@ require 'octokit'
|
|
2
2
|
|
3
3
|
module See
|
4
4
|
module Plugins
|
5
|
-
class GitHub
|
5
|
+
class GitHub < Plugin
|
6
6
|
def display_name
|
7
7
|
'GitHub'
|
8
8
|
end
|
@@ -13,42 +13,34 @@ module See
|
|
13
13
|
|
14
14
|
def run(config, plugin_config)
|
15
15
|
info = []
|
16
|
-
token =
|
17
|
-
unless token
|
18
|
-
info << " You must set GITHUB_ACCESS_TOKEN env variable".red
|
19
|
-
return info
|
20
|
-
end
|
16
|
+
token = access_token('GITHUB_ACCESS_TOKEN')
|
21
17
|
|
22
|
-
client = Octokit::Client.new :access_token => token
|
23
18
|
account = plugin_config['account']
|
24
19
|
repository = plugin_config['repository']
|
25
20
|
github_name = [account, repository].join '/'
|
26
21
|
|
22
|
+
client = Octokit::Client.new :access_token => token
|
27
23
|
pull_requests = client.pull_requests(github_name)
|
28
|
-
|
29
|
-
info << " Open pull requests:".light_blue
|
30
|
-
pull_requests.each do |pull_request|
|
31
|
-
username = "[#{pull_request.user.login}]".cyan
|
32
|
-
time = "- #{pull_request.updated_at.strftime("%b %e,%l:%M %p")}".black
|
33
|
-
info << " - #{pull_request.title} #{username} #{time}"
|
34
|
-
end
|
35
|
-
else
|
36
|
-
info << " No open pull requests".yellow
|
37
|
-
end
|
24
|
+
info.concat(show_collection('Pull Requests', pull_requests))
|
38
25
|
|
39
26
|
issues = client.issues(github_name)
|
40
|
-
|
41
|
-
info << " Open issues:".light_blue
|
42
|
-
issues.each do |issue|
|
43
|
-
username = "[#{issue.user.login}]".cyan
|
44
|
-
time = "- #{issue.updated_at.strftime("%b %e,%l:%M %p")}".black
|
45
|
-
info << " - #{issue.title} #{username} #{time}"
|
46
|
-
end
|
47
|
-
else
|
48
|
-
info << "No open issues".yellow
|
49
|
-
end
|
27
|
+
info.concat(show_collection('Issues', issues))
|
50
28
|
info
|
51
29
|
end
|
30
|
+
|
31
|
+
def show_collection(name, collection)
|
32
|
+
if collection.count == 0
|
33
|
+
return [" No open #{name.downcase}".yellow]
|
34
|
+
end
|
35
|
+
|
36
|
+
info = []
|
37
|
+
info << " Open #{name.downcase}:".light_blue
|
38
|
+
info << collection.map do |github_object|
|
39
|
+
username = "[#{github_object.user.login}]".cyan
|
40
|
+
time = "- #{github_object.updated_at.strftime("%b %e,%l:%M %p")}".black
|
41
|
+
" - #{github_object.title} #{username} #{time}"
|
42
|
+
end
|
43
|
+
end
|
52
44
|
end
|
53
45
|
end
|
54
46
|
end
|
data/lib/see/plugins/pivotal.rb
CHANGED
@@ -2,7 +2,7 @@ require 'pivotal-tracker'
|
|
2
2
|
|
3
3
|
module See
|
4
4
|
module Plugins
|
5
|
-
class Pivotal
|
5
|
+
class Pivotal < Plugin
|
6
6
|
def display_name
|
7
7
|
'Pivotal Tracker'
|
8
8
|
end
|
@@ -12,14 +12,10 @@ module See
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run(config, plugin_config)
|
15
|
-
|
16
|
-
token =
|
17
|
-
unless token
|
18
|
-
info << " You must set PIVOTAL_TRACKER_ACCESS_TOKEN env variable".red
|
19
|
-
return info
|
20
|
-
end
|
15
|
+
lines = []
|
16
|
+
@token = access_token('PIVOTAL_TRACKER_ACCESS_TOKEN')
|
21
17
|
|
22
|
-
PivotalTracker::Client.token = token
|
18
|
+
PivotalTracker::Client.token = @token
|
23
19
|
project = PivotalTracker::Project.find(plugin_config['project'])
|
24
20
|
|
25
21
|
next_unowned_story = nil
|
@@ -40,23 +36,23 @@ module See
|
|
40
36
|
end
|
41
37
|
|
42
38
|
if stories.length > 0
|
43
|
-
|
44
|
-
|
39
|
+
lines << " Stories being worked on:".light_blue
|
40
|
+
lines << stories
|
45
41
|
else
|
46
|
-
|
42
|
+
lines << " No stories being worked on".yellow
|
47
43
|
end
|
48
44
|
|
49
45
|
|
50
46
|
if next_unowned_story
|
51
|
-
|
47
|
+
lines << " Next story that can be worked on:".light_blue
|
52
48
|
time = "- #{next_unowned_story.created_at.strftime("%b %e,%l:%M %p")}".black
|
53
49
|
id = "#{next_unowned_story.id}".light_yellow
|
54
50
|
name = next_unowned_story.name
|
55
|
-
|
51
|
+
lines << " - #{id} #{name} #{time}"
|
56
52
|
else
|
57
|
-
|
53
|
+
lines << "No stories ready to work on".yellow
|
58
54
|
end
|
59
|
-
|
55
|
+
lines
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
data/lib/see/runner.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
module See
|
4
|
-
|
2
|
+
module Runner
|
5
3
|
def self.run
|
6
|
-
Runner.new.run
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
10
4
|
#
|
11
5
|
# Whole thing happens in two major steps:
|
12
6
|
# 1. load ./see.yml
|
@@ -15,41 +9,47 @@ module See
|
|
15
9
|
# 2. provide information from each configured plugin
|
16
10
|
# (provide content at the top and no content at the bottom)
|
17
11
|
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
puts "No configuration file found (tried #{config_path})".yellow
|
23
|
-
puts ' (if the file exists it may be malformed)'
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
|
27
|
-
progress = Thread.new do
|
28
|
-
print "Pulling data from #{config.length} source#{config.length == 1 ? '' : 's'}"
|
29
|
-
loop do
|
30
|
-
sleep 0.25
|
31
|
-
print '.'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
threads = []
|
36
|
-
config.each do |cfg|
|
37
|
-
threads << Thread.new do
|
12
|
+
config = See::Config.load
|
13
|
+
progress = ProgressIndicator.start(config.length)
|
14
|
+
threads = config.map do |cfg|
|
15
|
+
Thread.new do
|
38
16
|
begin
|
39
|
-
Thread.current[:lines] =
|
17
|
+
Thread.current[:lines] = See::Plugins.run_plugin(cfg[0], config)
|
40
18
|
rescue => error
|
41
|
-
Thread.current[:lines] =
|
42
|
-
Thread.current[:lines] << " #{error}".light_red
|
19
|
+
Thread.current[:lines] = "\nError running plugin: #{cfg[0]}".red
|
20
|
+
Thread.current[:lines] << "\n #{error}".light_red
|
43
21
|
end
|
44
22
|
end
|
45
23
|
end
|
46
24
|
|
47
|
-
lines = threads.map { |t| t.join[:lines].
|
48
|
-
progress.
|
25
|
+
lines = threads.map { |t| t.join[:lines] }.sort_by { |l| l[0] }
|
26
|
+
progress.stop
|
49
27
|
|
50
28
|
puts
|
51
|
-
lines.
|
29
|
+
lines.each { |t| puts t }
|
52
30
|
puts
|
53
31
|
end
|
32
|
+
|
33
|
+
class ProgressIndicator
|
34
|
+
def self.start(things_todo_count)
|
35
|
+
progress = ProgressIndicator.new
|
36
|
+
progress.start(things_todo_count)
|
37
|
+
progress
|
38
|
+
end
|
39
|
+
|
40
|
+
def start(things_todo_count)
|
41
|
+
@progress = Thread.new do
|
42
|
+
print "Pulling data from #{things_todo_count} source#{things_todo_count == 1 ? '' : 's'}"
|
43
|
+
loop do
|
44
|
+
sleep 0.25
|
45
|
+
print '.'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def stop
|
51
|
+
@progress.kill
|
52
|
+
end
|
53
|
+
end
|
54
54
|
end
|
55
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: see
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Avila
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- bin/see
|
133
|
+
- lib/see/config.rb
|
133
134
|
- lib/see/plugins.rb
|
134
135
|
- lib/see/plugins/github.rb
|
135
136
|
- lib/see/plugins/pivotal.rb
|