gh-events 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/gh-event2slack +8 -0
- data/lib/gh/events.rb +1 -0
- data/lib/gh/events/slack.rb +40 -0
- data/lib/gh/events/version.rb +1 -1
- data/res/slack.yml +32 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4c57011f3026b65d715ddeaceb440bf81191d111180756440b02c081ff1989
|
4
|
+
data.tar.gz: 54220459f58f26d20f086997d8e196c1f7ab22e990e82c83b8a2e5207eb128bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d24d365c9b1f370bde5e64863e91db41b26676060fa3c134c412ef4bf7be56486af9c199ed7d0c419654b837b35ca61bd209e6df4024f2cd694b167be4131348
|
7
|
+
data.tar.gz: 3096fec55611a0ada0e7e722390c3c992de8824d61bfaa027c1a569f33490a123713cb960e06ec85349da1836f40aa689c6d0b37f4159562708b1a547ebdf765
|
data/Gemfile.lock
CHANGED
data/exe/gh-event2slack
ADDED
data/lib/gh/events.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module GH::Events::Slack
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def translate(payload)
|
11
|
+
event = JSON.parse(payload, object_class: OpenStruct)
|
12
|
+
type = GH::Events.typeof(event).to_s
|
13
|
+
|
14
|
+
# transform
|
15
|
+
event.ref.gsub!(/^refs\/heads\/(.+)$/, 'branch `\1`')
|
16
|
+
event.ref.gsub!(/^refs\/tags\/(.+)$/, 'tag `\1`')
|
17
|
+
|
18
|
+
template = (templates[type] || "No template for type: #{type}.")
|
19
|
+
render(template, event)
|
20
|
+
end
|
21
|
+
|
22
|
+
def templates_file
|
23
|
+
File.expand_path(File.join(%w(.. .. .. .. res slack.yml)), __FILE__)
|
24
|
+
end
|
25
|
+
|
26
|
+
def templates
|
27
|
+
@templates ||= YAML.load_file(templates_file)
|
28
|
+
end
|
29
|
+
|
30
|
+
class ErbBinding < OpenStruct
|
31
|
+
def get_binding
|
32
|
+
return binding()
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def render(template, data)
|
37
|
+
ERB.new(template).result(ErbBinding.new(data).get_binding)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/gh/events/version.rb
CHANGED
data/res/slack.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
unknown: >-
|
2
|
+
An unknown event occurred.
|
3
|
+
push: >-
|
4
|
+
_<%= pusher.name %>_ pushed <%= ref %>
|
5
|
+
to `<%= repository.full_name %>`
|
6
|
+
:star: <%= repository.stargazers_count %>
|
7
|
+
:eye: <%= repository.watchers_count %>
|
8
|
+
(<<%= compare %>|compare>)
|
9
|
+
commit_comment: >-
|
10
|
+
_<%= comment.user.login %>_ commented the
|
11
|
+
<%= comment.url %>|commit `<%= comment.commit_id %>`> on
|
12
|
+
<<%= repository.html_url %>|<%= repository.full_name %>>: _<%= comment.body %>_
|
13
|
+
watch: An event of type `watch` occurred.
|
14
|
+
create: An event of type `create` occurred.
|
15
|
+
delete: An event of type `delete` occurred.
|
16
|
+
deployment: An event of type `deployment` occurred.
|
17
|
+
deployment_status: An event of type `deployment_status` occurred.
|
18
|
+
fork: An event of type `fork` occurred.
|
19
|
+
gollum: An event of type `gollum` occurred.
|
20
|
+
issue_comment: An event of type `issue_comment` occurred.
|
21
|
+
issues: An event of type `issues` occurred.
|
22
|
+
member: An event of type `member` occurred.
|
23
|
+
membership: An event of type `membership` occurred.
|
24
|
+
page_build: An event of type `page_build` occurred.
|
25
|
+
public: An event of type `public` occurred.
|
26
|
+
pull_request: An event of type `pull_request` occurred.
|
27
|
+
pull_request_review_comment: An event of type `pull_request_review_comment` occurred.
|
28
|
+
release: An event of type `release` occurred.
|
29
|
+
repository: An event of type `repository` occurred.
|
30
|
+
star: An event of type `star` occurred.
|
31
|
+
status: An event of type `status` occurred.
|
32
|
+
team_add: An event of type `team_add` occurred.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gh-events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Hofmann
|
@@ -55,7 +55,8 @@ dependencies:
|
|
55
55
|
description: Determine Github event types by their payload.
|
56
56
|
email:
|
57
57
|
- phil@200ok.ch
|
58
|
-
executables:
|
58
|
+
executables:
|
59
|
+
- gh-event2slack
|
59
60
|
extensions: []
|
60
61
|
extra_rdoc_files: []
|
61
62
|
files:
|
@@ -67,11 +68,14 @@ files:
|
|
67
68
|
- Rakefile
|
68
69
|
- bin/console
|
69
70
|
- bin/setup
|
71
|
+
- exe/gh-event2slack
|
70
72
|
- gh-events.gemspec
|
71
73
|
- lib/gh-events.rb
|
72
74
|
- lib/gh/events.rb
|
75
|
+
- lib/gh/events/slack.rb
|
73
76
|
- lib/gh/events/version.rb
|
74
77
|
- res/events.yml
|
78
|
+
- res/slack.yml
|
75
79
|
homepage: https://github.com/200ok-ch/gh-events
|
76
80
|
licenses: []
|
77
81
|
metadata:
|