github_issue_stats 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/github_issue_stats +44 -87
- data/lib/github_issue_stats.rb +2 -2
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae17636f4ac0fbedef888f294dc9a493e2dd1c88
|
4
|
+
data.tar.gz: 19b0639e7a6341f463dc784f631a9b193af550af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab26cc8b8bb2832c6a86fc35e400379e477455a142e06378915cdc4910cb2a6cff2d511b3de999967a3986dbba1e581ddee79d6249d028646cf6971a7a5faa3e
|
7
|
+
data.tar.gz: 9eb615a02c1ffd81ba6621def0b510d219d693743e87f3df161898e83491ea4bacf99115de7f38be3a3ad2f3c11e90bc2b3e9c1801ea2a455c520dd8e31a8132
|
data/bin/github_issue_stats
CHANGED
@@ -1,108 +1,65 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "commander"
|
3
4
|
require "optparse"
|
4
5
|
require "github_issue_stats"
|
5
6
|
|
6
7
|
ARGV.push('-h') if ARGV.empty?
|
7
8
|
|
8
|
-
|
9
|
+
cli = HighLine.new($stdin, $stderr)
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
options[:interval_length] = "1w"
|
15
|
-
options[:interval_count] = 4
|
11
|
+
Commander.configure do
|
12
|
+
program :name, 'GitHub Issue Stats'
|
13
|
+
program :version, GitHubIssueStats::VERSION
|
14
|
+
program :description, 'Simple program for collecting stats on issues in GitHub repositories.'
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
global_option '--verbose', "Enable output of detailed debugging information to STDERR"
|
17
|
+
global_option '--token STRING', String, "GitHub OAuth token for making API calls. If not specified, the GITHUB_OAUTH_TOKEN environment variable is used. Create a token here: https://github.com/settings/token"
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
command :history do |c|
|
20
|
+
c.syntax = 'github_issue_stats history [options]'
|
21
|
+
c.description = 'Collect stats on number of open issues over time'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
c.option '-s', '--scopes x,y,z', Array, "(required) List of scopes for which stats will be collected. A scope is a username or repo name. Example: --scopes github,rails/rails"
|
24
|
+
c.option '-l', '--labels [x,y,z]', Array, "List of labels for which stats will be collected for each scope. A label is an issue or pull request label, or special values 'issues' and 'pulls' representing all issues and all pull requests within the scope respectively. Default: 'issues'."
|
25
|
+
c.option '-i', '--interval_length [STRING]', String, "Size of interval for which stats will be aggregated. Intervals are defined with N[hdwmy], where h is hour, d is day, w is week m is month, y is year, and N is a positive integer used as a multiplier. Default: '1w'."
|
26
|
+
c.option '-n', '--interval_count [INTEGER]', Integer, "Number of intervals for which stats will be collected. Default: 4."
|
27
|
+
c.option '-o', '--output_format [STRING]', String, "Format used for output tables with collected stats. Can be 'text' or 'markdown'."
|
29
28
|
|
30
|
-
|
31
|
-
"List of scopes for which stats will be collected. A scope is",
|
32
|
-
"a username or repo name. Example: --scopes github,rails/rails", "\n") do |scopes|
|
33
|
-
options[:scopes] = scopes
|
34
|
-
end
|
29
|
+
c.example "Statistics for the atom organization, for issues, pull requests, bug and enhancement labels, going back four one-week intervals, with Markdown output", "github_issue_stats history -s atom -l issues,bug,enhancement,pulls -i 1w -n 4 -o markdown"
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
c.action do |args, options|
|
32
|
+
options.default \
|
33
|
+
:verbose => false,
|
34
|
+
:token => ENV["GITHUB_OAUTH_TOKEN"],
|
35
|
+
:output_format => 'text',
|
36
|
+
:labels => "issues",
|
37
|
+
:interval_length => "1w",
|
38
|
+
:interval_count => 4
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
"are defined with N[hdwmy], where h is hour, d is day, w is week",
|
48
|
-
"m is month, y is year, and N is a positive integer used as a",
|
49
|
-
"multiplier. Default: '1w'. Example: --interval_length 4d", "\n") do |interval_length|
|
50
|
-
options[:interval_length] = interval_length
|
51
|
-
end
|
40
|
+
options.scopes = Array(options.scopes)
|
41
|
+
options.labels = Array(options.labels)
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
43
|
+
raise ArgumentError.new("--token is required") if options.token.nil?
|
44
|
+
raise ArgumentError.new("invalid --token format") unless /\A\h{40}\z/.match(options.token)
|
45
|
+
raise ArgumentError.new("--scopes is required") if options.scopes.nil?
|
46
|
+
raise ArgumentError.new("invalid --interval_length format") unless /\A\d[hdwmy]\z/.match(options.interval_length)
|
47
|
+
raise ArgumentError.new("invalid --interval_count format") if options.interval_count.nil? || options.interval_count < 1
|
48
|
+
raise ArgumentError.new("invalid --output_format") unless /\A(text)|(markdown)\z/.match(options.output_format)
|
58
49
|
|
59
|
-
|
60
|
-
"Format used for output tables with collected stats. Can be",
|
61
|
-
"'text' or 'markdown'. Default: 'text'. Example: -o markdown", "\n") do |output_format|
|
62
|
-
options[:output_format] = output_format
|
63
|
-
end
|
50
|
+
github_issue_stats = GitHubIssueStats.new(options.token, options.verbose)
|
64
51
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
52
|
+
STDERR.print "Collecting stats..."
|
53
|
+
STDERR.flush
|
68
54
|
|
69
|
-
|
70
|
-
|
71
|
-
exit
|
72
|
-
end
|
55
|
+
stats = github_issue_stats.get_history_statistics(options.__hash__)
|
56
|
+
tables = github_issue_stats.generate_tables(stats, options.__hash__)
|
73
57
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
58
|
+
for scope, table in tables
|
59
|
+
puts "\n#{scope} stats:\n\n#{table}"
|
60
|
+
end
|
79
61
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
STDERR.puts("ERROR: #{message}\n\n")
|
84
|
-
STDERR.puts(opt_parser)
|
85
|
-
exit
|
86
|
-
end
|
87
|
-
|
88
|
-
log_input_error("--token is required", opt_parser) if options[:token].nil?
|
89
|
-
log_input_error("invalid --token format", opt_parser) unless /\A\h{40}\z/.match(options[:token])
|
90
|
-
log_input_error("--scopes is required", opt_parser) if options[:scopes].nil?
|
91
|
-
log_input_error("invalid --interval_length format", opt_parser) unless /\A\d[hdwmy]\z/.match(options[:interval_length])
|
92
|
-
log_input_error("invalid --interval_count format", opt_parser) if options[:interval_count].nil? || options[:interval_count] < 1
|
93
|
-
log_input_error("invalid --output_format", opt_parser) unless /\A(text)|(markdown)\z/.match(options[:output_format])
|
94
|
-
|
95
|
-
options[:scopes] = Array(options[:scopes])
|
96
|
-
options[:labels] = Array(options[:labels])
|
97
|
-
|
98
|
-
github_issue_stats = GitHubIssueStats.new(options[:token], options[:verbose])
|
99
|
-
|
100
|
-
STDERR.print "Collecting stats..."
|
101
|
-
STDERR.flush
|
102
|
-
|
103
|
-
stats = github_issue_stats.get_statistics(options)
|
104
|
-
tables = github_issue_stats.generate_tables(stats, options)
|
105
|
-
|
106
|
-
for scope, table in tables
|
107
|
-
puts "\n#{scope} stats:\n\n#{table}"
|
62
|
+
cli.say("Done!")
|
63
|
+
end
|
64
|
+
end
|
108
65
|
end
|
data/lib/github_issue_stats.rb
CHANGED
@@ -30,7 +30,7 @@ module Enumerable
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class GitHubIssueStats
|
33
|
-
VERSION = "0.
|
33
|
+
VERSION = "0.3.0"
|
34
34
|
|
35
35
|
attr_accessor :client, # Octokit client for acesing the API
|
36
36
|
:logger, # Logger for writing debugging info
|
@@ -89,7 +89,7 @@ class GitHubIssueStats
|
|
89
89
|
# }
|
90
90
|
# ]
|
91
91
|
#
|
92
|
-
def
|
92
|
+
def get_history_statistics(options)
|
93
93
|
# number_of_calls = get_required_number_of_api_calls(options)
|
94
94
|
# @sleep_period = get_api_calls_sleep(number_of_calls)
|
95
95
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_issue_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zuzak
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.3'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: octokit
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|