punt-receiver 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/punt-receive +5 -0
- data/lib/punt/receiver/config.rb +21 -0
- data/lib/punt/receiver/retriever.rb +21 -0
- data/lib/punt/receiver/version.rb +5 -0
- data/lib/punt/receiver.rb +8 -0
- data/punt-receiver.gemspec +26 -0
- data/test/punt/receiver/config_test.rb +25 -0
- data/test/punt/receiver/retriever_test.rb +36 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d82218c4e783b6f95327539d2f453c17a11f8ee3
|
4
|
+
data.tar.gz: d57c03431741ca80d9806ac1f8493c06514a61b6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a9a90a2b9a76ebe50a5232d695a648d5cef9da1effe90391a44df8e5166567d787bb6d6d59bf8f92d438506af710328784f49a78fd3c55a42b16636b830113f
|
7
|
+
data.tar.gz: 9dafca707e4b7a97370600dbcc3e62a78546ed527c852cfcfe02dc4426176c5318605eb82a5fdef89ceaeca9db619bef893652f028d2873b991a3145e50ab667
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Rodrigo Flores
|
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,39 @@
|
|
1
|
+
# Punt::Receiver
|
2
|
+
|
3
|
+
Given a set of repos and a Github token, shows all the PRs.
|
4
|
+
|
5
|
+
![](https://travis-ci.org/rodrigoflores/punt-receiver.svg)
|
6
|
+
|
7
|
+
## Set up and usage
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install punt-receiver
|
13
|
+
```
|
14
|
+
|
15
|
+
Save your github OAuth token (with repo scope) on a env var named `GITHUB_TOKEN` and the full path of the config file on the env var `PR_REPOS_FILE`.
|
16
|
+
|
17
|
+
```
|
18
|
+
export GITHUB_TOKEN=a-token
|
19
|
+
export PR_REPOS_FILE=/users/flores/.pr.yaml
|
20
|
+
```
|
21
|
+
|
22
|
+
On the `PR_REPOS_FILE` you should put a yaml content like this:
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
---
|
26
|
+
repos:
|
27
|
+
- rails/rails
|
28
|
+
- rspec/rspec
|
29
|
+
```
|
30
|
+
|
31
|
+
And then you'll be able to see all open PR's through the command
|
32
|
+
|
33
|
+
```
|
34
|
+
$ punt-receive
|
35
|
+
```
|
36
|
+
|
37
|
+
## To-do ##
|
38
|
+
|
39
|
+
- [ ] Create a set-up mode that checks for the env vars and creates a bare `PR_REPOS_FILE`
|
data/Rakefile
ADDED
data/bin/punt-receive
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Punt
|
4
|
+
module Receiver
|
5
|
+
class Config
|
6
|
+
def initialize(env=ENV,yaml=YAML)
|
7
|
+
@env = env
|
8
|
+
@yaml = yaml
|
9
|
+
end
|
10
|
+
|
11
|
+
def github_token
|
12
|
+
@env.fetch("GITHUB_TOKEN")
|
13
|
+
end
|
14
|
+
|
15
|
+
def relevant_repos
|
16
|
+
file_name = @env.fetch("PR_REPOS_FILE")
|
17
|
+
@yaml.load_file(file_name)["repos"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module Punt
|
4
|
+
module Receiver
|
5
|
+
class Retriever
|
6
|
+
def initialize(config,octokit_client=Octokit::Client)
|
7
|
+
@config = config
|
8
|
+
@client = octokit_client.new(:access_token => @config.github_token)
|
9
|
+
end
|
10
|
+
|
11
|
+
def retrieve_pull_requests(output=$stdout)
|
12
|
+
@config.relevant_repos.each do |repo|
|
13
|
+
prs = @client.pull_requests(repo)
|
14
|
+
prs.each do |pr|
|
15
|
+
output.puts "#{pr[:title]}\t#{pr[:user][:login]}\t#{pr[:created_at]}\t#{pr[:html_url]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'punt/receiver/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "punt-receiver"
|
8
|
+
spec.version = Punt::Receiver::VERSION
|
9
|
+
spec.authors = ["Rodrigo Flores"]
|
10
|
+
spec.email = ["mail@rodrigoflores.org"]
|
11
|
+
spec.summary = %q{Given a config file and a github token, checks for open PRs}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "5.6.1"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "octokit", ["~> 3.0"]
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "punt/receiver/config"
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/pride'
|
4
|
+
|
5
|
+
describe Punt::Receiver::Config do
|
6
|
+
before do
|
7
|
+
@mock_env = MiniTest::Mock.new
|
8
|
+
@mock_yaml = MiniTest::Mock.new
|
9
|
+
@config = Punt::Receiver::Config.new(@mock_env,@mock_yaml)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "gets the github token data" do
|
13
|
+
@mock_env.expect(:fetch,"a-gh-token",["GITHUB_TOKEN"])
|
14
|
+
@config.github_token.must_equal "a-gh-token"
|
15
|
+
assert @mock_env.verify
|
16
|
+
end
|
17
|
+
|
18
|
+
it "gets the relevant repos" do
|
19
|
+
@mock_env.expect(:fetch,"a-file.yaml", ["PR_REPOS_FILE"])
|
20
|
+
@mock_yaml.expect(:load_file,{"repos" => ["rails/rails"]},["a-file.yaml"])
|
21
|
+
@config.relevant_repos.must_equal ["rails/rails"]
|
22
|
+
assert @mock_env.verify
|
23
|
+
assert @mock_yaml.verify
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'punt/receiver/retriever'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/pride'
|
4
|
+
|
5
|
+
describe "it gathers all the repos" do
|
6
|
+
before do
|
7
|
+
@output = StringIO.new
|
8
|
+
@config = Minitest::Mock.new
|
9
|
+
@octokit = Minitest::Mock.new
|
10
|
+
@octokit_client = Minitest::Mock.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#retrieve_pull_requests" do
|
14
|
+
it "outputs pull requests" do
|
15
|
+
@config.expect(:github_token,"a-token")
|
16
|
+
@octokit.expect(:new, @octokit_client,[{:access_token => "a-token"}])
|
17
|
+
@retriever = Punt::Receiver::Retriever.new(@config, @octokit)
|
18
|
+
|
19
|
+
@config.expect(:relevant_repos,["rails/rails"],[])
|
20
|
+
@octokit_client.expect(:pull_requests, [{title: "A nice pr",
|
21
|
+
user: {login: "johndoe"},
|
22
|
+
created_at: "2010-01-01T00:00:00 UTC",
|
23
|
+
html_url: "https://github.com/a-nice-pr/url"}], ["rails/rails"])
|
24
|
+
|
25
|
+
|
26
|
+
buffer = StringIO.new
|
27
|
+
@retriever.retrieve_pull_requests(buffer)
|
28
|
+
|
29
|
+
buffer.string.must_equal "A nice pr\tjohndoe\t2010-01-01T00:00:00 UTC\thttps://github.com/a-nice-pr/url\n"
|
30
|
+
|
31
|
+
assert @config.verify
|
32
|
+
assert @octokit.verify
|
33
|
+
assert @octokit_client.verify
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: punt-receiver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo Flores
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.6.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.6.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- mail@rodrigoflores.org
|
72
|
+
executables:
|
73
|
+
- punt-receive
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/punt-receive
|
84
|
+
- lib/punt/receiver.rb
|
85
|
+
- lib/punt/receiver/config.rb
|
86
|
+
- lib/punt/receiver/retriever.rb
|
87
|
+
- lib/punt/receiver/version.rb
|
88
|
+
- punt-receiver.gemspec
|
89
|
+
- test/punt/receiver/config_test.rb
|
90
|
+
- test/punt/receiver/retriever_test.rb
|
91
|
+
homepage: ''
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Given a config file and a github token, checks for open PRs
|
115
|
+
test_files:
|
116
|
+
- test/punt/receiver/config_test.rb
|
117
|
+
- test/punt/receiver/retriever_test.rb
|