slackit 0.1.1 → 1.0.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 +4 -4
- data/README.md +27 -1
- data/exe/slackit +88 -0
- data/lib/slackit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9700ad1f84b30e2c6a0ebc232af6a61067ceb71de7ac797d89fb6c2c8cf9db
|
4
|
+
data.tar.gz: 11001201fd5ccdb9b084383ee53793ee3695f038513a6d71d626c288f5f58879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e28ddc17a9ecda1269989d275d53237e595365c76d9c55bc3a33383e605f7d1ac1eee1026d125c0146871a632f981bc2a54937deed61dde9b74e5103da380eb7
|
7
|
+
data.tar.gz: a2240167e394e4b24ba981498cb6711f28d8193124b8a70ef528499568ad1ba25829f7b65f13c62608ae4d9bd9254196fa0c774af0c78ba6c7714f765018585e
|
data/README.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
[](https://travis-ci.org/AntiPhotonltd/slackit)
|
2
|
+
[](LICENSE.md)
|
3
|
+
[](https://github.com/AntiPhotonltd/slackit/releases/latest)
|
4
|
+
[](https://badge.fury.io/rb/slackit)
|
5
|
+
[](https://github.com/AntiPhotonltd/slackit/commits)
|
6
|
+
[](https://github.com/AntiPhotonltd/slackit)
|
7
|
+
[](https://github.com/AntiPhotonltd/slackit)
|
8
|
+
|
1
9
|
# Slackit
|
2
10
|
|
3
11
|
Slackit is a very simply Ruby Gem for posting to a slack incoming webhook.
|
@@ -20,7 +28,25 @@ Or install it yourself as:
|
|
20
28
|
|
21
29
|
## Usage
|
22
30
|
|
23
|
-
|
31
|
+
Using this Gem is VERY simply, everything apart from the webhook and the message are optional.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
s = Slackit.new(options[:webhook], options[:channel], options[:username], options[:emoji])
|
35
|
+
|
36
|
+
s.send(options[:message])
|
37
|
+
```
|
38
|
+
|
39
|
+
### Command Line Usage
|
40
|
+
|
41
|
+
```
|
42
|
+
Usage: slackit
|
43
|
+
-h, --help Display this screen
|
44
|
+
-c, --channel string The channel to send the message to
|
45
|
+
-e, --emoji string The emoji to use [default: :wolf:]
|
46
|
+
-m, --message string The message to send
|
47
|
+
-w, --webhook string The slack incoming webhook to use
|
48
|
+
-u, --username string The username to send as [default: slackit]
|
49
|
+
```
|
24
50
|
|
25
51
|
## Development
|
26
52
|
|
data/exe/slackit
CHANGED
@@ -1,3 +1,91 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'slackit'
|
5
|
+
|
6
|
+
# -------------------------------------------------------------------------------- #
|
7
|
+
# Send Mssage to Slack #
|
8
|
+
# -------------------------------------------------------------------------------- #
|
9
|
+
# This function will take the input arguments and then send the message. #
|
10
|
+
# -------------------------------------------------------------------------------- #
|
11
|
+
|
12
|
+
def send_message_to_slack(options)
|
13
|
+
s = Slackit.new(options[:webhook], options[:channel], options[:username], options[:emoji])
|
14
|
+
|
15
|
+
s.send(options[:message])
|
16
|
+
end
|
17
|
+
|
18
|
+
# -------------------------------------------------------------------------------- #
|
19
|
+
# Process Arguments #
|
20
|
+
# -------------------------------------------------------------------------------- #
|
21
|
+
# This function will process the input from the command line and work out what it #
|
22
|
+
# is that the user wants to see. #
|
23
|
+
# #
|
24
|
+
# This is the main processing function where all the processing logic is handled. #
|
25
|
+
# -------------------------------------------------------------------------------- #
|
26
|
+
|
27
|
+
def process_arguments
|
28
|
+
options = {}
|
29
|
+
# Enforce the presence of
|
30
|
+
mandatory = %I[webhook message]
|
31
|
+
|
32
|
+
optparse = OptionParser.new do |opts|
|
33
|
+
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
34
|
+
|
35
|
+
opts.on('-h', '--help', 'Display this screen') do
|
36
|
+
puts opts
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
opts.on('-c', '--channel string', 'The channel to send the message to') do |channel|
|
40
|
+
options[:channel] = channel
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on('-e', '--emoji string', 'The emoji to use [default: :wolf:]') do |emoji|
|
44
|
+
options[:emoji] = emoji
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('-m', '--message string', 'The message to send') do |message|
|
48
|
+
options[:message] = message
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on('-w', '--webhook string', 'The slack incoming webhook to use') do |webhook|
|
52
|
+
options[:webhook] = webhook
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on('-u', '--username string', 'The username to send as [default: slackit]') do |username|
|
56
|
+
options[:username] = username
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
begin
|
61
|
+
optparse.parse!
|
62
|
+
missing = mandatory.select { |param| options[param].nil? }
|
63
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
64
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
65
|
+
puts e.to_s
|
66
|
+
puts optparse
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
exit 0 if send_message_to_slack(options)
|
71
|
+
|
72
|
+
exit 1
|
73
|
+
end
|
74
|
+
|
75
|
+
# -------------------------------------------------------------------------------- #
|
76
|
+
# Main() #
|
77
|
+
# -------------------------------------------------------------------------------- #
|
78
|
+
# The main function where all of the heavy lifting and script config is done. #
|
79
|
+
# -------------------------------------------------------------------------------- #
|
80
|
+
|
81
|
+
def main
|
82
|
+
process_arguments
|
83
|
+
end
|
84
|
+
|
85
|
+
main
|
86
|
+
|
87
|
+
# -------------------------------------------------------------------------------- #
|
88
|
+
# End of Script #
|
89
|
+
# -------------------------------------------------------------------------------- #
|
90
|
+
# This is the end - nothing more to see here. #
|
91
|
+
# -------------------------------------------------------------------------------- #
|
data/lib/slackit/version.rb
CHANGED