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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 536867ca0996403c7c14af95cdcc0fe09d64ff0f0255b1108807dc4b41e64043
4
- data.tar.gz: 5c42253ec777d1d387969f9bb82ef4937b483234f8d1a385c15924b59b930f6e
3
+ metadata.gz: 1a4c57011f3026b65d715ddeaceb440bf81191d111180756440b02c081ff1989
4
+ data.tar.gz: 54220459f58f26d20f086997d8e196c1f7ab22e990e82c83b8a2e5207eb128bf
5
5
  SHA512:
6
- metadata.gz: fed7a3180d966c34198af9c43f6be039bf873f5c75c9a04161be7c3019017edd0680c4386165f84e047f8bff9c297de00e26f8a834141f200b80d4d0c54114d6
7
- data.tar.gz: ba6a71ca37b15b4f43f95e463f6ae74cd96e75cd537e39e0dcf6ebb5c148020c61b8f3e43edc55133f911604091ef952c5d3f7916a7e00db12cb2e3e3d78a8a2
6
+ metadata.gz: d24d365c9b1f370bde5e64863e91db41b26676060fa3c134c412ef4bf7be56486af9c199ed7d0c419654b837b35ca61bd209e6df4024f2cd694b167be4131348
7
+ data.tar.gz: 3096fec55611a0ada0e7e722390c3c992de8824d61bfaa027c1a569f33490a123713cb960e06ec85349da1836f40aa689c6d0b37f4159562708b1a547ebdf765
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gh-events (0.2.0)
4
+ gh-events (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path("../../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'gh/events'
7
+
8
+ puts GH::Events::Slack.translate(ARGF.read)
@@ -1,4 +1,5 @@
1
1
  require "gh/events/version"
2
+ require "gh/events/slack"
2
3
 
3
4
  require 'yaml'
4
5
  require 'ostruct'
@@ -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
@@ -1,5 +1,5 @@
1
1
  module GH
2
2
  module Events
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -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.2.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: