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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -1
  3. data/exe/slackit +88 -0
  4. data/lib/slackit/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a774af55073cad544823784e272b4a83b227d14d8c77786490ec93da3e241faa
4
- data.tar.gz: 6e919a8568c83749e37e5ec699f4657afd673995c162df1103d07142bc49a211
3
+ metadata.gz: aa9700ad1f84b30e2c6a0ebc232af6a61067ceb71de7ac797d89fb6c2c8cf9db
4
+ data.tar.gz: 11001201fd5ccdb9b084383ee53793ee3695f038513a6d71d626c288f5f58879
5
5
  SHA512:
6
- metadata.gz: e6854b571ea0119dcbff3515a75df36567485bafbba3f560a187407678dbc5cfe66063030338b0ee4deea31306a1b2be9c5aff71e1e4e8968fa848be6d31f3f4
7
- data.tar.gz: 0bfb9cf3734b489aeac7ec40e586082cdb92bf7e6c494e431eaaa885aa99b933a465673f41f69ef6e529887893db1867fda6d9aa1a85ee09393afc50d6abdb3c
6
+ metadata.gz: e28ddc17a9ecda1269989d275d53237e595365c76d9c55bc3a33383e605f7d1ac1eee1026d125c0146871a632f981bc2a54937deed61dde9b74e5103da380eb7
7
+ data.tar.gz: a2240167e394e4b24ba981498cb6711f28d8193124b8a70ef528499568ad1ba25829f7b65f13c62608ae4d9bd9254196fa0c774af0c78ba6c7714f765018585e
data/README.md CHANGED
@@ -1,3 +1,11 @@
1
+ [![Build Status](https://img.shields.io/travis/AntiPhotonltd/slackit/master.svg)](https://travis-ci.org/AntiPhotonltd/slackit)
2
+ [![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
3
+ [![Release](https://img.shields.io/github/release/AntiPhotonltd/slackit.svg)](https://github.com/AntiPhotonltd/slackit/releases/latest)
4
+ [![Gem Version](https://badge.fury.io/rb/slackit.svg)](https://badge.fury.io/rb/slackit)
5
+ [![Github commits (since latest release)](https://img.shields.io/github/commits-since/AntiPhotonltd/slackit/latest.svg)](https://github.com/AntiPhotonltd/slackit/commits)
6
+ [![GitHub repo size in bytes](https://img.shields.io/github/repo-size/AntiPhotonltd/slackit.svg)](https://github.com/AntiPhotonltd/slackit)
7
+ [![GitHub contributors](https://img.shields.io/github/contributors/AntiPhotonltd/slackit.svg)](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
- To come
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
+ # -------------------------------------------------------------------------------- #
@@ -1,3 +1,3 @@
1
1
  class Slackit
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slackit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf