github_to_slack 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b054357b370e6128af33ad4bba56f1b22a0f2c25
4
+ data.tar.gz: 9b50bd6007ddc692f2384c62d098959e031f5f3f
5
+ SHA512:
6
+ metadata.gz: eaa03667a53d4adb1e9cac8b52c56258ef8f6a1524da6867b5cd446f030de142ecdf38e1512af2c56e8cff1fba13661796ab018347b2294dd0a5541108a4f4cc
7
+ data.tar.gz: 9d1e34bc805d65f5562b43971ece92d0b8cc9a1104943057c03f97018ed64ce28965c86d3a78dd06aef7ad1356272cd7fbdf6f8975c672cb3b900a2948a9ffe0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 jnwaletzko
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,28 @@
1
+ # GithubToSlack
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'github_to_slack'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install github_to_slack
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ 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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,8 @@
1
+ module GithubToSlack
2
+ class CommunicatorsController < ActionController::Base
3
+ def create
4
+ Communicator.new(params[:payload]).deliver_message
5
+ render json: {}
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,48 @@
1
+ module GithubToSlack
2
+ require 'slack-notifier'
3
+ class Communicator
4
+ attr_reader :payload
5
+
6
+ def initialize(payload)
7
+ @payload = payload
8
+ end
9
+
10
+ def build_message
11
+ puts "Parsing json"
12
+ params = JSON.parse(payload).with_indifferent_access
13
+
14
+ pr_url = params[:pull_request][:html_url]
15
+ pr_title = params[:pull_request][:title]
16
+
17
+ action = params[:action].to_sym
18
+ label_name = params[:label][:name]
19
+ sender_login = params[:sender][:login]
20
+
21
+ alert_message = "_#{sender_login}_ #{label_actions[action]} `#{label_name}` label to *#{pr_title}*.\nPR Link: #{pr_url}"
22
+ end
23
+
24
+ def deliver_message
25
+ SlackMessage.notify(build_message)
26
+ end
27
+
28
+ def label_actions
29
+ {
30
+ labeled: :added,
31
+ unlabeled: :removed
32
+ }
33
+ end
34
+ end
35
+
36
+ class SlackMessage
37
+ WEBHOOK_URL = ENV["SLACK_WEBHOOK_URL"]
38
+ CHANNEL_NAME = ENV["SLACK_CHANNEL_NAME"]
39
+
40
+ def self.notify(message)
41
+ Slack::Notifier
42
+ .new(WEBHOOK_URL,
43
+ channel: CHANNEL_NAME,
44
+ username: 'Github To Slack')
45
+ .ping(":allthethings: :octocat: :speaker: " + message)
46
+ end
47
+ end
48
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ GithubToSlack::Engine.routes.draw do
2
+ resources :communicators
3
+ end
@@ -0,0 +1,5 @@
1
+ module GithubToSlack
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace GithubToSlack
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module GithubToSlack
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,5 @@
1
+ require "github_to_slack/engine"
2
+
3
+ module GithubToSlack
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_to_slack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - jnwaletzko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-30 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: 4.2.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: slack-notifier
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: sqlite3
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: RailsEngine to manage slack notifications from GitHub
56
+ email:
57
+ - jnwaletzko@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/controllers/github_to_slack/communicators_controller.rb
66
+ - app/models/github_to_slack/communicator.rb
67
+ - config/routes.rb
68
+ - lib/github_to_slack.rb
69
+ - lib/github_to_slack/engine.rb
70
+ - lib/github_to_slack/version.rb
71
+ homepage: https://www.github.com/jnwaletzko
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.8
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: GithubToSlack.
95
+ test_files: []