tokite 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +1 -1
- data/app/models/tokite/hook.rb +15 -3
- data/app/models/tokite/search_query.rb +6 -7
- data/config/initializers/slack_notifier.rb +5 -2
- data/lib/tokite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb6c1963e12671ffb181f21e5a803cb8647b0fca
|
4
|
+
data.tar.gz: 70dd44f3f98fd90d117bba39141ce8bea4f3c18e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a5e28cc53e790c81e14015b50c7240c895d5653feb512921654655f453f39165b30f625faf525c69c05d1dd1b4c3fd11c1a25a4f098b2593d5335800c43690
|
7
|
+
data.tar.gz: e843fd54bdd8091a801a55deaa32e8dcdf39980fd74551c26ec50987c4ab753b237430347915c6e2136147fa0486e06031854e90babbcc4e479dce22f6cb2b72
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Tokite [](https://circleci.com/gh/hogelog/tokite)
|
1
|
+
# Tokite [](https://circleci.com/gh/hogelog/tokite) [](https://badge.fury.io/rb/tokite)
|
2
2
|
|
3
3
|
Tokite send GitHub event (pull-request, issue and comment) to Slack.
|
4
4
|
|
data/app/models/tokite/hook.rb
CHANGED
@@ -19,15 +19,27 @@ module Tokite
|
|
19
19
|
|
20
20
|
def fire!
|
21
21
|
return unless event.notify?
|
22
|
+
payloads = []
|
22
23
|
Rule.matched_rules(event).each do |rule|
|
23
24
|
attachment = event.slack_attachment
|
24
25
|
attachment[:fallback] += "\n\n#{rule.slack_attachment_fallback}"
|
25
26
|
attachment[:text] += "\n\n#{rule.slack_attachment_text}"
|
26
27
|
emoji = rule.icon_emoji.chomp.presence
|
27
28
|
additional_text = rule.additional_text
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
|
30
|
+
if payloads.none? {|payload| payload[:channel] == rule.channel && payload[:icon_emoji] == emoji && payload[:additional_text] == additional_text }
|
31
|
+
payloads << {
|
32
|
+
channel: rule.channel,
|
33
|
+
text: event.slack_text,
|
34
|
+
icon_emoji: emoji,
|
35
|
+
additional_text: additional_text,
|
36
|
+
attachments: [attachment],
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
payloads.each do |payload|
|
41
|
+
notify!(channel: payload[:channel], text: payload[:text], icon_emoji: payload[:emoji], attachments: payload[:attachment])
|
42
|
+
notify!(channel: payload[:channel], text: payload[:additional_text], icon_emoji: payload[:emoji], parse: "full") if payload[:additional_text].present?
|
31
43
|
end
|
32
44
|
end
|
33
45
|
|
@@ -3,7 +3,7 @@ require "parslet"
|
|
3
3
|
module Tokite
|
4
4
|
class SearchQuery
|
5
5
|
attr_reader :query, :tree
|
6
|
-
|
6
|
+
|
7
7
|
class ParseError < StandardError
|
8
8
|
end
|
9
9
|
|
@@ -11,12 +11,11 @@ module Tokite
|
|
11
11
|
rule(:space) { match('\s').repeat(1) }
|
12
12
|
rule(:space?) { space.maybe }
|
13
13
|
|
14
|
-
rule(:escape) { str('\\').ignore }
|
15
14
|
rule(:quot) { str('"') }
|
16
|
-
rule(:quoted_char) {
|
15
|
+
rule(:quoted_char) { (str('\\').ignore >> any) | match('[^"]') }
|
17
16
|
rule(:char) { match('[^\s]') }
|
18
17
|
rule(:slash) { str('/') }
|
19
|
-
rule(:regexp_char) {
|
18
|
+
rule(:regexp_char) { (str('\\').ignore >> slash) | match('[^/]') }
|
20
19
|
|
21
20
|
rule(:regexp_word) { slash >> regexp_char.repeat(1).as(:regexp_word) >> slash }
|
22
21
|
rule(:quot_word) { quot >> quoted_char.repeat(1).as(:word) >> quot }
|
@@ -37,7 +36,7 @@ module Tokite
|
|
37
36
|
rescue Parslet::ParseFailed => e
|
38
37
|
raise ParseError, e
|
39
38
|
end
|
40
|
-
|
39
|
+
|
41
40
|
def initialize(query)
|
42
41
|
@query = query
|
43
42
|
@tree = Array.wrap(self.class.parse(query))
|
@@ -52,8 +51,8 @@ module Tokite
|
|
52
51
|
targets = doc.values.map(&:downcase)
|
53
52
|
end
|
54
53
|
if word[:regexp_word]
|
55
|
-
regexp = word[:regexp_word].to_s
|
56
|
-
targets.any?{|text|
|
54
|
+
regexp = Regexp.compile(word[:regexp_word].to_s, Regexp::IGNORECASE)
|
55
|
+
targets.any?{|text| regexp.match?(text) }
|
57
56
|
else
|
58
57
|
value = word[:word].to_s.downcase
|
59
58
|
targets.any?{|text| text.index(value) }
|
@@ -1,6 +1,9 @@
|
|
1
1
|
if ENV["SLACK_WEBHOOK_URL"]
|
2
2
|
Tokite::Engine.config.slack_notifier = Slack::Notifier.new ENV["SLACK_WEBHOOK_URL"] do
|
3
|
-
|
4
|
-
|
3
|
+
if ENV["SLACK_ICON_EMOJI"]
|
4
|
+
defaults username: ENV.fetch("SLACK_NAME", "tokite"), icon_emoji: ENV["SLACK_ICON_EMOJI"]
|
5
|
+
else
|
6
|
+
defaults username: ENV.fetch("SLACK_NAME", "tokite")
|
7
|
+
end
|
5
8
|
end
|
6
9
|
end
|
data/lib/tokite/version.rb
CHANGED