github-nippou 1.0.2 → 1.1.0
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/Gemfile.lock +13 -11
- data/README.md +13 -3
- data/bin/github-nippou +1 -1
- data/github-nippou.gemspec +4 -4
- data/lib/github/nippou.rb +1 -73
- data/lib/github/nippou/commands.rb +115 -0
- data/lib/github/nippou/version.rb +1 -1
- metadata +30 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 768b205b4d75ddf857b9b1006ec95cc909169333
|
4
|
+
data.tar.gz: b9ea743c90af5b63a70ad2607995266496f23f81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b31655b73e7a38155244cee3a7d23acbe19d3c882b7a63f118e1198536f495935bababb36dc8463397cddc9c10a039114009aa276ae601bef246dd60f468b4cc
|
7
|
+
data.tar.gz: 07c885f154e58c58a68b651e3215956fb49ac7188d68fb8ce2dd012ccfdf7a9733f9a8a551bb804bb36341d79951b7ce7a23c3b3ee8921cf5d9e61ed3d1942f0
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-nippou (1.0
|
5
|
-
octokit
|
4
|
+
github-nippou (1.1.0)
|
5
|
+
octokit
|
6
|
+
thor
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
addressable (2.
|
11
|
+
addressable (2.4.0)
|
11
12
|
faraday (0.9.2)
|
12
13
|
multipart-post (>= 1.2, < 3)
|
13
14
|
multipart-post (2.0.0)
|
14
|
-
octokit (3.
|
15
|
-
sawyer (~> 0.
|
16
|
-
rake (
|
17
|
-
sawyer (0.
|
18
|
-
addressable (
|
15
|
+
octokit (4.3.0)
|
16
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
17
|
+
rake (11.1.1)
|
18
|
+
sawyer (0.7.0)
|
19
|
+
addressable (>= 2.3.5, < 2.5)
|
19
20
|
faraday (~> 0.8, < 0.10)
|
21
|
+
thor (0.19.1)
|
20
22
|
|
21
23
|
PLATFORMS
|
22
24
|
ruby
|
23
25
|
|
24
26
|
DEPENDENCIES
|
25
|
-
bundler
|
27
|
+
bundler
|
26
28
|
github-nippou!
|
27
|
-
rake
|
29
|
+
rake
|
28
30
|
|
29
31
|
BUNDLED WITH
|
30
|
-
1.
|
32
|
+
1.11.2
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Github::Nippou [![Gem Version][gem-badge]][gem-link]
|
2
2
|
|
3
|
-
|
3
|
+
Displays today's your GitHub action.
|
4
4
|
|
5
5
|
This is a helpful tool when you write a daily report in reference to
|
6
|
-
GitHub.
|
6
|
+
GitHub. Nippou is a japanese word which means a daily report.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -28,7 +28,17 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
|
31
|
+
```
|
32
|
+
$ github-nippou help
|
33
|
+
Commands:
|
34
|
+
github-nippou help [COMMAND] # Describe available commands or one specific command
|
35
|
+
github-nippou list # Displays today's GitHub events formatted for Nippou
|
36
|
+
|
37
|
+
Options:
|
38
|
+
a, [--all], [--no-all] # Displays all events that can retrieve from GitHub
|
39
|
+
```
|
40
|
+
|
41
|
+
You can omit the sub command `list`.
|
32
42
|
|
33
43
|
## Contributing
|
34
44
|
|
data/bin/github-nippou
CHANGED
data/github-nippou.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'github/nippou/version'
|
@@ -21,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
21
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
21
|
spec.require_paths = ['lib']
|
23
22
|
|
24
|
-
spec.add_dependency 'octokit'
|
23
|
+
spec.add_dependency 'octokit'
|
24
|
+
spec.add_dependency 'thor'
|
25
25
|
|
26
|
-
spec.add_development_dependency 'bundler'
|
27
|
-
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
28
|
end
|
data/lib/github/nippou.rb
CHANGED
@@ -1,74 +1,2 @@
|
|
1
|
+
require 'github/nippou/commands'
|
1
2
|
require 'github/nippou/version'
|
2
|
-
require 'octokit'
|
3
|
-
|
4
|
-
module Github
|
5
|
-
module Nippou
|
6
|
-
def self.list
|
7
|
-
user = self.user
|
8
|
-
client = Octokit::Client.new(login: user, access_token: self.access_token)
|
9
|
-
events = client.user_events(user)
|
10
|
-
|
11
|
-
url_to_detail = {}
|
12
|
-
|
13
|
-
events.each do |_|
|
14
|
-
break unless _.created_at.getlocal.to_date == Time.now.to_date
|
15
|
-
case _.type
|
16
|
-
when 'IssuesEvent', 'IssueCommentEvent'
|
17
|
-
title = _.payload.issue.title.gsub('`', '\\\`')
|
18
|
-
merged = client.pull_merged?(_.repo.name, _.payload.issue.number)
|
19
|
-
url_to_detail[_.payload.issue.html_url] ||= {title: title, repo_basename: _.repo.name, username: _.payload.issue.user.login, merged: merged}
|
20
|
-
when 'PullRequestEvent', 'PullRequestReviewCommentEvent'
|
21
|
-
title = _.payload.pull_request.title.gsub('`', '\\\`')
|
22
|
-
merged = client.pull_merged?(_.repo.name, _.payload.pull_request.number)
|
23
|
-
url_to_detail[_.payload.pull_request.html_url] ||= {title: title, repo_basename: _.repo.name, username: _.payload.pull_request.user.login, merged: merged}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
url_to_detail.each do |url, detail|
|
28
|
-
line = "* [#{detail[:title]} - #{detail[:repo_basename]}](#{url}) by #{detail[:username]}"
|
29
|
-
line << ' **merged!**' if detail[:merged]
|
30
|
-
puts line
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def self.user
|
37
|
-
case
|
38
|
-
when ENV['GITHUB_NIPPOU_USER']
|
39
|
-
ENV['GITHUB_NIPPOU_USER']
|
40
|
-
when !`git config github-nippou.user`.chomp.empty?
|
41
|
-
`git config github-nippou.user`.chomp
|
42
|
-
else
|
43
|
-
puts <<MESSAGE
|
44
|
-
** User required.
|
45
|
-
|
46
|
-
Please set github-nippou.user to your .gitconfig.
|
47
|
-
$ git config --global github-nippou.user [Your GitHub account]
|
48
|
-
MESSAGE
|
49
|
-
exit!
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.access_token
|
54
|
-
case
|
55
|
-
when ENV['GITHUB_NIPPOU_ACCESS_TOKEN']
|
56
|
-
ENV['GITHUB_NIPPOU_ACCESS_TOKEN']
|
57
|
-
when !`git config github-nippou.token`.chomp.empty?
|
58
|
-
`git config github-nippou.token`.chomp
|
59
|
-
else
|
60
|
-
puts <<MESSAGE
|
61
|
-
** Authorization required.
|
62
|
-
|
63
|
-
Please set github-nippou.token to your .gitconfig.
|
64
|
-
$ git config --global github-nippou.token [Your GitHub access token]
|
65
|
-
|
66
|
-
To get new token, visit
|
67
|
-
https://github.com/settings/tokens/new
|
68
|
-
|
69
|
-
MESSAGE
|
70
|
-
exit!
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module StringExMarkdown
|
5
|
+
refine String do
|
6
|
+
def markdown_escape
|
7
|
+
self.gsub(/([`<>])/, '\\\\\1')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Github
|
13
|
+
module Nippou
|
14
|
+
class Commands < Thor
|
15
|
+
using StringExMarkdown
|
16
|
+
|
17
|
+
default_task :list
|
18
|
+
class_option :all, type: :boolean, aliases: :a, desc: 'Displays all events that can retrieve from GitHub'
|
19
|
+
|
20
|
+
desc 'list', "Displays today's GitHub events formatted for Nippou"
|
21
|
+
def list
|
22
|
+
nippous.each do |url, detail|
|
23
|
+
line = "* [#{detail[:title]} - #{detail[:repo_basename]}](#{url}) by #{detail[:username]}"
|
24
|
+
line << ' **merged!**' if detail[:merged]
|
25
|
+
puts line
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def nippous
|
32
|
+
result = {}
|
33
|
+
now = Time.now
|
34
|
+
|
35
|
+
client.user_events(user).each do |event|
|
36
|
+
break if skip?(event, now)
|
37
|
+
|
38
|
+
case event.type
|
39
|
+
when 'IssuesEvent', 'IssueCommentEvent'
|
40
|
+
issue = event.payload.issue
|
41
|
+
result[issue.html_url] ||= hash_for_issue(event.repo, issue)
|
42
|
+
when 'PullRequestEvent', 'PullRequestReviewCommentEvent'
|
43
|
+
pr = event.payload.pull_request
|
44
|
+
result[pr.html_url] ||= hash_for_pr(event.repo, pr)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
def skip?(event, now)
|
52
|
+
if options[:all]
|
53
|
+
false
|
54
|
+
else
|
55
|
+
event.created_at.getlocal.to_date != now.to_date
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def client
|
60
|
+
@client ||= Octokit::Client.new(login: user, access_token: access_token)
|
61
|
+
end
|
62
|
+
|
63
|
+
def user
|
64
|
+
@user ||=
|
65
|
+
case
|
66
|
+
when ENV['GITHUB_NIPPOU_USER']
|
67
|
+
ENV['GITHUB_NIPPOU_USER']
|
68
|
+
when !`git config github-nippou.user`.chomp.empty?
|
69
|
+
`git config github-nippou.user`.chomp
|
70
|
+
else
|
71
|
+
puts <<MESSAGE
|
72
|
+
** User required.
|
73
|
+
|
74
|
+
Please set github-nippou.user to your .gitconfig.
|
75
|
+
$ git config --global github-nippou.user [Your GitHub account]
|
76
|
+
MESSAGE
|
77
|
+
exit!
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def access_token
|
82
|
+
@access_token ||=
|
83
|
+
case
|
84
|
+
when ENV['GITHUB_NIPPOU_ACCESS_TOKEN']
|
85
|
+
ENV['GITHUB_NIPPOU_ACCESS_TOKEN']
|
86
|
+
when !`git config github-nippou.token`.chomp.empty?
|
87
|
+
`git config github-nippou.token`.chomp
|
88
|
+
else
|
89
|
+
puts <<MESSAGE
|
90
|
+
** Authorization required.
|
91
|
+
|
92
|
+
Please set github-nippou.token to your .gitconfig.
|
93
|
+
$ git config --global github-nippou.token [Your GitHub access token]
|
94
|
+
|
95
|
+
To get new token, visit
|
96
|
+
https://github.com/settings/tokens/new
|
97
|
+
MESSAGE
|
98
|
+
exit!
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def hash_for_issue(repo, issue)
|
103
|
+
title = issue.title.markdown_escape
|
104
|
+
merged = client.pull_merged?(repo.name, issue.number)
|
105
|
+
{title: title, repo_basename: repo.name, username: issue.user.login, merged: merged}
|
106
|
+
end
|
107
|
+
|
108
|
+
def hash_for_pr(repo, pr)
|
109
|
+
title = pr.title.markdown_escape
|
110
|
+
merged = client.pull_merged?(repo.name, pr.number)
|
111
|
+
{title: title, repo_basename: repo.name, username: pr.user.login, merged: merged}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-nippou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Masuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0'
|
55
69
|
description: |2
|
56
70
|
This is a helpful tool when you write a daily report in reference to
|
57
71
|
GitHub. nippou is a japanese word which means a daily report.
|
@@ -71,6 +85,7 @@ files:
|
|
71
85
|
- bin/github-nippou
|
72
86
|
- github-nippou.gemspec
|
73
87
|
- lib/github/nippou.rb
|
88
|
+
- lib/github/nippou/commands.rb
|
74
89
|
- lib/github/nippou/version.rb
|
75
90
|
homepage: https://github.com/masutaka/github-nippou
|
76
91
|
licenses:
|
@@ -92,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
107
|
version: '0'
|
93
108
|
requirements: []
|
94
109
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.1
|
96
111
|
signing_key:
|
97
112
|
specification_version: 4
|
98
113
|
summary: Print today's your GitHub action.
|