summon_bot 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: 0ae08d702fbcd402f1f0b39a205c1aea95343c4d
4
+ data.tar.gz: 694b641beebbf694ede8ee5f41c151036eebd8cd
5
+ SHA512:
6
+ metadata.gz: 9717ab2af161a4dd3801a380183bb0e6ead78d60f8ad95282fca8120c35bbb415c09943dafe0f98c9eed1cc88ed0b4fbf09c40c51d409ddd5e4ce52fc3b06023
7
+ data.tar.gz: dda3636671cba3628e43de155404431b83252bc0fc13fdbe43a8b884769656472ef65d699aec7676cf821f19ecb0bb69ba14b6a681c54f9de9ad0b0de3ad8246
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 nyaahara
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # SummonBot
2
+
3
+ SummonBot can summon slack bot only define your environment.
4
+ SummonBot is Wrapped gem `Slack::Notifier`
5
+
6
+ ## Installation
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'summon_bot'
11
+ ```
12
+
13
+ And then execute:
14
+ ```bash
15
+ $ bundle
16
+ ```
17
+
18
+ Or install it yourself as:
19
+ ```bash
20
+ $ gem install summon_bot
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ First, define your environment for example
26
+
27
+ .env
28
+ ```
29
+ SUMMON_BOT_SLACK__NATTSUNN=https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/XXXXXXXX
30
+ ```
31
+
32
+ ```
33
+ SummonBot::Slack.nattsunn.speak('notification')
34
+ => #<Net::HTTPOK 200 OK readbody=true>
35
+ ```
36
+
37
+ And this:
38
+
39
+ ![](https://gyazo.com/151508f7304326f65edfe4bd5b029097/raw)
40
+
41
+
42
+
43
+ If you want to use dummy notification class, write this your code.
44
+ `initializer/summon_bot.rb` instead.
45
+
46
+ ```
47
+ SummonBot::Slack.instance_eval { @notifier_class = SummonBot::DummyNotifier }
48
+ ```
49
+
50
+
51
+ ## Test command.
52
+
53
+ ```
54
+ RAILS_ENV=test bers
55
+ ```
56
+
57
+ ## License
58
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
59
+
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SummonBot'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,15 @@
1
+ module SummonBot
2
+ class DummyNotifier
3
+ def initialize(_)
4
+ end
5
+
6
+ def speak(message)
7
+ ping("[ENV=#{Rails.env}] #{message}")
8
+ end
9
+
10
+ def ping(message)
11
+ puts '[warning] Slack notification is disabled.'
12
+ puts message
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module SummonBot
2
+ class Slack
3
+ PREFIX = 'SUMMON_BOT_SLACK__'
4
+ class << self
5
+ def method_missing(name)
6
+ bot_names = ENV.keys.select { |k, _| k.include? PREFIX }.map { |k| k.gsub(Regexp.new("^#{PREFIX}"), '').downcase.to_sym }
7
+ fail NoMethodError unless bot_names.include? name
8
+ bot = notifier_class.new(ENV["#{PREFIX}#{name.upcase}"])
9
+
10
+ def bot.speak(message)
11
+ ping("[ENV=#{Rails.env}] #{message}")
12
+ end
13
+
14
+ bot
15
+ end
16
+
17
+ def notifier_class
18
+ # For testing
19
+ @notifier_class || ::Slack::Notifier
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module SummonBot
2
+ VERSION = '1.0.0'
3
+ end
data/lib/summon_bot.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "summon_bot/slack"
2
+ require "summon_bot/dummy_notifier"
3
+
4
+ module SummonBot
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :summon_bot do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: summon_bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - nyaahara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: slack-notifier
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry-byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description: SummonBot can summon slack bot only define your environment. SummonBot
90
+ is Wrapped gem Slack::Notifier
91
+ email:
92
+ - d.niihara@gmail.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - MIT-LICENSE
98
+ - README.md
99
+ - Rakefile
100
+ - lib/summon_bot.rb
101
+ - lib/summon_bot/dummy_notifier.rb
102
+ - lib/summon_bot/slack.rb
103
+ - lib/summon_bot/version.rb
104
+ - lib/tasks/summon_bot_tasks.rake
105
+ homepage: https://github.com/nyaahara/summon_bot
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: SummonBot can summon slack bot only define your environment.
129
+ test_files: []
130
+ has_rdoc: