lita-hook-forward 1.0.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: 208a3e42826858a59a44ca8db382fd4e7cfd7136
4
+ data.tar.gz: 214bc5598536566b1feedffbd1060efd86ee717e
5
+ SHA512:
6
+ metadata.gz: ba58cc53f58bb23f3dc329b726e10c63988eef42c42b8981447fe13c0ecd87397c1fa1233b2afddec383625205ee58252fea22b87b478e4f0c31d1006c487bf1
7
+ data.tar.gz: 014865d94d5d4c5a922f80a46a0d0da78cde7abaa58216cfc32fc0e6eb2ce9efaf2f7f5bb364061b0670cfe2bfee5f7b84f321563d363c806413ccf75dff8e0c
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea/*
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Milo
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,40 @@
1
+ # lita-hook-forward
2
+
3
+ [![Build Status](https://travis-ci.org/milo-ft/lita-hook-forward.png)](https://travis-ci.org/milo-ft/lita-hook-forward)
4
+ [![Code Climate](https://codeclimate.com/github/milo-ft/lita-hook-forward.png)](https://codeclimate.com/github/milo-ft/lita-hook-forward)
5
+ [![Coverage Status](https://coveralls.io/repos/milo-ft/lita-hook-forward/badge.png)](https://coveralls.io/r/milo-ft/lita-hook-forward)
6
+
7
+ **lita-hook-forward** is a simple [Lita](https://github.com/jimmycuadra/lita) handler that will forward any message coming from a hook.
8
+
9
+ ## Installation
10
+
11
+ Add **lita-hook-forward** to your Lita instance's Gemfile:
12
+
13
+ ``` ruby
14
+ gem "lita-hook-forward"
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ### Required attributes
20
+
21
+ * `default_room` (String) - The default room or rooms (comma separated).
22
+ i.e.: `#general`.
23
+
24
+ ### Example
25
+
26
+ ``` ruby
27
+ Lita.configure do |config|
28
+ config.handlers.hook_forwarder.default_room = '#general'
29
+ end
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```
35
+ http://.slackserver/lita/hook-forward?targets=%23&message=Hello%20everyone
36
+ ```
37
+
38
+ ## License
39
+
40
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/hook_forward'
@@ -0,0 +1,28 @@
1
+ module Lita
2
+ module Handlers
3
+ class HookForward < Handler
4
+
5
+ #noinspection RubyArgCount
6
+ http.get '/lita/hook-forward', :receive
7
+
8
+ def self.default_config(handler_config)
9
+ handler_config.default_room = nil
10
+ end
11
+
12
+ def receive(request, response)
13
+ message = request.params['message']
14
+ targets = request.params['targets'] || Lita.config.handlers.hook_forward.default_room || nil
15
+ rooms = []
16
+ targets.split(',').each do |param_target|
17
+ rooms << param_target
18
+ end
19
+ rooms.each do |room|
20
+ target = Source.new(room: room)
21
+ robot.send_message(target, message)
22
+ end
23
+ end
24
+ end
25
+
26
+ Lita.register_handler(HookForward)
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-hook-forward'
3
+ spec.version = '1.0.0'
4
+ spec.authors = ['Emilio Figueroa']
5
+ spec.email = ['emiliofigueroatorres@gmail.com']
6
+ spec.description = %q{A simple Lita handler that will forward any message coming from a hook}
7
+ spec.summary = %q{A simple Lita handler that will forward any message coming from a hook}
8
+ spec.homepage = 'https://github.com/milo-ft/lita-hook-forward'
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', '>= 3.0'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'rake'
21
+ spec.add_development_dependency 'rspec', '>= 3.0.0.beta2'
22
+ spec.add_development_dependency 'shoulda', '>= 3.5.0'
23
+ spec.add_development_dependency 'simplecov'
24
+ spec.add_development_dependency 'coveralls'
25
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ hook_forward:
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::HookForward, lita_handler: true do
4
+
5
+ it { routes_http(:get, '/lita/hook-forward').to(:receive) }
6
+
7
+ describe '#receive' do
8
+
9
+ let(:request) do
10
+ request = double('Rack::Request')
11
+ allow(request).to receive(:params).and_return(params)
12
+ request
13
+ end
14
+ let(:params) { {'message' => 'hello'} }
15
+ let(:response) { Rack::Response.new }
16
+
17
+ before { Lita.config.handlers.hook_forward.default_room = '#baz' }
18
+
19
+ it 'sends a notification message to the applicable rooms' do
20
+ expect(robot).to receive(:send_message) do |target, message|
21
+ expect(target.room).to eq('#baz')
22
+ expect(message).to include('hello')
23
+ end
24
+ subject.receive(request, response)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-hook-forward'
10
+ require 'lita/rspec'
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-hook-forward
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Emilio Figueroa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 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: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.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: rake
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta2
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 3.5.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 3.5.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
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
+ description: A simple Lita handler that will forward any message coming from a hook
112
+ email:
113
+ - emiliofigueroatorres@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - Gemfile
121
+ - LICENSE
122
+ - README.md
123
+ - Rakefile
124
+ - lib/lita-hook-forward.rb
125
+ - lib/lita/handlers/hook_forward.rb
126
+ - lita-hook-forward.gemspec
127
+ - locales/en.yml
128
+ - spec/lita/handlers/hook_forward_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/milo-ft/lita-hook-forward
131
+ licenses:
132
+ - MIT
133
+ metadata:
134
+ lita_plugin_type: handler
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.2.2
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: A simple Lita handler that will forward any message coming from a hook
155
+ test_files:
156
+ - spec/lita/handlers/hook_forward_spec.rb
157
+ - spec/spec_helper.rb
158
+ has_rdoc: