lita-reviewer-lotto 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60af1fb20e376f67503f09ee563f37f06f19d398
4
+ data.tar.gz: 7231d0ea84ba9da9f488e805d4e2f2adffc5570f
5
+ SHA512:
6
+ metadata.gz: d9e70f5e490c9d24432d274e7d84533fc7aa1d5f1aa710d33a06914958a6d07a15da03f208fdf3411da8e71fc77edd913a4cca318d32b9697672481d982389d6
7
+ data.tar.gz: ed1c5487ee7345e39df32648e1ab120dcb868d48bcb455dd21afa11d6bc411043a1fb9286770c81155f5f454d6972b223fb57bd1d039adb9d26dcbda7cc413a8
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lita-reviewer-lotto.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 fukayatsu
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.
@@ -0,0 +1,50 @@
1
+ # lita-reviewer-lotto
2
+
3
+ A reviewer lottery script for Lita
4
+
5
+ Inspired by [sakatam/hubot-reviewer-lotto](https://github.com/sakatam/hubot-reviewer-lotto)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your lita's Gemfile:
10
+
11
+ gem 'lita-reviewer-lotto'
12
+
13
+ ## Usage
14
+
15
+ ### generate access token on github
16
+
17
+ https://github.com/settings/tokens/new
18
+
19
+ [![](https://cloud.githubusercontent.com/assets/1041857/2859368/41fa4ebc-d1a2-11e3-9faa-22aa2c394011.png)](https://cloud.githubusercontent.com/assets/1041857/2859368/41fa4ebc-d1a2-11e3-9faa-22aa2c394011.png)
20
+
21
+ > Select scopes
22
+
23
+ - repo
24
+ - public_repo
25
+ - read:org
26
+
27
+ ### lita config
28
+
29
+ ```
30
+ # lita_config.rb (example)
31
+ Lita.configure do |config|
32
+ config.handlers.reviewer_lotto.gh_token = ENV["GH_TOKEN"] # String
33
+ config.handlers.reviewer_lotto.gh_organization = ENV["GH_ORGANIZATION"] # String
34
+ config.handlers.reviewer_lotto.gh_reviewer_team = ENV["GH_REVIEWER_TEAM"] # Integer
35
+ end
36
+ ```
37
+
38
+ ```
39
+ # on your chat
40
+ YOU > @bot reviewer for your_repo 123
41
+ BOT > foobar has been assigned for https://github.com/your_org/your_repo/pull/123 as a reviewer
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( http://github.com/fukayatsu/lita-reviewer-lotto/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "lita/reviewer/lotto"
2
+ require "lita/handlers/reviewer_lotto"
@@ -0,0 +1,38 @@
1
+ require 'octokit'
2
+
3
+ module Lita
4
+ module Handlers
5
+ class ReviewerLotto < Handler
6
+ def self.default_config(handler_config)
7
+ handler_config.gh_token = nil
8
+ handler_config.gh_organization = nil
9
+ handler_config.gh_reviewer_team = nil
10
+ end
11
+
12
+ route /^reviewer for ([\w-]+) (\d+)$/, :reviewer_for, command: true,
13
+ help: {"Lita: reviewer for [repo] [pull_request_number]" => "assigns a random reviewer for the pull request"}
14
+ def reviewer_for(response)
15
+ repository_name = response.matches[0][0]
16
+ pull_request_number = response.matches[0][1]
17
+
18
+ repository = "#{config.gh_organization}/#{repository_name}"
19
+ client = Octokit::Client.new(access_token: config.gh_token)
20
+ reviewers = client.team_members(config.gh_reviewer_team).map(&:login)
21
+ pull_request = client.pull_request(repository, pull_request_number)
22
+
23
+ reviewer = (reviewers - [pull_request.user.login]).sample
24
+ client.update_issue(repository, pull_request_number, pull_request.title, pull_request.body, assignee: reviewer)
25
+ client.add_comment(repository, pull_request_number, "@#{reviewer} please review this :bow:")
26
+ response.reply "#{reviewer} has been assigned for #{pull_request.html_url} as a reviewer"
27
+ rescue Octokit::NotFound => e
28
+ response.reply 'PullRequest not found'
29
+ end
30
+
31
+ private
32
+ def config
33
+ Lita.config.handlers.reviewer_lotto
34
+ end
35
+ end
36
+ Lita.register_handler(ReviewerLotto)
37
+ end
38
+ end
@@ -0,0 +1,2 @@
1
+ require "lita"
2
+ require "lita/reviewer/lotto/version"
@@ -0,0 +1,7 @@
1
+ module Lita
2
+ module Reviewer
3
+ module Lotto
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lita/reviewer/lotto/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lita-reviewer-lotto"
8
+ spec.version = Lita::Reviewer::Lotto::VERSION
9
+ spec.authors = ["fukayatsu"]
10
+ spec.email = ["fukayatsu@gmail.com"]
11
+ spec.summary = %q{A reviewer lottery script for Lita}
12
+ spec.description = %q{A reviewer lottery script for Lita}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata = { "lita_plugin_type" => "handler" }
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "lita", ">= 2.0"
24
+ spec.add_runtime_dependency 'octokit', '~> 3.1.0'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.5"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "pry"
29
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-reviewer-lotto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - fukayatsu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
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: A reviewer lottery script for Lita
84
+ email:
85
+ - fukayatsu@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/lita-reviewer-lotto.rb
96
+ - lib/lita/handlers/reviewer_lotto.rb
97
+ - lib/lita/reviewer/lotto.rb
98
+ - lib/lita/reviewer/lotto/version.rb
99
+ - lita-reviewer-lotto.gemspec
100
+ homepage: ''
101
+ licenses:
102
+ - MIT
103
+ metadata:
104
+ lita_plugin_type: handler
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: A reviewer lottery script for Lita
125
+ test_files: []