pghub-base 0.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +33 -0
- data/Rakefile +36 -0
- data/app/assets/config/pghub_base_manifest.js +2 -0
- data/app/assets/javascripts/pghub/base/application.js +13 -0
- data/app/assets/javascripts/pghub/base/webhooks.js +2 -0
- data/app/assets/javascripts/pghub/base.js +2 -0
- data/app/assets/stylesheets/pghub/base/application.css +15 -0
- data/app/assets/stylesheets/pghub/base/webhooks.css +4 -0
- data/app/assets/stylesheets/pghub/base.css +4 -0
- data/app/controllers/pghub/base/application_controller.rb +7 -0
- data/app/controllers/pghub/base/webhooks_controller.rb +52 -0
- data/app/helpers/pghub/base/application_helper.rb +6 -0
- data/app/helpers/pghub/base/base_helper.rb +4 -0
- data/app/helpers/pghub/base/webhooks_helper.rb +4 -0
- data/app/jobs/pghub/base/application_job.rb +6 -0
- data/app/mailers/pghub/base/application_mailer.rb +8 -0
- data/app/models/pghub/base/application_record.rb +7 -0
- data/app/views/layouts/pghub/base/application.html.erb +14 -0
- data/app/views/pghub/base/base/create.html.erb +2 -0
- data/app/views/pghub/base/webhooks/create.html.erb +2 -0
- data/config/routes.rb +3 -0
- data/lib/pghub/base/engine.rb +7 -0
- data/lib/pghub/base/version.rb +5 -0
- data/lib/pghub/base.rb +10 -0
- data/lib/pghub/config.rb +10 -0
- data/lib/pghub/engine.rb +11 -0
- data/lib/pghub/github_api/comment.rb +16 -0
- data/lib/pghub/github_api/connection.rb +16 -0
- data/lib/pghub/github_api/issue.rb +20 -0
- data/lib/pghub/github_api.rb +20 -0
- data/lib/tasks/pghub/base_tasks.rake +4 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13d88a9a89e5f84582533e9ce749715575bda044
|
4
|
+
data.tar.gz: 10ab5f229d065a43ae2bc355e4e86c4478f54ac6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc18108a78d15a74faddef637813be6821c6860ffaa5d4a669c306a66b3810dc950fe408638e1b81833b32adf030ffa7da0314ffe503ba7ea9580c45ef020714
|
7
|
+
data.tar.gz: fa77673fdf54e7b91328775fb4a9e037b8ea6851ff33dfec270f7fa14dd4ec6348e9ced723287671f64b1594810acc7b8b20dde7a64b7787a1a8de84da30dab6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 ebkn12
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Pghub::Base
|
2
|
+
This gem offers base function for all `Pghub` gems.
|
3
|
+
|
4
|
+
[Pghub-lgtm](https://github.com/playground-live/pghub-lgtm)
|
5
|
+
|
6
|
+
[Pghub-issue_title](https://github.com/playground-live/pghub-issue_title)
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
You don't have to operate this gem.
|
10
|
+
Look at other `Pghub` gems.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'pghub-base'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
```bash
|
21
|
+
$ bundle
|
22
|
+
```
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
```bash
|
26
|
+
$ gem install pghub-base
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
Contribution directions go here.
|
31
|
+
|
32
|
+
## License
|
33
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Pghub::Base'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_dependency "pghub/base/application_controller"
|
2
|
+
|
3
|
+
module Pghub::Base
|
4
|
+
class WebhooksController < ApplicationController
|
5
|
+
@webhook_params = nil
|
6
|
+
VALID_ACTIONS = %w[
|
7
|
+
opened
|
8
|
+
edited
|
9
|
+
created
|
10
|
+
edited
|
11
|
+
review_requested
|
12
|
+
submitted
|
13
|
+
]
|
14
|
+
|
15
|
+
def create
|
16
|
+
@webhook_params = params[:webhook]
|
17
|
+
|
18
|
+
return unless VALID_ACTIONS.include?(@webhook_params[:action])
|
19
|
+
|
20
|
+
if defined? Pghub::Lgtm
|
21
|
+
Pghub::Lgtm.post(issue_path) if input.include?('LGTM')
|
22
|
+
end
|
23
|
+
|
24
|
+
if defined? Pghub::IssueTitle
|
25
|
+
Pghub::IssueTitle.post(issue_path, input) if input.include?('ref')
|
26
|
+
end
|
27
|
+
|
28
|
+
head 200
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def input
|
34
|
+
if @webhook_params[:comment]
|
35
|
+
@webhook_params[:comment][:body]
|
36
|
+
elsif @webhook_params[:review]
|
37
|
+
@webhook_params[:review][:body]
|
38
|
+
elsif @webhook_params[:issue]
|
39
|
+
@webhook_params[:issue][:body]
|
40
|
+
else
|
41
|
+
@webhook_params[:pull_request][:body]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def issue_path
|
46
|
+
reg_organization = %r{#{Pghub.config.github_organization}\/}
|
47
|
+
path = @webhook_params[:issue].present? ? @webhook_params[:issue][:url] : @webhook_params[:pull_request][:issue_url]
|
48
|
+
|
49
|
+
path.match(reg_organization).post_match
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Pghub base</title>
|
5
|
+
<%= stylesheet_link_tag "pghub/base/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "pghub/base/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/pghub/base.rb
ADDED
data/lib/pghub/config.rb
ADDED
data/lib/pghub/engine.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pghub/config'
|
2
|
+
require 'pghub/github_api/connection'
|
3
|
+
|
4
|
+
class GithubAPI
|
5
|
+
module Comment
|
6
|
+
include Connection
|
7
|
+
|
8
|
+
def post(content)
|
9
|
+
connection.post do |req|
|
10
|
+
req.url "#{issue_path}/comments?access_token=#{Pghub.config.github_access_token}"
|
11
|
+
req.headers['Content-Type'] = 'application/json'
|
12
|
+
req.body = { body: content }.to_json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'pgHub/config'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
class GithubAPI
|
5
|
+
module Connection
|
6
|
+
def connection
|
7
|
+
Faraday.new(url: "https://api.github.com/repos/#{Pghub.config.github_organization}",
|
8
|
+
ssl: { verify: true }) do |faraday|
|
9
|
+
faraday.request :multipart
|
10
|
+
faraday.request :url_encoded
|
11
|
+
faraday.response :raise_error
|
12
|
+
faraday.adapter :net_http
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'pghub/config'
|
2
|
+
require 'pghub/github_api/connection'
|
3
|
+
|
4
|
+
class GithubAPI
|
5
|
+
module Issue
|
6
|
+
include Connection
|
7
|
+
|
8
|
+
def get_title
|
9
|
+
body = issue_response
|
10
|
+
body['title']
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def issue_response
|
16
|
+
response = connection.get("#{issue_path}?access_token=#{Pghub.config.github_access_token}")
|
17
|
+
JSON.parse(response.body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'pghub/github_api/issue'
|
2
|
+
require 'pghub/github_api/comment'
|
3
|
+
|
4
|
+
class UndefinedIssuePath < StandardError; end
|
5
|
+
|
6
|
+
class GithubAPI
|
7
|
+
include Issue
|
8
|
+
include Comment
|
9
|
+
|
10
|
+
def initialize(issue_path)
|
11
|
+
@issue_path = issue_path
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def issue_path
|
17
|
+
raise UndefinedIssuePath, '@issue_path is not defined.' if @issue_path.blank?
|
18
|
+
@issue_path
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pghub-base
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ebkn12, akias, Doppon, seteen, mryoshio, sughimura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
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: faraday
|
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: pry-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: This gem offers base function for all gems like pghub-xxx
|
56
|
+
email:
|
57
|
+
- developers@playground.live
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/config/pghub_base_manifest.js
|
66
|
+
- app/assets/javascripts/pghub/base.js
|
67
|
+
- app/assets/javascripts/pghub/base/application.js
|
68
|
+
- app/assets/javascripts/pghub/base/webhooks.js
|
69
|
+
- app/assets/stylesheets/pghub/base.css
|
70
|
+
- app/assets/stylesheets/pghub/base/application.css
|
71
|
+
- app/assets/stylesheets/pghub/base/webhooks.css
|
72
|
+
- app/controllers/pghub/base/application_controller.rb
|
73
|
+
- app/controllers/pghub/base/webhooks_controller.rb
|
74
|
+
- app/helpers/pghub/base/application_helper.rb
|
75
|
+
- app/helpers/pghub/base/base_helper.rb
|
76
|
+
- app/helpers/pghub/base/webhooks_helper.rb
|
77
|
+
- app/jobs/pghub/base/application_job.rb
|
78
|
+
- app/mailers/pghub/base/application_mailer.rb
|
79
|
+
- app/models/pghub/base/application_record.rb
|
80
|
+
- app/views/layouts/pghub/base/application.html.erb
|
81
|
+
- app/views/pghub/base/base/create.html.erb
|
82
|
+
- app/views/pghub/base/webhooks/create.html.erb
|
83
|
+
- config/routes.rb
|
84
|
+
- lib/pghub/base.rb
|
85
|
+
- lib/pghub/base/engine.rb
|
86
|
+
- lib/pghub/base/version.rb
|
87
|
+
- lib/pghub/config.rb
|
88
|
+
- lib/pghub/engine.rb
|
89
|
+
- lib/pghub/github_api.rb
|
90
|
+
- lib/pghub/github_api/comment.rb
|
91
|
+
- lib/pghub/github_api/connection.rb
|
92
|
+
- lib/pghub/github_api/issue.rb
|
93
|
+
- lib/tasks/pghub/base_tasks.rake
|
94
|
+
homepage: http://tech-blog.playground.live
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.6.13
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Support developer using Github.
|
118
|
+
test_files: []
|