openpull 0.0.5 → 0.0.6
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/bin/openpull +1 -1
- data/lib/openpull/pull_request_decorator.rb +15 -0
- data/lib/openpull/pull_request_fetcher.rb +20 -21
- data/lib/openpull/runner.rb +75 -43
- data/lib/openpull/table.rb +3 -1
- data/lib/openpull/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11ac4753168a18e414bf437e328e2a6981bcb623
|
4
|
+
data.tar.gz: d51ca5e3ee7caa640623de403694c0c46a166315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f3741087b5ce398d095b22ca2c884f18b930441fdbd745659970115f63d53a529cfcf2f03beb6a5f9379784c7c83a58e45a5a8d8a7f4a197760544d87524ab7
|
7
|
+
data.tar.gz: 492bad90f158ad4c15f6314f8586b1bfb213b9befd7dce04c3a77698441f6ab768ccc19e77f18e1ebbf2a0ca4b1ebdd5f77cc98c1cbcee53493d27b6e143c3cc
|
data/bin/openpull
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
module OpenPull
|
2
2
|
class PullRequestDecorator < ::SimpleDelegator
|
3
|
+
def as_row(username)
|
4
|
+
[title, user(username), labels, status, commits, comments, mergeable,
|
5
|
+
html_url.underline, updated_at]
|
6
|
+
end
|
7
|
+
|
3
8
|
def title
|
4
9
|
title = super
|
5
10
|
return title if title.size <= 80
|
@@ -32,6 +37,16 @@ module OpenPull
|
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
40
|
+
def commits
|
41
|
+
num = rels[:commits].get.data.size
|
42
|
+
num == 0 ? '' : num
|
43
|
+
end
|
44
|
+
|
45
|
+
def comments
|
46
|
+
num = rels[:review_comments].get.data.size
|
47
|
+
num == 0 ? '' : num
|
48
|
+
end
|
49
|
+
|
35
50
|
def mergeable
|
36
51
|
super ? 'Yes'.green : 'No'.red
|
37
52
|
end
|
@@ -9,9 +9,11 @@ module OpenPull
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def fetch
|
12
|
-
client.org_repos(organisation).map do |repository|
|
12
|
+
repos = client.org_repos(organisation).map do |repository|
|
13
13
|
Thread.new { fetch_pull_requests(repository) }
|
14
|
-
end.map(&:value)
|
14
|
+
end.map(&:value)
|
15
|
+
|
16
|
+
repos.reject { |v| v.nil? || v.empty? }
|
15
17
|
end
|
16
18
|
|
17
19
|
private
|
@@ -22,35 +24,32 @@ module OpenPull
|
|
22
24
|
pull_requests = client.pull_requests(repository.id, state: 'open')
|
23
25
|
return [] if pull_requests.empty?
|
24
26
|
|
25
|
-
headers = ["#{repository.name} (#{pull_requests.size})"]
|
26
|
-
headers << (repository.private ? 'private' : 'public')
|
27
|
-
headers += ['', '', '']
|
28
|
-
headers << repository.html_url
|
29
|
-
headers << ''
|
30
|
-
headers.map! { |h| h.blue.bold }
|
31
|
-
|
32
27
|
results = pull_requests.map do |pr|
|
33
28
|
Thread.new { row(pr) }
|
34
29
|
end.map(&:value)
|
35
30
|
|
36
|
-
[headers] + results
|
31
|
+
[headers(repository, results.size)] + results
|
32
|
+
end
|
33
|
+
|
34
|
+
def headers(repository, size)
|
35
|
+
visibility = repository.private ? 'private' : 'public'
|
36
|
+
|
37
|
+
[
|
38
|
+
"#{repository.name} (#{size})",
|
39
|
+
visibility
|
40
|
+
] +
|
41
|
+
[''] * 5 +
|
42
|
+
[
|
43
|
+
repository.html_url,
|
44
|
+
''
|
45
|
+
].map { |h| h.blue.bold }
|
37
46
|
end
|
38
47
|
|
39
48
|
def row(pr)
|
40
49
|
print '.'.yellow
|
41
50
|
|
42
51
|
pr_data = pr.rels[:self].get.data
|
43
|
-
|
44
|
-
|
45
|
-
[
|
46
|
-
deco_pr.title,
|
47
|
-
deco_pr.user(username),
|
48
|
-
deco_pr.labels,
|
49
|
-
deco_pr.status,
|
50
|
-
deco_pr.mergeable,
|
51
|
-
deco_pr.html_url.underline,
|
52
|
-
deco_pr.updated_at
|
53
|
-
]
|
52
|
+
OpenPull::PullRequestDecorator.new(pr_data).as_row(username)
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
data/lib/openpull/runner.rb
CHANGED
@@ -2,10 +2,16 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module OpenPull
|
4
4
|
class Runner
|
5
|
+
class << self
|
6
|
+
def run(argv = [])
|
7
|
+
new(argv).run
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
attr_reader :argv
|
6
12
|
attr_accessor :options
|
7
13
|
|
8
|
-
def initialize(argv)
|
14
|
+
def initialize(argv = [])
|
9
15
|
@argv = argv
|
10
16
|
@options = {}
|
11
17
|
end
|
@@ -13,64 +19,90 @@ module OpenPull
|
|
13
19
|
def run
|
14
20
|
op = option_parser
|
15
21
|
op.parse!
|
16
|
-
|
22
|
+
check_options(op)
|
17
23
|
|
18
24
|
puts OpenPull::Client.new(@options[:access_token],
|
19
25
|
@options[:organisation],
|
20
26
|
@options[:username]).show_table
|
21
|
-
|
22
27
|
end
|
23
28
|
|
24
29
|
private
|
25
30
|
|
26
31
|
def option_parser
|
27
32
|
OptionParser.new do |opts|
|
28
|
-
opts
|
29
|
-
|
30
|
-
opts
|
31
|
-
opts.separator 'Organisation and username can also be set in the ' \
|
32
|
-
'environment as GITHUB_ORGANISATION and GITHUB_USERNAME.'
|
33
|
-
opts.separator ''
|
34
|
-
|
35
|
-
opts.separator 'Options:'
|
36
|
-
|
37
|
-
opts.on_tail('-h', '--help', 'Show this message') do
|
38
|
-
puts opts
|
39
|
-
exit
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on_tail('--version', 'Show version') do
|
43
|
-
puts OpenPull::VERSION
|
44
|
-
exit
|
45
|
-
end
|
46
|
-
|
47
|
-
@options[:organisation] = ENV['GITHUB_ORGANISATION']
|
48
|
-
opts.on('-o', '--organisation [ORG]', String, 'The Github organisation') do |o|
|
49
|
-
@options[:organisation] = o
|
50
|
-
end
|
51
|
-
|
52
|
-
@options[:username] = ENV['GITHUB_USERNAME']
|
53
|
-
opts.on('-u', '--username [USER]', String, 'Your Github username') do |u|
|
54
|
-
@options[:username] = u
|
55
|
-
end
|
33
|
+
parse_banner(opts)
|
34
|
+
parse_options(opts)
|
35
|
+
parse_values(opts)
|
56
36
|
end
|
57
37
|
end
|
58
38
|
|
59
|
-
def
|
60
|
-
|
39
|
+
def parse_banner(opts)
|
40
|
+
opts.banner = 'Usage: openpull [options]'
|
41
|
+
|
42
|
+
opts.separator ''
|
43
|
+
opts.separator 'Organisation and username can also be set in the ' \
|
44
|
+
'environment as GITHUB_ORGANISATION and GITHUB_USERNAME.'
|
45
|
+
opts.separator ''
|
46
|
+
end
|
47
|
+
|
48
|
+
def parse_options(opts)
|
49
|
+
opts.separator 'Options:'
|
50
|
+
|
51
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
52
|
+
puts opts
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on_tail('--version', 'Show version') do
|
57
|
+
puts OpenPull::VERSION
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_values(opts)
|
63
|
+
parse_organisation(opts)
|
64
|
+
parse_username(opts)
|
65
|
+
end
|
61
66
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
puts "\n#{op}"
|
70
|
-
return false
|
67
|
+
def parse_organisation(opts)
|
68
|
+
@options[:organisation] = ENV['GITHUB_ORGANISATION']
|
69
|
+
opts.on('-o',
|
70
|
+
'--organisation [ORG]',
|
71
|
+
String,
|
72
|
+
'The Github organisation') do |o|
|
73
|
+
@options[:organisation] = o
|
71
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def parse_username(opts)
|
78
|
+
@options[:username] = ENV['GITHUB_USERNAME']
|
79
|
+
opts.on('-u',
|
80
|
+
'--username [USER]',
|
81
|
+
String,
|
82
|
+
'Your Github username') do |u|
|
83
|
+
@options[:username] = u
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def check_options(op)
|
88
|
+
check_access_token
|
89
|
+
check_organisation(op)
|
90
|
+
end
|
91
|
+
|
92
|
+
def check_access_token
|
93
|
+
@options[:access_token] = ENV['GITHUB_ACCESS_TOKEN']
|
94
|
+
return unless @options[:access_token].nil?
|
95
|
+
puts 'You need to set the GitHub access token in your environment. ' \
|
96
|
+
'(GITHUB_ACCESS_TOKEN)'
|
97
|
+
exit
|
98
|
+
end
|
72
99
|
|
73
|
-
|
100
|
+
def check_organisation(op)
|
101
|
+
return unless @options[:organisation].nil?
|
102
|
+
puts 'You need to either pass GitHub organisation or set it in your ' \
|
103
|
+
'environment. (GITHUB_ORGANISATION)'
|
104
|
+
puts "\n#{op}"
|
105
|
+
exit
|
74
106
|
end
|
75
107
|
end
|
76
108
|
end
|
data/lib/openpull/table.rb
CHANGED
data/lib/openpull/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openpull
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mads Ohm Larsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.31'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.31'
|
69
83
|
description: Fetches open pull-requests, with status and mergability, in your organisation.
|
70
84
|
email: mads.ohm@gmail.com
|
71
85
|
executables:
|