lita-broadcast 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07dc19c95a64ff558d38a06d1fc2f3cb4845fd1c
4
+ data.tar.gz: f02061e690d59d1f9e3954230331ba7ba167cb6a
5
+ SHA512:
6
+ metadata.gz: 5e0fa759ae2c9539bca2603b40ccb901a17c0501eef02c82e4ece8dad329a68357d49bfe3e4e75dcccb30fb9ef825ddabb99dd127416d395ef972935a52d4102
7
+ data.tar.gz: 91c9e0d316fae995dbcf0fbb5f37f886f183cb058564efba62adc3c2051dd8cae2e2e666437827f213a44f286cf9e5d3ae4de9afc0bf411fc8986e6f7caf91da
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ FileName:
2
+ Exclude:
3
+ - lib/lita-broadcast.rb
4
+
5
+ LineLength:
6
+ Max: 130
7
+
8
+ AbcSize:
9
+ Max: 30
10
+
11
+ MethodLength:
12
+ Max: 20
13
+
14
+ ClassLength:
15
+ Max: 150
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ cache: bundler
6
+ sudo: false
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # This is temporary until https://github.com/litaio/lita/pull/166 is merged
6
+ gem 'lita', git: 'git@github.com:tristaneuan/lita', branch: 'room-find-try-strip-hash'
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2016 Tristan Chong
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # lita-broadcast
2
+
3
+ [![Build Status](https://travis-ci.org/tristaneuan/lita-broadcast.png?branch=master)](https://travis-ci.org/tristaneuan/lita-broadcast)
4
+ [![Coverage Status](https://coveralls.io/repos/tristaneuan/lita-broadcast/badge.png)](https://coveralls.io/r/tristaneuan/lita-broadcast)
5
+
6
+ **lita-broadcast** is a handler for [Lita](https://github.com/litaio/lita) that allows messages to be sent to multiple channels simultaneously.
7
+
8
+ ## Installation
9
+
10
+ Add lita-broadcast to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem "lita-broadcast"
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ The command `tell #room1 #room2: <your message here>` will send everything to the right of the `:` to #room1 and #room2.
19
+
20
+ For example,
21
+ ```
22
+ <john> lita: tell #engineering #operations #helpdesk: hello
23
+ ```
24
+ The channels #engineering #operations and #helpdesk will all see the message:
25
+ ```
26
+ <lita> @john says: hello
27
+ ```
28
+
29
+ ## License
30
+
31
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
7
+
8
+ task default: [:spec, :rubocop]
@@ -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/broadcast'
8
+
9
+ Lita::Handlers::Broadcast.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'),
11
+ __FILE__
12
+ )
@@ -0,0 +1,35 @@
1
+ module Lita
2
+ module Handlers
3
+ # Send a message to multiple channels simultaneously.
4
+ class Broadcast < Handler
5
+ route(/^tell\s+(?<channels>[^:]+):\s*(?<message>.+)/i,
6
+ :broadcast,
7
+ command: true,
8
+ help: { t('help.broadcast_key') => t('help.broadcast_value') })
9
+
10
+ def broadcast(response)
11
+ channels = response.match_data['channels'].strip.split
12
+ message = response.match_data['message']
13
+
14
+ channels.each do |identifier|
15
+ target = channel_for(identifier)
16
+ return response.reply(t('broadcast.not_found', channel: identifier)) if target.nil?
17
+
18
+ robot.send_message(target, render_template('broadcast',
19
+ user: response.user,
20
+ says: t('broadcast.says'),
21
+ message: message))
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def channel_for(identifier)
28
+ room = Lita::Room.fuzzy_find(identifier)
29
+ Source.new(room: room) if room
30
+ end
31
+
32
+ Lita.register_handler(self)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-broadcast'
3
+ spec.version = '0.1.0'
4
+ spec.authors = ['Tristan Chong']
5
+ spec.email = ['ong@tristaneuan.ch']
6
+ spec.description = 'A Lita handler to broadcast a message to multiple channels simultaneously.'
7
+ spec.summary = spec.description
8
+ spec.homepage = 'https://github.com/tristaneuan/lita-broadcast'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
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', '>= 5.0'
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
+ spec.add_development_dependency 'rubocop'
25
+ spec.add_development_dependency 'simplecov'
26
+ spec.add_development_dependency 'coveralls'
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,10 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ broadcast:
5
+ help:
6
+ broadcast_key: "tell #room1 #room2: <your message here>"
7
+ broadcast_value: "Broadcast a message to multiple rooms."
8
+ broadcast:
9
+ not_found: "Channel '%{channel}' does not exist."
10
+ says: "says"
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Broadcast, lita_handler: true do
4
+ it { is_expected.to route_command('tell #channel1: hello').to(:broadcast) }
5
+ it { is_expected.to route_command('tell #channel1 C2: hello').to(:broadcast) }
6
+
7
+ describe '#broadcast' do
8
+ let(:user1) { Lita::User.create('U1', name: 'User1', mention_name: 'user1') }
9
+ let(:channel1) { Lita::Room.create_or_update('C1', name: 'channel1') }
10
+ let(:channel2) { Lita::Room.create_or_update('C2', name: 'channel2') }
11
+
12
+ it 'sends the message to multiple targets' do
13
+ expect(Lita::Room).to receive(:fuzzy_find).with('#channel1').and_return(channel1)
14
+ expect(Lita::Room).to receive(:fuzzy_find).with('C2').and_return(channel2)
15
+ expect(robot).to receive(:send_message).with(instance_of(Lita::Source), 'user1 says: hello').twice
16
+ send_command('tell #channel1 C2: hello', as: user1)
17
+ end
18
+
19
+ it 'replies with an error if a given channel does not exist' do
20
+ send_command('tell #channel3: hello', as: user1)
21
+ expect(replies.count).to eq(1)
22
+ expect(replies.last).to eq("Channel '#channel3' does not exist.")
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatters = [
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-broadcast'
10
+ require 'lita/rspec'
@@ -0,0 +1 @@
1
+ <%= @user.mention_name %> <%= @says %>: <%= @message %>
@@ -0,0 +1 @@
1
+ <@<%= @user.id %>> <%= @says %>: <%= @message %>
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-broadcast
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tristan Chong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-14 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: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
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
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: A Lita handler to broadcast a message to multiple channels simultaneously.
140
+ email:
141
+ - ong@tristaneuan.ch
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rubocop.yml"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - LICENSE
151
+ - README.md
152
+ - Rakefile
153
+ - lib/lita-broadcast.rb
154
+ - lib/lita/handlers/broadcast.rb
155
+ - lita-broadcast.gemspec
156
+ - locales/en.yml
157
+ - spec/lita/handlers/broadcast_spec.rb
158
+ - spec/spec_helper.rb
159
+ - templates/broadcast.erb
160
+ - templates/broadcast.slack.erb
161
+ homepage: https://github.com/tristaneuan/lita-broadcast
162
+ licenses:
163
+ - MIT
164
+ metadata:
165
+ lita_plugin_type: handler
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.4.5
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: A Lita handler to broadcast a message to multiple channels simultaneously.
186
+ test_files:
187
+ - spec/lita/handlers/broadcast_spec.rb
188
+ - spec/spec_helper.rb