slackdraft 1.0.1 → 1.0.2
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 +42 -36
- data/examples/README.md +3 -0
- data/lib/slackdraft/base.rb +1 -1
- data/lib/slackdraft/message.rb +5 -10
- data/lib/slackdraft/version.rb +1 -1
- metadata +2 -2
- data/slackdraft-1.0.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a3d20d902033420d44050a957cb89bc1c76a038
|
4
|
+
data.tar.gz: 57f127c0596a44ac40b099bc9f4dc7d9ca51d9f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd799b3cd20ad0aff2596b2c8bdc1db6602adbbf7fd82010c35d7383126fa100a2675d7920065a681d1af0c7ce068549e84eec6a62ece201968f4520db7c26d
|
7
|
+
data.tar.gz: f4967737ba77b035a8add917c19cd895248d4c26d830344982c3f744ad5d8102e696136703ec0fe73a37aba29c828c8920d55af02b5a50bbbffe072ee94de972
|
data/README.md
CHANGED
@@ -7,36 +7,38 @@ Simplest way to send messages to Slack.
|
|
7
7
|
|
8
8
|
Like any other gem:
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
```shell
|
11
|
+
gem install slackdraft
|
12
|
+
```
|
12
13
|
|
13
14
|
# Ruby Usage
|
14
15
|
|
15
16
|
Usage is very simple:
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# Url of the icon or emoji
|
22
|
-
# slack.icon_url = "https://..."
|
23
|
-
slack.icon_emoji = ":fire:"
|
18
|
+
```ruby
|
19
|
+
require 'slackdraft'
|
20
|
+
url = "https://slack/webhook/url"
|
21
|
+
slack = Slackdraft::Message.new(url)
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
# Url of the icon or emoji
|
24
|
+
# slack.icon_url = "https://..."
|
25
|
+
slack.icon_emoji = ":fire:"
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
# Set the bot username
|
28
|
+
slack.username = "SlackDraft"
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
# Set the channel
|
31
|
+
slack.channel = "#general"
|
33
32
|
|
34
|
-
|
35
|
-
|
33
|
+
# Set text
|
34
|
+
# Or you can pass text in as an array
|
35
|
+
# slack.text = ["Your message here!", ">_*And can have* formatting_"]
|
36
|
+
slack.text = "Your message here! _*And can have* formatting_"
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
# Send the message
|
39
|
+
slack.send!
|
40
|
+
#-> true/false
|
41
|
+
```
|
40
42
|
|
41
43
|
For more examples, see the `examples/` directory.
|
42
44
|
|
@@ -44,27 +46,31 @@ For more examples, see the `examples/` directory.
|
|
44
46
|
|
45
47
|
It's dumb simple. Instead of using `curl`, use this:
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
```shell
|
50
|
+
slackdraft -u mike \
|
51
|
+
-c "#slackdraft" \
|
52
|
+
-m "This is our *formammted message*" \
|
53
|
+
https://hooks.slack.com/services/xxxxxxx
|
54
|
+
```
|
51
55
|
|
52
56
|
> **Note**: The CLI version does not support Slack Attachments
|
53
57
|
|
54
58
|
## Help text
|
55
59
|
|
56
|
-
|
57
|
-
|
60
|
+
```shell
|
61
|
+
$ slackdraft -h
|
62
|
+
Usage: slackdraft [options] url
|
58
63
|
|
59
|
-
|
64
|
+
Slack with less Kurt Russell
|
60
65
|
|
61
|
-
|
66
|
+
v0.7.7
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
Options:
|
69
|
+
-h, --help Show command line help
|
70
|
+
--version Show help/version info
|
71
|
+
-c, --channel CHANNEL Channel to send message to
|
72
|
+
-u, --username USER User to send message as
|
73
|
+
-m, --message MESSAGE Message to send
|
74
|
+
-e, --emoji EMOJI Emoji to prefix message with
|
75
|
+
-i, --icon ICON Icon to prefix message with
|
76
|
+
```
|
data/examples/README.md
ADDED
data/lib/slackdraft/base.rb
CHANGED
data/lib/slackdraft/message.rb
CHANGED
@@ -36,24 +36,19 @@ module Slackdraft
|
|
36
36
|
return ':fire:' if @icon_emoji.nil?
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
40
|
-
def
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
# Reference a user
|
45
|
-
def refuser(user)
|
46
|
-
"<@U024BE7LH|#{user}>"
|
39
|
+
# Parse username and channels
|
40
|
+
def parse_usernames_and_channels(text)
|
41
|
+
text.gsub(/(@\w+)/, '<\1>').gsub(/(#\w+)/, '<\1>')
|
47
42
|
end
|
48
43
|
|
49
44
|
# Set the text of the message
|
50
45
|
def text
|
51
46
|
|
52
47
|
if @text.kind_of?(Array)
|
53
|
-
return @text.join("\n")
|
48
|
+
return parse_usernames_and_channels(@text.join("\n"))
|
54
49
|
end
|
55
50
|
|
56
|
-
@text
|
51
|
+
parse_usernames_and_channels(@text)
|
57
52
|
end
|
58
53
|
|
59
54
|
# Generate the payload if stuff was provided
|
data/lib/slackdraft/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackdraft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Mackintosh
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- README.md
|
139
139
|
- Rakefile
|
140
140
|
- bin/slackdraft
|
141
|
+
- examples/README.md
|
141
142
|
- examples/attachment.rb
|
142
143
|
- examples/attachment_long.rb
|
143
144
|
- examples/formatted/alert.rb
|
@@ -148,7 +149,6 @@ files:
|
|
148
149
|
- lib/slackdraft/format/init.rb
|
149
150
|
- lib/slackdraft/message.rb
|
150
151
|
- lib/slackdraft/version.rb
|
151
|
-
- slackdraft-1.0.0.gem
|
152
152
|
- slackdraft.gemspec
|
153
153
|
homepage: http://github.com/mikemackintosh/slackdraft
|
154
154
|
licenses:
|
data/slackdraft-1.0.0.gem
DELETED
Binary file
|