gh-events 0.8.2 → 0.8.3

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: f42768b024e11b3e98a2352ca81f6105d3ff4b9e5767efaa3bfb56377e8c2c7a
4
- data.tar.gz: 43c3fa8883db2ab811e5e358966b50b0bef3a93c73a6446f8b31ce63df7b0a7e
3
+ metadata.gz: 23309b6819c759bd4ae39468e40dc374409484ae1ec4568c42713ba82dbf305e
4
+ data.tar.gz: f9decf307c3770b981bbca41bb149f008a59aa8279a2b01ef59e4adb8d55a44b
5
5
  SHA512:
6
- metadata.gz: b9f1922da318421f76427589360f62459fe37f134e468e0cd45650c41b4bd4ab5ca6181c871618986a236c299cf37852037e8996a7cb7054edf0862c320d9898
7
- data.tar.gz: 9a8c9102ec4107c01b22c542d1963351fff72f68580f0131901f5556fc8c488c6abca496c9c7f6aab7bee8b3af958086e38e770a0da753117228fe8617bbd3bf
6
+ metadata.gz: e24a1288484269407ae8761f2db4b49e6f6f0413e7ab4bdbd43e2405f87c8ce71ac117feb42cb82bfe756a2acbf9122180b1169901380acc82db3698001adefa
7
+ data.tar.gz: 37c811378a88220d83d070ac5bb02ae8466e6e1be977a40307a32610b11f071a56d319832b50671c931d2d738a336fa5b9d9b21236cc32a7ef861da5295bd570
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gh-events (0.8.2)
4
+ gh-events (0.8.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -47,7 +47,22 @@ module GH::Events::Text
47
47
  # if there is no template use a default
48
48
  template ||= templates['no_template']
49
49
 
50
- render(template, event).gsub(/[\n\r]+/, '\n')
50
+ res = render(template, event).gsub(/[\n\r]+/, '\n')
51
+ validate(res, dict)
52
+ res
53
+ end
54
+
55
+ # Validate the format of the response in case it's JSON
56
+ def validate(response, channel)
57
+ return unless channel == "slack"
58
+ begin
59
+ JSON.parse(response)
60
+ rescue Exception => e
61
+ warn "Rendered template is not valid JSON"
62
+ warn e
63
+ exit 1
64
+ end
65
+ response
51
66
  end
52
67
 
53
68
  def templates_file(dict)
@@ -1,5 +1,5 @@
1
1
  module GH
2
2
  module Events
3
- VERSION = "0.8.2"
3
+ VERSION = "0.8.3"
4
4
  end
5
5
  end
@@ -17,7 +17,7 @@ commit_comment:
17
17
  commit <<%= comment.html_url %>|`<%= comment.commit_id %>`>
18
18
  on <<%= repository.html_url %>|<%= repository.full_name %>>
19
19
  attachments:
20
- - fallback: <%= comment.body %>
20
+ - fallback: <%= comment.body.gsub(/"/,'\"') %>
21
21
  color: '#36a64f'
22
22
  # pretext: Optional text that appears above the attachment block
23
23
  author_name: <%= sender.login %>
@@ -25,7 +25,7 @@ commit_comment:
25
25
  author_icon: <%= sender.avatar_url %>
26
26
  # title: Slack API Documentation
27
27
  # title_link: https://api.slack.com/
28
- text: <%= comment.body %>
28
+ text: <%= comment.body.gsub(/"/,'\"') %>
29
29
  # fields:
30
30
  # - title: Priority
31
31
  # value: High
@@ -57,14 +57,14 @@ issue_comment:
57
57
  :left_speech_bubble:
58
58
  <<%= sender.html_url %>|<%= sender.login %>>
59
59
  commented
60
- on <<%= comment.html_url %>|<%= issue.title %>>
60
+ on <<%= comment.html_url %>|<%= issue.title.gsub(/"/,'\"') %>>
61
61
  attachments:
62
- - fallback: <%= comment.body %>
62
+ - fallback: <%= comment.body.gsub(/"/,'\"') %>
63
63
  color: '#36a64f'
64
64
  author_name: <%= sender.login %>
65
65
  author_link: <%= sender.html_url %>
66
66
  author_icon: <%= sender.avatar_url %>
67
- text: <%= comment.body %>
67
+ text: <%= comment.body.gsub(/"/,'\"') %>
68
68
 
69
69
  issues:
70
70
  text: >-
@@ -143,12 +143,12 @@ pull_request_review_comment:
143
143
  new review comment
144
144
  on <<%= comment.html_url %>|<%= pull_request.title %>>
145
145
  attachments:
146
- - fallback: <%= comment.body %>
146
+ - fallback: <%= comment.body.gsub(/"/,'\"') %>
147
147
  color: red
148
148
  author_name: <%= sender.login %>
149
149
  author_link: <%= sender.html_url %>
150
150
  author_icon: <%= sender.avatar_url %>
151
- text: <%= comment.body %>
151
+ text: <%= comment.body.gsub(/"/,'\"') %>
152
152
 
153
153
  star:
154
154
  text: >-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Hofmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-04 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler