github-nippou 2.0.0.beta3 → 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/github/nippou.rb +3 -0
- data/lib/github/nippou/commands.rb +9 -55
- data/lib/github/nippou/concerns/sawyer_resource_github.rb +33 -0
- data/lib/github/nippou/concerns/string_markdown.rb +7 -0
- data/lib/github/nippou/user_events.rb +31 -6
- data/lib/github/nippou/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e04ff32f953611852d55ee08062486083beda4c6
|
4
|
+
data.tar.gz: 678f97c55b3b566e561c97b903fac0f517edea6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d1e69a9dd7ca65092a4e6b58d8194fcb1057c4b024eb69e3cf459cb1dc3a1fc5620159b6e25ea79368aeed818ccee5eb0343bb7c32870c30a4255da787a6f4
|
7
|
+
data.tar.gz: db8c91944b4d351c16c75263e89d66a5c7a92ef17acffd61edc576100cc748d336be022426c738d13011e589e82db5b95829d8bb0964e2af34bb30567ca86183
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,7 @@ $ github-nippou help
|
|
33
33
|
Commands:
|
34
34
|
github-nippou help [COMMAND] # Describe available commands or one specific command
|
35
35
|
github-nippou list # Displays today's GitHub events formatted for Nippou
|
36
|
+
github-nippou version # Displays version
|
36
37
|
|
37
38
|
Options:
|
38
39
|
s, [--since-date=SINCE_DATE] # Retrieves GitHub user_events since the date
|
data/lib/github/nippou.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
require 'thor'
|
2
2
|
|
3
|
-
module StringExMarkdown
|
4
|
-
refine String do
|
5
|
-
def markdown_escape
|
6
|
-
self.gsub(/([`<>])/, '\\\\\1')
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
3
|
module Github
|
12
4
|
module Nippou
|
13
5
|
class Commands < Thor
|
14
|
-
using
|
6
|
+
using SawyerResourceGithub
|
7
|
+
using StringMarkdown
|
15
8
|
|
16
9
|
default_task :list
|
17
10
|
class_option :since_date, type: :string,
|
@@ -23,11 +16,13 @@ module Github
|
|
23
16
|
|
24
17
|
desc 'list', "Displays today's GitHub events formatted for Nippou"
|
25
18
|
def list
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
user_events.each do |user_event|
|
20
|
+
issue = user_event.issue(client)
|
21
|
+
line = "* [%s - %s](%s) by %s" %
|
22
|
+
[issue.title.markdown_escape, user_event.repo.name, user_event.html_url, issue.user.login]
|
23
|
+
if issue.merged
|
29
24
|
line << ' **merged!**'
|
30
|
-
elsif
|
25
|
+
elsif issue.state == 'closed'
|
31
26
|
line << ' **closed!**'
|
32
27
|
end
|
33
28
|
puts line
|
@@ -41,27 +36,10 @@ module Github
|
|
41
36
|
|
42
37
|
private
|
43
38
|
|
44
|
-
def nippous
|
45
|
-
result = {}
|
46
|
-
|
47
|
-
user_events.each do |user_event|
|
48
|
-
case user_event.type
|
49
|
-
when 'IssuesEvent', 'IssueCommentEvent'
|
50
|
-
issue = user_event.payload.issue
|
51
|
-
result[issue.html_url] ||= hash_for_issue(user_event.repo.name, issue.number)
|
52
|
-
when 'PullRequestEvent', 'PullRequestReviewCommentEvent'
|
53
|
-
pr = user_event.payload.pull_request
|
54
|
-
result[pr.html_url] ||= hash_for_pr(user_event.repo.name, pr.number)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
result.sort
|
59
|
-
end
|
60
|
-
|
61
39
|
def user_events
|
62
40
|
@user_events ||= UserEvents.new(
|
63
41
|
client, user, options[:since_date], options[:until_date]
|
64
|
-
).
|
42
|
+
).collect
|
65
43
|
end
|
66
44
|
|
67
45
|
def client
|
@@ -106,30 +84,6 @@ MESSAGE
|
|
106
84
|
exit!
|
107
85
|
end
|
108
86
|
end
|
109
|
-
|
110
|
-
def hash_for_issue(repo_name, issue_number)
|
111
|
-
issue = client.issue(repo_name, issue_number)
|
112
|
-
|
113
|
-
{
|
114
|
-
title: issue.title.markdown_escape,
|
115
|
-
repo_basename: repo_name,
|
116
|
-
username: issue.user.login,
|
117
|
-
merged: issue.merged,
|
118
|
-
state: issue.state,
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
def hash_for_pr(repo_name, pr_number)
|
123
|
-
pr = client.pull_request(repo_name, pr_number)
|
124
|
-
|
125
|
-
{
|
126
|
-
title: pr.title.markdown_escape,
|
127
|
-
repo_basename: repo_name,
|
128
|
-
username: pr.user.login,
|
129
|
-
merged: pr.merged,
|
130
|
-
state: pr.state,
|
131
|
-
}
|
132
|
-
end
|
133
87
|
end
|
134
88
|
end
|
135
89
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module SawyerResourceGithub
|
4
|
+
refine Sawyer::Resource do
|
5
|
+
def issue(client)
|
6
|
+
case
|
7
|
+
when self.issue?
|
8
|
+
client.issue(self.repo.name, self.payload.issue.number)
|
9
|
+
when self.pull_request?
|
10
|
+
client.pull_request(self.repo.name, self.payload.pull_request.number)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def html_url
|
15
|
+
case
|
16
|
+
when self.issue?
|
17
|
+
self.payload.issue.html_url
|
18
|
+
when self.pull_request?
|
19
|
+
self.payload.pull_request.html_url
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def issue?
|
24
|
+
self.type == 'IssuesEvent' ||
|
25
|
+
self.type == 'IssueCommentEvent'
|
26
|
+
end
|
27
|
+
|
28
|
+
def pull_request?
|
29
|
+
self.type == 'PullRequestEvent' ||
|
30
|
+
self.type == 'PullRequestReviewCommentEvent'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -4,13 +4,22 @@ require 'octokit'
|
|
4
4
|
module Github
|
5
5
|
module Nippou
|
6
6
|
class UserEvents
|
7
|
+
using SawyerResourceGithub
|
8
|
+
|
7
9
|
def initialize(client, user, since_date, until_date)
|
8
10
|
@client = client
|
9
11
|
@user = user
|
10
|
-
@
|
11
|
-
|
12
|
+
@since_time = Time.parse(since_date).beginning_of_day
|
13
|
+
until_time = Time.parse(until_date).end_of_day
|
14
|
+
@range = @since_time..until_time
|
15
|
+
end
|
16
|
+
|
17
|
+
def collect
|
18
|
+
uniq(sort(filter(retrieve)))
|
12
19
|
end
|
13
20
|
|
21
|
+
private
|
22
|
+
|
14
23
|
def retrieve
|
15
24
|
user_events = @client.user_events(@user, per_page: 100)
|
16
25
|
last_response = @client.last_response
|
@@ -23,15 +32,31 @@ module Github
|
|
23
32
|
user_events.select { |user_event| in_range?(user_event) }
|
24
33
|
end
|
25
34
|
|
26
|
-
private
|
27
|
-
|
28
35
|
def continue?(last_response, user_events)
|
29
36
|
last_response.rels[:next] &&
|
30
|
-
user_events.last.created_at.getlocal >= @
|
37
|
+
user_events.last.created_at.getlocal >= @since_time
|
31
38
|
end
|
32
39
|
|
33
40
|
def in_range?(user_event)
|
34
|
-
|
41
|
+
@range.include?(user_event.created_at.getlocal)
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter(user_events)
|
45
|
+
user_events.select do |user_event|
|
46
|
+
user_event.issue? || user_event.pull_request?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def sort(user_events)
|
51
|
+
user_events.sort do |a, b|
|
52
|
+
a.html_url <=> b.html_url
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def uniq(user_events)
|
57
|
+
user_events.uniq do |user_event|
|
58
|
+
user_event.html_url
|
59
|
+
end
|
35
60
|
end
|
36
61
|
end
|
37
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-nippou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Masuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- github-nippou.gemspec
|
101
101
|
- lib/github/nippou.rb
|
102
102
|
- lib/github/nippou/commands.rb
|
103
|
+
- lib/github/nippou/concerns/sawyer_resource_github.rb
|
104
|
+
- lib/github/nippou/concerns/string_markdown.rb
|
103
105
|
- lib/github/nippou/user_events.rb
|
104
106
|
- lib/github/nippou/version.rb
|
105
107
|
homepage: https://github.com/masutaka/github-nippou
|