slackit 1.0.1 → 1.1.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/CHANGELOG.md +9 -0
- data/README.md +26 -5
- data/exe/slackit +12 -8
- data/lib/slackit/version.rb +1 -1
- data/lib/slackit.rb +8 -6
- data/spec/slackit_spec.rb +4 -0
- 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: dd46600c8819cc9d3ae4c44b2c94f7f1904436da707d3177872536e3ffe23d33
|
|
4
|
+
data.tar.gz: 72a88c29045497006e754242478125959c4003f17cc7360a93aba624f5d0293f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66d6c556a9958eb0eccd414f2d1fa03622235b055aa8e4af289808fbbd937f8e75d0f45639df83b70fb4cb6609e1215172157eafd3a7f060548083ed71694688
|
|
7
|
+
data.tar.gz: 186f2310fc4b6a7ccf2d2660b6cc7338abbe676c79f066055e75e877cd1ac34220e5b346738a70bad3015a271223412a013fc1c04cf445eb715e8b9467f5735f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 1.1.0 (January 22, 2019)
|
|
2
|
+
|
|
3
|
+
IMPROVEMENTS:
|
|
4
|
+
|
|
5
|
+
* Made the parameter list a map to make it easier to pass different combinations of options. ([@TGWolf][])
|
|
6
|
+
* Added additional testing to ensure a new class instance is created. ([@TGWolf][])
|
|
7
|
+
* Specifying no channel will now send the message to '#general'. ([@TGWolf][])
|
|
8
|
+
* Added better error handling to the CLI tool. ([@TGWolf][])
|
|
9
|
+
|
|
1
10
|
## 1.0.1 (January 22, 2019)
|
|
2
11
|
|
|
3
12
|
BUG FIX:
|
data/README.md
CHANGED
|
@@ -28,12 +28,31 @@ Or install it yourself as:
|
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
```ruby
|
|
32
|
+
require "slackit"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Initialize client:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
client = Slackit.new(webhook_url: "slack webhook url")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Initialize with options:
|
|
32
42
|
|
|
33
43
|
```ruby
|
|
34
|
-
|
|
44
|
+
client = SlackNotify::Client.new(
|
|
45
|
+
webhook_url: "slack webhook url",
|
|
46
|
+
channel: "#development",
|
|
47
|
+
username: "mybot",
|
|
48
|
+
icon_emoji: ":shipit:",
|
|
49
|
+
)
|
|
50
|
+
```
|
|
35
51
|
|
|
36
|
-
|
|
52
|
+
Initialize via shorthand method:
|
|
53
|
+
|
|
54
|
+
```Ruby
|
|
55
|
+
client = Slackit.new(options)
|
|
37
56
|
```
|
|
38
57
|
|
|
39
58
|
### Command Line Usage
|
|
@@ -42,9 +61,9 @@ Using this Gem is VERY simply, everything apart from the webhook and the message
|
|
|
42
61
|
Usage: slackit
|
|
43
62
|
-h, --help Display this screen
|
|
44
63
|
-c, --channel string The channel to send the message to
|
|
45
|
-
-
|
|
64
|
+
-i, --icon-emoji string The emoji to use as the channel icon [default: :wolf:]
|
|
46
65
|
-m, --message string The message to send
|
|
47
|
-
-w, --webhook string
|
|
66
|
+
-w, --webhook-url string The slack incoming webhook url to use
|
|
48
67
|
-u, --username string The username to send as [default: slackit]
|
|
49
68
|
```
|
|
50
69
|
|
|
@@ -56,6 +75,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
56
75
|
|
|
57
76
|
## Testing
|
|
58
77
|
|
|
78
|
+
For local testing make sure that you run `bundle exec rspec spec` and then `rake install` to install the gem locally.
|
|
79
|
+
|
|
59
80
|
## Contributing
|
|
60
81
|
|
|
61
82
|
Bug reports and pull requests are welcome on GitHub at https://github.com/AntiPhotonltd/slackit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/exe/slackit
CHANGED
|
@@ -10,9 +10,13 @@ require 'slackit'
|
|
|
10
10
|
# -------------------------------------------------------------------------------- #
|
|
11
11
|
|
|
12
12
|
def send_message_to_slack(options)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
begin
|
|
14
|
+
s = Slackit.new(webhook_url: options[:webhook_url], channel: options[:channel], username: options[:username], icon_emoji: options[:icon_emoji])
|
|
15
|
+
s.send(options[:message])
|
|
16
|
+
rescue ArgumentError
|
|
17
|
+
puts "You must specify a webhook_url"
|
|
18
|
+
exit(1)
|
|
19
|
+
end
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
# -------------------------------------------------------------------------------- #
|
|
@@ -27,7 +31,7 @@ end
|
|
|
27
31
|
def process_arguments
|
|
28
32
|
options = {}
|
|
29
33
|
# Enforce the presence of
|
|
30
|
-
mandatory = %I[
|
|
34
|
+
mandatory = %I[webhook_url message]
|
|
31
35
|
|
|
32
36
|
optparse = OptionParser.new do |opts|
|
|
33
37
|
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
|
@@ -40,16 +44,16 @@ def process_arguments
|
|
|
40
44
|
options[:channel] = channel
|
|
41
45
|
end
|
|
42
46
|
|
|
43
|
-
opts.on('-
|
|
44
|
-
options[:
|
|
47
|
+
opts.on('-i', '--icon-emoji string', 'The emoji to use for the channel icon [default: :wolf:]') do |icon_emoji|
|
|
48
|
+
options[:icon_emoji] = icon_emoji
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
opts.on('-m', '--message string', 'The message to send') do |message|
|
|
48
52
|
options[:message] = message
|
|
49
53
|
end
|
|
50
54
|
|
|
51
|
-
opts.on('-w', '--webhook string', 'The slack incoming webhook to use') do |
|
|
52
|
-
options[:
|
|
55
|
+
opts.on('-w', '--webhook-url string', 'The slack incoming webhook url to use') do |webhook_url|
|
|
56
|
+
options[:webhook_url] = webhook_url
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
opts.on('-u', '--username string', 'The username to send as [default: slackit]') do |username|
|
data/lib/slackit/version.rb
CHANGED
data/lib/slackit.rb
CHANGED
|
@@ -5,11 +5,13 @@ require 'httparty'
|
|
|
5
5
|
# To follow
|
|
6
6
|
#
|
|
7
7
|
class Slackit
|
|
8
|
-
def initialize(
|
|
9
|
-
@webhook_url
|
|
10
|
-
@
|
|
11
|
-
@
|
|
12
|
-
@icon_emoji
|
|
8
|
+
def initialize(options = {})
|
|
9
|
+
@webhook_url = options[:webhook_url]
|
|
10
|
+
@username = options[:username]
|
|
11
|
+
@channel = options[:channel]
|
|
12
|
+
@icon_emoji = options[:icon_emoji]
|
|
13
|
+
|
|
14
|
+
raise ArgumentError.new('Webhook URL required') if @webhook_url.nil?
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
# sends a notification
|
|
@@ -22,7 +24,7 @@ class Slackit
|
|
|
22
24
|
body = { 'text': text, 'icon_emoji': @icon_emoji, username: @username }
|
|
23
25
|
|
|
24
26
|
# add the channel if there is one otherwise the default channel
|
|
25
|
-
body['channel'] = @channel
|
|
27
|
+
body['channel'] = @channel || '#general'
|
|
26
28
|
|
|
27
29
|
begin
|
|
28
30
|
response = HTTParty.post(@webhook_url, body: body.to_json, headers: headers)
|
data/spec/slackit_spec.rb
CHANGED