github-nippou 1.2.0 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +14 -1
- data/github-nippou.gemspec +1 -0
- data/lib/github/nippou.rb +1 -0
- data/lib/github/nippou/commands.rb +33 -28
- data/lib/github/nippou/user_events.rb +32 -0
- data/lib/github/nippou/version.rb +1 -1
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f0f13ef8692fd47c64b7406283ad0aa0fc38591
|
4
|
+
data.tar.gz: 567ff11a390184d4e85e1c7ca04f02d74d25a7d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7173ae0ab09b35cff1bc6529f231fc1d6ddff2605134d591409493fef445d231932ee2b5ceb3b0fd50acbf792e2353040d216860ceac7ae733f2c9fa4816549a
|
7
|
+
data.tar.gz: 4e234ec0584549fb6eaa188f73acbf8037db618730d845a66e4cac520c48cf6acad5b98467c9599e0111fa604ed560c49733136ef80c690d63ee732b83b0c056
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-nippou (
|
4
|
+
github-nippou (2.0.0.beta1)
|
5
|
+
activesupport
|
5
6
|
octokit
|
6
7
|
thor
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
12
|
+
activesupport (4.2.6)
|
13
|
+
i18n (~> 0.7)
|
14
|
+
json (~> 1.7, >= 1.7.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
17
|
+
tzinfo (~> 1.1)
|
11
18
|
addressable (2.4.0)
|
12
19
|
faraday (0.9.2)
|
13
20
|
multipart-post (>= 1.2, < 3)
|
21
|
+
i18n (0.7.0)
|
22
|
+
json (1.8.3)
|
23
|
+
minitest (5.8.4)
|
14
24
|
multipart-post (2.0.0)
|
15
25
|
octokit (4.3.0)
|
16
26
|
sawyer (~> 0.7.0, >= 0.5.3)
|
@@ -19,6 +29,9 @@ GEM
|
|
19
29
|
addressable (>= 2.3.5, < 2.5)
|
20
30
|
faraday (~> 0.8, < 0.10)
|
21
31
|
thor (0.19.1)
|
32
|
+
thread_safe (0.3.5)
|
33
|
+
tzinfo (1.2.2)
|
34
|
+
thread_safe (~> 0.1)
|
22
35
|
|
23
36
|
PLATFORMS
|
24
37
|
ruby
|
data/github-nippou.gemspec
CHANGED
data/lib/github/nippou.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'octokit'
|
2
1
|
require 'thor'
|
3
2
|
|
4
3
|
module StringExMarkdown
|
@@ -15,8 +14,9 @@ module Github
|
|
15
14
|
using StringExMarkdown
|
16
15
|
|
17
16
|
default_task :list
|
18
|
-
class_option :
|
19
|
-
|
17
|
+
class_option :since_date, type: :string,
|
18
|
+
default: Time.now.strftime('%Y%m%d'),
|
19
|
+
aliases: :s, desc: 'Retrieves GitHub user_events since the date'
|
20
20
|
|
21
21
|
desc 'list', "Displays today's GitHub events formatted for Nippou"
|
22
22
|
def list
|
@@ -35,30 +35,25 @@ module Github
|
|
35
35
|
|
36
36
|
def nippous
|
37
37
|
result = {}
|
38
|
-
now = Time.now
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
case event.type
|
39
|
+
user_events.each do |user_event|
|
40
|
+
case user_event.type
|
44
41
|
when 'IssuesEvent', 'IssueCommentEvent'
|
45
|
-
issue =
|
46
|
-
result[issue.html_url] ||= hash_for_issue(
|
42
|
+
issue = user_event.payload.issue
|
43
|
+
result[issue.html_url] ||= hash_for_issue(user_event.repo.name, issue.number)
|
47
44
|
when 'PullRequestEvent', 'PullRequestReviewCommentEvent'
|
48
|
-
pr =
|
49
|
-
result[pr.html_url] ||= hash_for_pr(
|
45
|
+
pr = user_event.payload.pull_request
|
46
|
+
result[pr.html_url] ||= hash_for_pr(user_event.repo.name, pr.number)
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
50
|
result.sort
|
54
51
|
end
|
55
52
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
event.created_at.getlocal.to_date != now.to_date
|
61
|
-
end
|
53
|
+
def user_events
|
54
|
+
@user_events ||= UserEvents.new(
|
55
|
+
client, user, options[:since_date]
|
56
|
+
).retrieve
|
62
57
|
end
|
63
58
|
|
64
59
|
def client
|
@@ -104,18 +99,28 @@ MESSAGE
|
|
104
99
|
end
|
105
100
|
end
|
106
101
|
|
107
|
-
def hash_for_issue(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
102
|
+
def hash_for_issue(repo_name, issue_number)
|
103
|
+
issue = client.issue(repo_name, issue_number)
|
104
|
+
|
105
|
+
{
|
106
|
+
title: issue.title.markdown_escape,
|
107
|
+
repo_basename: repo_name,
|
108
|
+
username: issue.user.login,
|
109
|
+
merged: client.pull_merged?(repo_name, issue.number),
|
110
|
+
state: issue.state,
|
111
|
+
}
|
112
112
|
end
|
113
113
|
|
114
|
-
def hash_for_pr(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
def hash_for_pr(repo_name, pr_number)
|
115
|
+
pr = client.pull_request(repo_name, pr_number)
|
116
|
+
|
117
|
+
{
|
118
|
+
title: pr.title.markdown_escape,
|
119
|
+
repo_basename: repo_name,
|
120
|
+
username: pr.user.login,
|
121
|
+
merged: client.pull_merged?(repo_name, pr.number),
|
122
|
+
state: pr.state,
|
123
|
+
}
|
119
124
|
end
|
120
125
|
end
|
121
126
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'active_support/time'
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
module Github
|
5
|
+
module Nippou
|
6
|
+
class UserEvents
|
7
|
+
def initialize(client, user, since_date)
|
8
|
+
@client = client
|
9
|
+
@user = user
|
10
|
+
@range = Time.parse(since_date)..Time.now.end_of_day
|
11
|
+
end
|
12
|
+
|
13
|
+
def retrieve
|
14
|
+
user_events = @client.user_events(@user)
|
15
|
+
last_response = @client.last_response
|
16
|
+
|
17
|
+
while last_response.rels[:next] && in_range?(user_events.last)
|
18
|
+
last_response = last_response.rels[:next].get
|
19
|
+
user_events.concat(last_response.data)
|
20
|
+
end
|
21
|
+
|
22
|
+
user_events.select { |user_event| in_range?(user_event) }
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def in_range?(user_event)
|
28
|
+
@range.include?(user_event.created_at.getlocal)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-nippou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: octokit
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +100,7 @@ files:
|
|
86
100
|
- github-nippou.gemspec
|
87
101
|
- lib/github/nippou.rb
|
88
102
|
- lib/github/nippou/commands.rb
|
103
|
+
- lib/github/nippou/user_events.rb
|
89
104
|
- lib/github/nippou/version.rb
|
90
105
|
homepage: https://github.com/masutaka/github-nippou
|
91
106
|
licenses:
|
@@ -102,12 +117,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
117
|
version: '0'
|
103
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
119
|
requirements:
|
105
|
-
- - "
|
120
|
+
- - ">"
|
106
121
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
122
|
+
version: 1.3.1
|
108
123
|
requirements: []
|
109
124
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.5.1
|
111
126
|
signing_key:
|
112
127
|
specification_version: 4
|
113
128
|
summary: Print today's your GitHub action.
|