lita-build-notifications 0.1.0
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/build_notifications.rb +124 -0
- data/lib/lita-build-notifications.rb +12 -0
- data/lita-build-notifications.gemspec +24 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/build_notifications_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/.gitkeep +0 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b79923f4f8140f5295aefe8aababc892510df7e0
|
4
|
+
data.tar.gz: df2b5b690ee4f9caad3e7f94da783084c242f945
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a7848f4d72208d6a8d0b82952822a8eb5fee65e02b8575cdf6e31f9898fbb8da5154d1e234e61b5559f9b390fc9de608a035cf85d9aba82b1a375d04d2e38be
|
7
|
+
data.tar.gz: 5b4db0c2af49ab2860e6525536fc485e62b8f6673780105122e7a3f71e94265ee98f324c215d00c8611f3637c677e8e0946191a6fee8b8944deefea3a11f2f61
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# lita-build-notifications
|
2
|
+
|
3
|
+
This extension allows you to register for status changes of build events. It furthermore adds a HTTP POST endpoint
|
4
|
+
to Lita to inform about any build status changes.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add lita-build-notifications to your Lita instance's Gemfile:
|
9
|
+
|
10
|
+
``` ruby
|
11
|
+
gem "lita-build-notifications"
|
12
|
+
```
|
13
|
+
|
14
|
+
## Configuration
|
15
|
+
not required
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
### Commands
|
19
|
+
```
|
20
|
+
build notify <me|room-id> - notify you or the given room on build events
|
21
|
+
build list receivers - list all ids of who will be notified
|
22
|
+
build clear receivers - remove all receivers of build events
|
23
|
+
```
|
24
|
+
|
25
|
+
### HTTP Endpoints
|
26
|
+
Post a JSON in the following form to `http://yourlita/build/notify`:
|
27
|
+
```
|
28
|
+
{
|
29
|
+
"id":"build name or id",
|
30
|
+
"status": "build satatus (e.g. success)"
|
31
|
+
}
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class BuildNotifications < Handler
|
4
|
+
|
5
|
+
route(/^build\s+(.+)/, :buildCommand, command: true, help: {
|
6
|
+
"build notify <me|room-id>" => "notify you or the given room on build events",
|
7
|
+
"build list receivers" => "list all ids of who will be notified",
|
8
|
+
"build clear receivers" => "remove all receivers of build events"
|
9
|
+
})
|
10
|
+
|
11
|
+
http.post "/build/notify", :postNotification
|
12
|
+
|
13
|
+
def postNotification(request, response)
|
14
|
+
data = MultiJson.load(request.body)
|
15
|
+
notifyAll("Build: #{data['id']} Status: #{data['status']}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def notifyAll(message)
|
19
|
+
receivers = getReceivers()
|
20
|
+
receivers.each do |receiver|
|
21
|
+
target = receiverToTarget(receiver)
|
22
|
+
unless target == nil
|
23
|
+
robot.send_message(target, message)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def buildCommand(response)
|
29
|
+
args = response.args
|
30
|
+
command = args.shift
|
31
|
+
|
32
|
+
case command
|
33
|
+
when "notify"
|
34
|
+
addNotification(response, args)
|
35
|
+
when "list"
|
36
|
+
command = args.shift
|
37
|
+
case command
|
38
|
+
when "receivers"
|
39
|
+
listReceivers(response, args)
|
40
|
+
end
|
41
|
+
when "clear"
|
42
|
+
command = args.shift
|
43
|
+
case command
|
44
|
+
when "receivers"
|
45
|
+
clearAllReceivers(response)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def addNotification(response, args)
|
51
|
+
currentTargets = getReceivers()
|
52
|
+
|
53
|
+
if args[0] == "me"
|
54
|
+
if currentTargets.include? "private:#{response.user.id}"
|
55
|
+
response.reply_privately("You are already on the notify list.")
|
56
|
+
else
|
57
|
+
currentTargets << "user:#{response.user.id}"
|
58
|
+
response.reply_privately("You will be notified of build results.")
|
59
|
+
end
|
60
|
+
else
|
61
|
+
currentTargets << "room:#{args[0]}"
|
62
|
+
end
|
63
|
+
|
64
|
+
putReceivers(currentTargets)
|
65
|
+
end
|
66
|
+
|
67
|
+
def listReceivers(response, args)
|
68
|
+
currentTargets = getReceivers()
|
69
|
+
|
70
|
+
if currentTargets == nil
|
71
|
+
response.reply_privately("No one is registered to listen to build updates.")
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
response.reply_privately("These people follow my build updates:")
|
76
|
+
currentTargets.each do |target|
|
77
|
+
type = target.split(':')[0]
|
78
|
+
id = target.split(':')[1]
|
79
|
+
|
80
|
+
if type == "user"
|
81
|
+
user = Lita::User.find_by_id(id)
|
82
|
+
name = user.name
|
83
|
+
else
|
84
|
+
room = Lita::Room.find_by_id(id)
|
85
|
+
name = room.name
|
86
|
+
end
|
87
|
+
|
88
|
+
response.reply_privately("(#{type}) #{name}")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def clearAllReceivers(response)
|
93
|
+
putReceivers([])
|
94
|
+
response.reply_with_mention("All build receivers deleted!")
|
95
|
+
end
|
96
|
+
|
97
|
+
def getReceivers()
|
98
|
+
json = redis['notify']
|
99
|
+
if json == nil
|
100
|
+
return []
|
101
|
+
end
|
102
|
+
return MultiJson.load(json)
|
103
|
+
end
|
104
|
+
|
105
|
+
def putReceivers(recArray)
|
106
|
+
json = MultiJson.dump(recArray)
|
107
|
+
redis['notify'] = json
|
108
|
+
end
|
109
|
+
|
110
|
+
def receiverToTarget(receiver)
|
111
|
+
type = receiver.split(':')[0]
|
112
|
+
id = receiver.split(':')[1]
|
113
|
+
|
114
|
+
if type == "user"
|
115
|
+
return Lita::User.find_by_id(id)
|
116
|
+
else
|
117
|
+
return Lita::Room.find_by_id(id)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
Lita.register_handler(self)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require "lita/handlers/build_notifications"
|
8
|
+
|
9
|
+
Lita::Handlers::BuildNotifications.template_root File.expand_path(
|
10
|
+
File.join("..", "..", "templates"),
|
11
|
+
__FILE__
|
12
|
+
)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-build-notifications"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Daniel Eder"]
|
5
|
+
spec.email = ["daniel@deder.at"]
|
6
|
+
spec.description = "Allows to post build status information from HTTP to chat channels."
|
7
|
+
spec.summary = "This plugin provides a HTTP endpoint to post build status information and publishes it to subscribers in the chat."
|
8
|
+
spec.homepage = "https://github.com/lycis/lita-build-notification"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.7"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "pry-byebug"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rack-test"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
24
|
+
end
|
data/locales/en.yml
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
require "lita-build-notifications"
|
2
|
+
require "lita/rspec"
|
3
|
+
|
4
|
+
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
5
|
+
# was generated with Lita 4, the compatibility mode should be left disabled.
|
6
|
+
Lita.version_3_compatibility_mode = false
|
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-build-notifications
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Eder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0
|
97
|
+
description: Allows to post build status information from HTTP to chat channels.
|
98
|
+
email:
|
99
|
+
- daniel@deder.at
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/lita-build-notifications.rb
|
109
|
+
- lib/lita/handlers/build_notifications.rb
|
110
|
+
- lita-build-notifications.gemspec
|
111
|
+
- locales/en.yml
|
112
|
+
- spec/lita/handlers/build_notifications_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
- templates/.gitkeep
|
115
|
+
homepage: https://github.com/lycis/lita-build-notification
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata:
|
119
|
+
lita_plugin_type: handler
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.5.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: This plugin provides a HTTP endpoint to post build status information and
|
140
|
+
publishes it to subscribers in the chat.
|
141
|
+
test_files:
|
142
|
+
- spec/lita/handlers/build_notifications_spec.rb
|
143
|
+
- spec/spec_helper.rb
|