github-nippou 2.0.0.beta5 → 2.0.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/github-nippou.gemspec +1 -0
- data/lib/github/nippou/commands.rb +15 -17
- data/lib/github/nippou/concerns/sawyer_resource_github.rb +3 -14
- data/lib/github/nippou/concerns/string_markdown.rb +1 -1
- data/lib/github/nippou/user_events.rb +4 -1
- data/lib/github/nippou/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: 79390fbd81c7c4d4b3d1fe9443f882ab52f8d894
|
4
|
+
data.tar.gz: 10a6ee01658bf337a39f8599e018536e8c0593a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63d33966ebd8cd63886832a68f0c490845cb1e896942c807fe2ef5a1c196684385bbdc4786d188608ccb1df87f9f27dbbc3262d0c21a253a4e50a26751edb0e4
|
7
|
+
data.tar.gz: eb3430e7111a0750764415f258196e8331b7f7ee5699e08f23d06f0f09ce4f122fdc5167cc104a09ebca9a40d0936a0d0462f4c0be71039a5a3a2e34e75d72bd
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-nippou (2.0.0.
|
4
|
+
github-nippou (2.0.0.beta6)
|
5
5
|
activesupport
|
6
6
|
octokit
|
7
|
+
parallel
|
7
8
|
thor
|
8
9
|
|
9
10
|
GEM
|
@@ -24,6 +25,7 @@ GEM
|
|
24
25
|
multipart-post (2.0.0)
|
25
26
|
octokit (4.3.0)
|
26
27
|
sawyer (~> 0.7.0, >= 0.5.3)
|
28
|
+
parallel (1.8.0)
|
27
29
|
rake (11.1.1)
|
28
30
|
sawyer (0.7.0)
|
29
31
|
addressable (>= 2.3.5, < 2.5)
|
data/github-nippou.gemspec
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'parallel'
|
1
2
|
require 'thor'
|
2
3
|
|
3
4
|
module Github
|
@@ -17,19 +18,12 @@ module Github
|
|
17
18
|
desc 'list', "Displays today's GitHub events formatted for Nippou"
|
18
19
|
def list
|
19
20
|
lines = []
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
threads << Thread.start do
|
26
|
-
while user_event = mutex1.synchronize { user_events.pop } do
|
27
|
-
line = format_line(user_event, i)
|
28
|
-
mutex2.synchronize { lines << line }
|
29
|
-
end
|
30
|
-
end
|
21
|
+
mutex = Mutex::new
|
22
|
+
|
23
|
+
Parallel.each_with_index(user_events, in_threads: thread_num) do |user_event, i|
|
24
|
+
line = format_line(user_event, i)
|
25
|
+
mutex.synchronize { lines << line }
|
31
26
|
end
|
32
|
-
threads.each(&:join)
|
33
27
|
|
34
28
|
puts sort(lines)
|
35
29
|
end
|
@@ -48,7 +42,7 @@ module Github
|
|
48
42
|
end
|
49
43
|
|
50
44
|
def format_line(user_event, i)
|
51
|
-
puts "#{i} : #{user_event.html_url}" if ENV['GITHUB_NIPPOU_DEBUG']
|
45
|
+
puts "#{i % thread_num} : #{user_event.html_url}" if ENV['GITHUB_NIPPOU_DEBUG']
|
52
46
|
issue = issue(user_event)
|
53
47
|
line = "* [%s - %s](%s) by %s" %
|
54
48
|
[issue.title.markdown_escape, user_event.repo.name, user_event.html_url, issue.user.login]
|
@@ -63,16 +57,20 @@ module Github
|
|
63
57
|
end
|
64
58
|
|
65
59
|
def issue(user_event)
|
66
|
-
|
67
|
-
|
68
|
-
else
|
60
|
+
case
|
61
|
+
when user_event.payload.pull_request
|
69
62
|
client.pull_request(user_event.repo.name, user_event.payload.pull_request.number)
|
63
|
+
when user_event.payload.issue.pull_request
|
64
|
+
# a pull_request like an issue
|
65
|
+
client.pull_request(user_event.repo.name, user_event.payload.issue.number)
|
66
|
+
else
|
67
|
+
client.issue(user_event.repo.name, user_event.payload.issue.number)
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
73
71
|
def sort(lines)
|
74
72
|
lines.sort do |a, b|
|
75
|
-
a.
|
73
|
+
a.markdown_html_url <=> b.markdown_html_url
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
@@ -3,22 +3,11 @@ require 'octokit'
|
|
3
3
|
module SawyerResourceGithub
|
4
4
|
refine Sawyer::Resource do
|
5
5
|
def html_url
|
6
|
-
|
7
|
-
when self.issue?
|
8
|
-
self.payload.issue.html_url
|
9
|
-
when self.pull_request?
|
6
|
+
if self.payload.pull_request
|
10
7
|
self.payload.pull_request.html_url
|
8
|
+
else
|
9
|
+
self.payload.issue.html_url
|
11
10
|
end
|
12
11
|
end
|
13
|
-
|
14
|
-
def issue?
|
15
|
-
self.type == 'IssuesEvent' ||
|
16
|
-
self.type == 'IssueCommentEvent'
|
17
|
-
end
|
18
|
-
|
19
|
-
def pull_request?
|
20
|
-
self.type == 'PullRequestEvent' ||
|
21
|
-
self.type == 'PullRequestReviewCommentEvent'
|
22
|
-
end
|
23
12
|
end
|
24
13
|
end
|
@@ -42,8 +42,11 @@ module Github
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def filter(user_events)
|
45
|
+
elements = %w(IssuesEvent IssueCommentEvent
|
46
|
+
PullRequestEvent PullRequestReviewCommentEvent)
|
47
|
+
|
45
48
|
user_events.select do |user_event|
|
46
|
-
|
49
|
+
elements.include?(user_event.type)
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
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.beta6
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: parallel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: thor
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|