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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b66329da3ad9134da94bf8553fe434c9a1bb7627
4
- data.tar.gz: 2c5cd66d67e33b167f454e8d9245969c13447e29
3
+ metadata.gz: 3a3d20d902033420d44050a957cb89bc1c76a038
4
+ data.tar.gz: 57f127c0596a44ac40b099bc9f4dc7d9ca51d9f7
5
5
  SHA512:
6
- metadata.gz: 9c06d2e9d5a4397b8d3d69ebc0f08f01a5379b1e17a08757c8910118ab2bd02fb1baddfff55b80e5940bdc90d62d65e8d409ff9aa483c43c6353414da1a3a523
7
- data.tar.gz: c9203c65521f94a7d8401e065e548e6547188fe24c07d905de50ed9825ea65eba51772a9598ea6583105cf296b8f82651212b206679b6028037708d4469ee895
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
- gem install slackdraft
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
- require 'slackdraft'
18
- url = "https://slack/webhook/url"
19
- slack = Slackdraft::Message.new(url)
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
- # Set the bot username
26
- slack.username = "SlackDraft"
23
+ # Url of the icon or emoji
24
+ # slack.icon_url = "https://..."
25
+ slack.icon_emoji = ":fire:"
27
26
 
28
- # Set the channel
29
- slack.channel = "#general"
27
+ # Set the bot username
28
+ slack.username = "SlackDraft"
30
29
 
31
- # Set text
32
- slack.text = "Your message here! _*And can have* formatting_"
30
+ # Set the channel
31
+ slack.channel = "#general"
33
32
 
34
- # Or you can pass text in as an array
35
- # slack.text = ["Your message here!", ">_*And can have* formatting_"]
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
- # Send the message
38
- slack.send!
39
- #-> true/false
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
- slackdraft -u mike \
48
- -c "#slackdraft" \
49
- -m "This is our *formammted message*" \
50
- https://hooks.slack.com/services/xxxxxxx
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
- $ slackdraft -h
57
- Usage: slackdraft [options] url
60
+ ```shell
61
+ $ slackdraft -h
62
+ Usage: slackdraft [options] url
58
63
 
59
- Slack with less Kurt Russell
64
+ Slack with less Kurt Russell
60
65
 
61
- v0.7.7
66
+ v0.7.7
62
67
 
63
- Options:
64
- -h, --help Show command line help
65
- --version Show help/version info
66
- -c, --channel CHANNEL Channel to send message to
67
- -u, --username USER User to send message as
68
- -m, --message MESSAGE Message to send
69
- -e, --emoji EMOJI Emoji to prefix message with
70
- -i, --icon ICON Icon to prefix message with
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
+ ```
@@ -0,0 +1,3 @@
1
+ I will add some examples here with some screenshots, because I am a nice guy.
2
+
3
+ Standby.
@@ -20,7 +20,7 @@ module Slackdraft
20
20
 
21
21
  # Send the message!
22
22
  def send!
23
-
23
+
24
24
  # Send the request
25
25
  request = HTTParty.post(self.target, :body => {
26
26
  :payload => generate_payload.to_json
@@ -36,24 +36,19 @@ module Slackdraft
36
36
  return ':fire:' if @icon_emoji.nil?
37
37
  end
38
38
 
39
- # Reference a channel
40
- def refchannel(channel)
41
- "<#C024BE7LR|#{channel}>"
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
@@ -1,3 +1,3 @@
1
1
  module Slackdraft
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
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.1
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