ruboty-pr 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +19 -0
- data/Rakefile +2 -0
- data/lib/ruboty/handlers/pr.rb +27 -0
- data/lib/ruboty/pr/actions/base.rb +74 -0
- data/lib/ruboty/pr/actions/remember.rb +26 -0
- data/lib/ruboty/pr/actions/search_pull_requests.rb +64 -0
- data/lib/ruboty/pr/version.rb +5 -0
- data/lib/ruboty/pr.rb +10 -0
- data/ruboty-pr.gemspec +24 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2b3f58a5aa7e73fafc5d20fbc702df87b635831
|
4
|
+
data.tar.gz: 4b2c72697f6c15124a4cdefe9d58ae27727cdee7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39dfc19a642ebb5a42071e05e3b890b7c87ed7b92c53c085de2202487bf4a5c45bccaa46fdd0a32bb09da7d1945f007811ee6ced9f63d3373c72029d803bc3c2
|
7
|
+
data.tar.gz: '09470f057da79ead0691444a193e5f26c9e3b1fedaaa2cc4384508e00a9bd69dcf890d7113e573b7a3d68ffa6e4489c29ad27409b73fbdb96b3db04b3f0840f3'
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yoshinori Hirasawa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Ruboty::PR
|
2
|
+
Output pull requests as markdown via Ruboty.
|
3
|
+
|
4
|
+
## Install
|
5
|
+
```ruby
|
6
|
+
# Gemfile
|
7
|
+
gem "ruboty-pr"
|
8
|
+
```
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
```
|
12
|
+
@ruboty pr since {today|yesterday} - Output pull requests as markdown
|
13
|
+
@ruboty remember <token> - Remember sender's GitHub access token
|
14
|
+
```
|
15
|
+
|
16
|
+
## ENV
|
17
|
+
```
|
18
|
+
GITHUB_BASE_URL - Pass GitHub base URL if needed (e.g. https://github.example.com)
|
19
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Handlers
|
3
|
+
class PR < Base
|
4
|
+
env :GITHUB_BASE_URL, "Pass GitHub URL if needed (e.g. https://github.example.com)", optional: true
|
5
|
+
|
6
|
+
on(
|
7
|
+
/remember (?<token>.+)\z/,
|
8
|
+
name: "remember",
|
9
|
+
description: "Remember sender's GitHub access token",
|
10
|
+
)
|
11
|
+
|
12
|
+
on(
|
13
|
+
/pr since (?<since>today|yesterday)?\z/,
|
14
|
+
name: "search_pull_requests",
|
15
|
+
description: "Ouput pull requests as markdown",
|
16
|
+
)
|
17
|
+
|
18
|
+
def remember(message)
|
19
|
+
Ruboty::PR::Actions::Remember.new(message).call
|
20
|
+
end
|
21
|
+
|
22
|
+
def search_pull_requests(message)
|
23
|
+
Ruboty::PR::Actions::SearchPullRequests.new(message).call
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module PR
|
3
|
+
module Actions
|
4
|
+
class Base
|
5
|
+
NAMESPACE = "github"
|
6
|
+
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
@message = message
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def access_tokens
|
16
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def body
|
20
|
+
message[:description] || ""
|
21
|
+
end
|
22
|
+
|
23
|
+
def sender_name
|
24
|
+
message.from_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def require_access_token
|
28
|
+
message.reply("I don't know your github access token")
|
29
|
+
end
|
30
|
+
|
31
|
+
def has_access_token?
|
32
|
+
!!access_token
|
33
|
+
end
|
34
|
+
|
35
|
+
def access_token
|
36
|
+
@access_token ||= access_tokens[sender_name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def client
|
40
|
+
Octokit::Client.new(client_options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def client_options
|
44
|
+
client_options_with_nil_value.reject {|key, value| value.nil? }
|
45
|
+
end
|
46
|
+
|
47
|
+
def client_options_with_nil_value
|
48
|
+
{
|
49
|
+
access_token: access_token,
|
50
|
+
api_endpoint: api_endpoint,
|
51
|
+
web_endpoint: web_endpoint,
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def web_endpoint
|
56
|
+
"#{github_base_url}/" if github_base_url
|
57
|
+
end
|
58
|
+
|
59
|
+
def api_endpoint
|
60
|
+
"#{github_base_url}/api/v3" if github_base_url
|
61
|
+
end
|
62
|
+
|
63
|
+
def github_base_url
|
64
|
+
case
|
65
|
+
when ENV["GITHUB_BASE_URL"]
|
66
|
+
ENV["GITHUB_BASE_URL"]
|
67
|
+
when ENV["GITHUB_HOST"]
|
68
|
+
"https://#{ENV['GITHUB_HOST']}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module PR
|
3
|
+
module Actions
|
4
|
+
class Remember < Base
|
5
|
+
def call
|
6
|
+
remember
|
7
|
+
report
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def report
|
13
|
+
message.reply("Remembered #{sender_name}'s github access token")
|
14
|
+
end
|
15
|
+
|
16
|
+
def remember
|
17
|
+
access_tokens[sender_name] = given_access_token
|
18
|
+
end
|
19
|
+
|
20
|
+
def given_access_token
|
21
|
+
message[:token]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module PR
|
3
|
+
module Actions
|
4
|
+
class SearchPullRequests < Base
|
5
|
+
def call
|
6
|
+
if has_access_token?
|
7
|
+
list
|
8
|
+
else
|
9
|
+
require_access_token
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def list
|
16
|
+
message.reply(search_summary, code: true)
|
17
|
+
end
|
18
|
+
|
19
|
+
def search_summary
|
20
|
+
if issues.empty?
|
21
|
+
empty_summary
|
22
|
+
else
|
23
|
+
repositories.sort.map do |repo_name, repo_issues|
|
24
|
+
repo_issues.map do |issue|
|
25
|
+
"* [#{(issue.state == "closed") ? "x" : " "}] [#{repo_name}##{issue.number}: #{issue.title}](#{issue.html_url})"
|
26
|
+
end.join("\n")
|
27
|
+
end.join("\n")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def empty_summary
|
32
|
+
"Issue not found"
|
33
|
+
end
|
34
|
+
|
35
|
+
def repositories
|
36
|
+
repos = Hash.new { |hash, key| hash[key] = [] }
|
37
|
+
issues.each do |issue|
|
38
|
+
next unless issue.pull_request
|
39
|
+
repo_name = "#{issue.repository.name}##{issue.number}"
|
40
|
+
repos[repo_name] << issue
|
41
|
+
end
|
42
|
+
repos
|
43
|
+
end
|
44
|
+
|
45
|
+
def issues
|
46
|
+
@issues ||= search_result
|
47
|
+
end
|
48
|
+
|
49
|
+
def search_result
|
50
|
+
client.issues(nil, state: "all", since: since)
|
51
|
+
end
|
52
|
+
|
53
|
+
def since
|
54
|
+
case message[:since]
|
55
|
+
when "today" then
|
56
|
+
Date.today.midnight.iso8601
|
57
|
+
when "yesterday" then
|
58
|
+
Date.yesterday.midnight.iso8601
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/ruboty/pr.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require "octokit"
|
4
|
+
|
5
|
+
require "ruboty"
|
6
|
+
require "ruboty/pr/actions/base"
|
7
|
+
require "ruboty/pr/actions/search_pull_requests"
|
8
|
+
require "ruboty/pr/actions/remember"
|
9
|
+
require "ruboty/pr/version"
|
10
|
+
require "ruboty/handlers/pr"
|
data/ruboty-pr.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'ruboty/pr/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruboty-pr"
|
7
|
+
spec.version = Ruboty::PR::VERSION
|
8
|
+
spec.authors = ["Yoshinori Hirasawa"]
|
9
|
+
spec.email = ["fakestarbaby@gmail.com"]
|
10
|
+
spec.summary = "Output pull requests as markdown via Ruboty."
|
11
|
+
spec.homepage = "https://github.com/fakestarbaby/ruboty-pr"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "activesupport"
|
20
|
+
spec.add_dependency "ruboty"
|
21
|
+
spec.add_dependency "octokit"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-pr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yoshinori Hirasawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruboty
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- fakestarbaby@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- CHANGELOG.md
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/ruboty/handlers/pr.rb
|
97
|
+
- lib/ruboty/pr.rb
|
98
|
+
- lib/ruboty/pr/actions/base.rb
|
99
|
+
- lib/ruboty/pr/actions/remember.rb
|
100
|
+
- lib/ruboty/pr/actions/search_pull_requests.rb
|
101
|
+
- lib/ruboty/pr/version.rb
|
102
|
+
- ruboty-pr.gemspec
|
103
|
+
homepage: https://github.com/fakestarbaby/ruboty-pr
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.6.8
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Output pull requests as markdown via Ruboty.
|
127
|
+
test_files: []
|