slackit 1.1.5 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.caretaker.yml +8 -0
- data/.rubocop.yml +66 -13
- data/.travis.yml +20 -22
- data/CHANGELOG.md +138 -29
- data/Gemfile +3 -2
- data/README.md +118 -14
- data/Rakefile +2 -2
- data/VERSION.txt +1 -0
- data/bin/console +3 -3
- data/exe/slackit +46 -6
- data/lib/slackit.rb +101 -19
- data/lib/slackit/version.rb +1 -1
- data/slackit.gemspec +27 -24
- data/spec/slackit_spec.rb +0 -4
- data/testing/slackit +138 -0
- metadata +76 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffac7badefe83f4137bae067ecd1b64aff9c0bd0dcab7ed9292f885f875f6847
|
4
|
+
data.tar.gz: 65bc3f113eb2622a8e321ee63b66147364fd4e57d5ec47573fd0f1be3ef4ecd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49cdf3c9cb84a8d3d2eaac5b059fe4a7879ede779a1052b9b755487dcca1f5c7b44a06b7641aeba5acc25a714a6b315ab84395534a7311b314bc5b3f108c6ac6
|
7
|
+
data.tar.gz: e451640c4d2565909f4354834dd19eea3872883bc2fff0bc804bb1fc8ed938c5183325cbc9690153634661e8c9ad79adc6c0d47af15ffdec6a68e719eb1be498
|
data/.caretaker.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,30 +1,83 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
|
4
|
+
Layout/CaseIndentation:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Layout/ClosingHeredocIndentation:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/FirstHashElementIndentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/HashAlignment:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Layout/HeredocIndentation:
|
17
|
+
Enabled: false
|
18
|
+
|
1
19
|
Layout/IndentationWidth:
|
2
|
-
|
20
|
+
Width: 4
|
3
21
|
|
4
|
-
|
5
|
-
|
22
|
+
Layout/LineLength:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
26
|
+
Enabled: false
|
6
27
|
|
7
|
-
|
8
|
-
|
28
|
+
Lint/RescueException:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Metrics/AbcSize:
|
32
|
+
Enabled: false
|
9
33
|
|
10
34
|
Metrics/BlockLength:
|
11
|
-
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Metrics/BlockNesting:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Metrics/ClassLength:
|
41
|
+
Enabled: false
|
12
42
|
|
13
43
|
Metrics/CyclomaticComplexity:
|
14
|
-
|
44
|
+
Enabled: false
|
15
45
|
|
16
46
|
Metrics/MethodLength:
|
17
|
-
|
47
|
+
Enabled: false
|
18
48
|
|
19
49
|
Metrics/PerceivedComplexity:
|
20
|
-
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Naming/FileName:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Style/FrozenStringLiteralComment:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Style/HashSyntax:
|
59
|
+
Enabled: false
|
21
60
|
|
22
|
-
Style/
|
23
|
-
|
61
|
+
Style/PercentLiteralDelimiters:
|
62
|
+
Enabled: false
|
24
63
|
|
25
64
|
Style/RaiseArgs:
|
26
|
-
|
65
|
+
EnforcedStyle: compact
|
66
|
+
|
67
|
+
Style/RedundantBegin:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Style/RedundantConditional:
|
71
|
+
Enabled: false
|
72
|
+
|
73
|
+
Style/RedundantReturn:
|
74
|
+
Enabled: false
|
75
|
+
|
76
|
+
Style/SpecialGlobalVars:
|
77
|
+
Enabled: false
|
27
78
|
|
28
79
|
Style/WordArray:
|
29
|
-
|
80
|
+
EnforcedStyle: brackets
|
30
81
|
|
82
|
+
Style/RedundantPercentQ:
|
83
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,29 +1,24 @@
|
|
1
1
|
matrix:
|
2
2
|
include:
|
3
3
|
- language: ruby
|
4
|
-
name: "Bundler (rvm 2.
|
5
|
-
rvm: 2.
|
4
|
+
name: "Bundler (rvm 2.5)"
|
5
|
+
rvm: 2.5
|
6
6
|
before_install:
|
7
|
-
- gem install bundler
|
7
|
+
- gem install bundler
|
8
8
|
- language: ruby
|
9
|
-
name: "Bundler (rvm 2.
|
10
|
-
rvm: 2.
|
9
|
+
name: "Bundler (rvm 2.6)"
|
10
|
+
rvm: 2.6
|
11
11
|
before_install:
|
12
|
-
- gem install bundler
|
12
|
+
- gem install bundler
|
13
13
|
- language: ruby
|
14
|
-
name: "Bundler (rvm 2.
|
15
|
-
rvm: 2.
|
14
|
+
name: "Bundler (rvm 2.7)"
|
15
|
+
rvm: 2.7
|
16
16
|
before_install:
|
17
|
-
- gem install bundler
|
17
|
+
- gem install bundler
|
18
18
|
- language: ruby
|
19
|
-
name: "
|
20
|
-
rvm: 2.6.1
|
21
|
-
before_install:
|
22
|
-
- gem install bundler -v 2.0.1
|
23
|
-
- language: ruby
|
24
|
-
name: "Rubocop (rvm 2.4.4)"
|
19
|
+
name: "Rubocop (rvm 2.5)"
|
25
20
|
env: SKIP_INTERPRETER=true
|
26
|
-
rvm: 2.
|
21
|
+
rvm: 2.5
|
27
22
|
before_install:
|
28
23
|
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
29
24
|
install:
|
@@ -31,9 +26,9 @@ matrix:
|
|
31
26
|
script:
|
32
27
|
- ./rubocop-travis/scan.sh
|
33
28
|
- language: ruby
|
34
|
-
name: "Rubocop (rvm 2.
|
29
|
+
name: "Rubocop (rvm 2.6)"
|
35
30
|
env: SKIP_INTERPRETER=true
|
36
|
-
rvm: 2.
|
31
|
+
rvm: 2.6
|
37
32
|
before_install:
|
38
33
|
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
39
34
|
install:
|
@@ -41,9 +36,9 @@ matrix:
|
|
41
36
|
script:
|
42
37
|
- ./rubocop-travis/scan.sh
|
43
38
|
- language: ruby
|
44
|
-
name: "Rubocop (rvm 2.
|
39
|
+
name: "Rubocop (rvm 2.7)"
|
45
40
|
env: SKIP_INTERPRETER=true
|
46
|
-
rvm: 2.
|
41
|
+
rvm: 2.7
|
47
42
|
before_install:
|
48
43
|
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
49
44
|
install:
|
@@ -51,8 +46,11 @@ matrix:
|
|
51
46
|
script:
|
52
47
|
- ./rubocop-travis/scan.sh
|
53
48
|
- language: ruby
|
54
|
-
name: "Link Checker (rvm 2.
|
55
|
-
rvm: 2.
|
49
|
+
name: "Link Checker (rvm 2.7)"
|
50
|
+
rvm: 2.7
|
51
|
+
env:
|
52
|
+
- WHITELIST="https://img.shields.io"
|
53
|
+
- EXCLUDE_FILES="CHANGELOG.md"
|
56
54
|
before_install:
|
57
55
|
- mkdir travis
|
58
56
|
- git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
|
data/CHANGELOG.md
CHANGED
@@ -1,52 +1,161 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
* Clean up tweaks based on updaes to rubocop. ([@TGWolf][])
|
6
5
|
|
7
|
-
|
6
|
+
This changelog was automatically generated using [Caretaker](https://github.com/AntiPhotonltd/slackit) by [Wolf Software](https://github.com/WolfSoftware)
|
8
7
|
|
9
|
-
|
8
|
+
### [Unreleased](https://github.com/AntiPhotonltd/slackit/compare/v1.1.10...HEAD)
|
10
9
|
|
11
|
-
|
12
|
-
* Updated the travis job file to use newer versions of ruby. ([@TGWolf][])
|
10
|
+
- Pre-release push and test [`[head]`](https://github.com/AntiPhotonltd/slackit/commit/) [`[TGWolf]`](https://github.com/TGWolf)
|
13
11
|
|
14
|
-
|
12
|
+
- Fix rake and bundle errors [`[4eb94e5]`](https://github.com/AntiPhotonltd/slackit/commit/4eb94e573cae25be2b616f25b6987b510b7f6395) [`[TGWolf]`](https://github.com/TGWolf)
|
15
13
|
|
16
|
-
|
14
|
+
- Added better validation of slack webhook urls including a cli option to validate a hook, also replace httpary with net/http for more control [`[150b522]`](https://github.com/AntiPhotonltd/slackit/commit/150b522104e285c7cb59b1366fa132c06ec68518) [`[TGWolf]`](https://github.com/TGWolf)
|
17
15
|
|
18
|
-
|
16
|
+
### [v1.1.9](https://github.com/AntiPhotonltd/slackit/compare/v1.1.8...v1.1.9)
|
19
17
|
|
20
|
-
|
18
|
+
> Released on July, 31st 2020
|
21
19
|
|
22
|
-
|
20
|
+
- Bump version ready for release [`[1f236b2]`](https://github.com/AntiPhotonltd/slackit/commit/1f236b290312173c2b25a9f1f08e65f181b68648) [`[TGWolf]`](https://github.com/TGWolf)
|
23
21
|
|
24
|
-
|
22
|
+
- Update readme to new verrsion [`[a9263c0]`](https://github.com/AntiPhotonltd/slackit/commit/a9263c04d5405ee46116c0ee4a5a1dbd46e25102) [`[TGWolf]`](https://github.com/TGWolf)
|
25
23
|
|
26
|
-
|
24
|
+
- Update the version of json due to github security alert [`[fa0e80a]`](https://github.com/AntiPhotonltd/slackit/commit/fa0e80a2a5cf21b2e25e534ab0dc67e3805abe0a) [`[TGWolf]`](https://github.com/TGWolf)
|
27
25
|
|
28
|
-
|
26
|
+
- Fix all of the rubocop errors [`[8897f54]`](https://github.com/AntiPhotonltd/slackit/commit/8897f54ec15160461898b206581522bf9d6c77aa) [`[TGWolf]`](https://github.com/TGWolf)
|
29
27
|
|
30
|
-
|
28
|
+
- Add attachments and blocks [`[3a84400]`](https://github.com/AntiPhotonltd/slackit/commit/3a844009d445b3684032fb5546baa95ebf219fd9) [`[TGWolf]`](https://github.com/TGWolf)
|
31
29
|
|
32
|
-
|
30
|
+
### [v1.1.8](https://github.com/AntiPhotonltd/slackit/compare/v1.1.7...v1.1.8)
|
33
31
|
|
34
|
-
|
32
|
+
> Released on March, 9th 2020
|
35
33
|
|
36
|
-
|
37
|
-
* Added additional testing to ensure a new class instance is created. ([@TGWolf][])
|
38
|
-
* Specifying no channel will now send the message to '#general'. ([@TGWolf][])
|
39
|
-
* Added better error handling to the CLI tool. ([@TGWolf][])
|
34
|
+
- Fix some new rubocop warnings/errors [`[cc6365d]`](https://github.com/AntiPhotonltd/slackit/commit/cc6365dc5464f9791219499025a0cce110ab2114) [`[TGWolf]`](https://github.com/TGWolf)
|
40
35
|
|
41
|
-
|
36
|
+
- Fix a typo in link checking job [`[e8ba2a6]`](https://github.com/AntiPhotonltd/slackit/commit/e8ba2a61b6b44adabdbf03d2160a8693f5f41b0a) [`[TGWolf]`](https://github.com/TGWolf)
|
42
37
|
|
43
|
-
|
38
|
+
### [v1.1.7](https://github.com/AntiPhotonltd/slackit/compare/v1.1.6...v1.1.7)
|
44
39
|
|
45
|
-
|
40
|
+
> Released on March, 9th 2020
|
46
41
|
|
47
|
-
|
42
|
+
- spec.required_ruby_version [`[519c7cb]`](https://github.com/AntiPhotonltd/slackit/commit/519c7cb481c538a46782e16fd17a83fb41a6e467) [`[TGWolf]`](https://github.com/TGWolf)
|
48
43
|
|
49
|
-
|
44
|
+
- Fix gemfile ruby version [`[fb0d2dc]`](https://github.com/AntiPhotonltd/slackit/commit/fb0d2dc6618b9fcf04c8730b827ad7e0fbc0001c) [`[TGWolf]`](https://github.com/TGWolf)
|
45
|
+
|
46
|
+
### [v1.1.6](https://github.com/AntiPhotonltd/slackit/compare/v1.1.5...v1.1.6)
|
47
|
+
|
48
|
+
> Released on March, 9th 2020
|
49
|
+
|
50
|
+
- Add a minimum ruby version to the Gemfile [`[f5c22ac]`](https://github.com/AntiPhotonltd/slackit/commit/f5c22ac495d51cadc496aea27009a83b224e0afb) [`[TGWolf]`](https://github.com/TGWolf)
|
51
|
+
|
52
|
+
- Fix security issues with Rake and remove support for Ruby 2.4 [`[d74c038]`](https://github.com/AntiPhotonltd/slackit/commit/d74c038476856ce3cd244067de74c4db251b115b) [`[TGWolf]`](https://github.com/TGWolf)
|
53
|
+
|
54
|
+
- Fix issue with version file [`[e31c0d4]`](https://github.com/AntiPhotonltd/slackit/commit/e31c0d4cf81339e239f20e3b4ecb33f7fb3b341d) [`[TGWolf]`](https://github.com/TGWolf)
|
55
|
+
|
56
|
+
- Fix a secirity issue in rake and update for new version of rubocop [`[af5596b]`](https://github.com/AntiPhotonltd/slackit/commit/af5596b9b33bc2942931045fdb41fa23d6ccac24) [`[TGWolf]`](https://github.com/TGWolf)
|
57
|
+
|
58
|
+
- Enable caretaker [`[e656e32]`](https://github.com/AntiPhotonltd/slackit/commit/e656e329e326c9e781fce3b4b5851e0b2c8c4298) [`[TGWolf]`](https://github.com/TGWolf)
|
59
|
+
|
60
|
+
- Fix for a security issue in rake [`[4228845]`](https://github.com/AntiPhotonltd/slackit/commit/4228845ae947f4d1dbdd265701107800a20095d1) [`[TGWolf]`](https://github.com/TGWolf)
|
61
|
+
|
62
|
+
- badges [`[773aa6f]`](https://github.com/AntiPhotonltd/slackit/commit/773aa6ffec0e15a95ed50971860f268ae67939bf) [`[TGWolf]`](https://github.com/TGWolf)
|
63
|
+
|
64
|
+
- badges [`[d2c017b]`](https://github.com/AntiPhotonltd/slackit/commit/d2c017b7b1548c2544b24a8fc5d4d12f6d54c915) [`[TGWolf]`](https://github.com/TGWolf)
|
65
|
+
|
66
|
+
### [v1.1.5](https://github.com/AntiPhotonltd/slackit/compare/v1.1.4...v1.1.5)
|
67
|
+
|
68
|
+
> Released on September, 30th 2019
|
69
|
+
|
70
|
+
- Changelog 1.1.6 [`[f722018]`](https://github.com/AntiPhotonltd/slackit/commit/f7220188db3e51cb9f46e60c9b36754169c77506) [`[TGWolf]`](https://github.com/TGWolf)
|
71
|
+
|
72
|
+
- Typo :( [`[7a22454]`](https://github.com/AntiPhotonltd/slackit/commit/7a224545e9ef0a6c8d9deb6a1522ca3fcbaf44e2) [`[TGWolf]`](https://github.com/TGWolf)
|
73
|
+
|
74
|
+
- Remove the channel as a requirement as slack deals with defaults better than we do [`[d25d738]`](https://github.com/AntiPhotonltd/slackit/commit/d25d7389cd0f771dc8f12fc4d423547cc6a7430d) [`[TGWolf]`](https://github.com/TGWolf)
|
75
|
+
|
76
|
+
- typos [`[5cd43c8]`](https://github.com/AntiPhotonltd/slackit/commit/5cd43c86649e93fd8a97ec6a598a5295f4812267) [`[TGWolf]`](https://github.com/TGWolf)
|
77
|
+
|
78
|
+
### [v1.1.4](https://github.com/AntiPhotonltd/slackit/compare/v1.1.3...v1.1.4)
|
79
|
+
|
80
|
+
> Released on June, 28th 2019
|
81
|
+
|
82
|
+
- changelog 1.1.5 [`[7b10700]`](https://github.com/AntiPhotonltd/slackit/commit/7b1070005110d2ca42c898548cfb5a0648865908) [`[TGWolf]`](https://github.com/TGWolf)
|
83
|
+
|
84
|
+
- Miss-fixed [`[6263ae3]`](https://github.com/AntiPhotonltd/slackit/commit/6263ae33e597821d79de4435b2bb5e9e125e3761) [`[TGWolf]`](https://github.com/TGWolf)
|
85
|
+
|
86
|
+
- Changed enforced by newer version of rubocop [`[5b9ed30]`](https://github.com/AntiPhotonltd/slackit/commit/5b9ed30dbbfdb27b09898dd5afcc5c384ea37da2) [`[TGWolf]`](https://github.com/TGWolf)
|
87
|
+
|
88
|
+
- sudo: required isnt [`[a502415]`](https://github.com/AntiPhotonltd/slackit/commit/a502415815d8f679127d987396c5d953931d38fb) [`[TGWolf]`](https://github.com/TGWolf)
|
89
|
+
|
90
|
+
- travis cleanup [`[6278daa]`](https://github.com/AntiPhotonltd/slackit/commit/6278daafa0b58d54aa22c0c1d62d3c72ccf25dd8) [`[TGWolf]`](https://github.com/TGWolf)
|
91
|
+
|
92
|
+
### [v1.1.3](https://github.com/AntiPhotonltd/slackit/compare/v1.1.2...v1.1.3)
|
93
|
+
|
94
|
+
> Released on March, 13th 2019
|
95
|
+
|
96
|
+
- Changelog 1.1.4 [`[f8643af]`](https://github.com/AntiPhotonltd/slackit/commit/f8643af20a7ac2c2eb765bb904b866166fcaf5f2) [`[TGWolf]`](https://github.com/TGWolf)
|
97
|
+
|
98
|
+
- typos [`[1250bbb]`](https://github.com/AntiPhotonltd/slackit/commit/1250bbb9399a102a9ef9844620347b12d80304a9) [`[TGWolf]`](https://github.com/TGWolf)
|
99
|
+
|
100
|
+
### [v1.1.2](https://github.com/AntiPhotonltd/slackit/compare/v1.1.1...v1.1.2)
|
101
|
+
|
102
|
+
> Released on February, 6th 2019
|
103
|
+
|
104
|
+
- Changelog 1.1.3 [`[573c873]`](https://github.com/AntiPhotonltd/slackit/commit/573c873d882c9c87f2fce42b3f0d09d1e0b8fb91) [`[TGWolf]`](https://github.com/TGWolf)
|
105
|
+
|
106
|
+
- Add multiline message support [`[#2]`](https://github.com/AntiPhotonltd/slackit/pull/2) [`[TGWolf]`](https://github.com/TGWolf) [`[TGWolf]`](https://github.com/TGWolf)
|
107
|
+
|
108
|
+
### [v1.1.1](https://github.com/AntiPhotonltd/slackit/compare/v1.1.0...v1.1.1)
|
109
|
+
|
110
|
+
> Released on January, 31st 2019
|
111
|
+
|
112
|
+
- Changelog 1.1.2 [`[6c88839]`](https://github.com/AntiPhotonltd/slackit/commit/6c888394aecf633f4d6d6df7604ce7f240453c8d) [`[TGWolf]`](https://github.com/TGWolf)
|
113
|
+
|
114
|
+
- Add ability to pipe message [`[#1]`](https://github.com/AntiPhotonltd/slackit/pull/1) [`[TGWolf]`](https://github.com/TGWolf) [`[TGWolf]`](https://github.com/TGWolf)
|
115
|
+
|
116
|
+
### [v1.1.0](https://github.com/AntiPhotonltd/slackit/compare/v1.0.1...v1.1.0)
|
117
|
+
|
118
|
+
> Released on January, 22nd 2019
|
119
|
+
|
120
|
+
- fix rubocop [`[ce3cf46]`](https://github.com/AntiPhotonltd/slackit/commit/ce3cf4696ff608003736f7c12a37261f88125363) [`[TGWolf]`](https://github.com/TGWolf)
|
121
|
+
|
122
|
+
- final update [`[74bc203]`](https://github.com/AntiPhotonltd/slackit/commit/74bc203a456209c46eea0081e5d5da79b8da56cf) [`[TGWolf]`](https://github.com/TGWolf)
|
123
|
+
|
124
|
+
- Bug fix for older versions of Ruby [`[cb15ee7]`](https://github.com/AntiPhotonltd/slackit/commit/cb15ee710eaa3661ef411edee1e11277df5e705a) [`[TGWolf]`](https://github.com/TGWolf)
|
125
|
+
|
126
|
+
- typo [`[7db1903]`](https://github.com/AntiPhotonltd/slackit/commit/7db1903b8bfed04f22dd61f43b17918fcb2de5c8) [`[TGWolf]`](https://github.com/TGWolf)
|
127
|
+
|
128
|
+
### [v1.0.1](https://github.com/AntiPhotonltd/slackit/compare/v1.0.0...v1.0.1)
|
129
|
+
|
130
|
+
> Released on January, 22nd 2019
|
131
|
+
|
132
|
+
- Update changelog to reflect released date [`[80e18f1]`](https://github.com/AntiPhotonltd/slackit/commit/80e18f1d0fba1f3c3bf0abc464107972fe997cd7) [`[TGWolf]`](https://github.com/TGWolf)
|
133
|
+
|
134
|
+
- Updates [`[2fda41b]`](https://github.com/AntiPhotonltd/slackit/commit/2fda41b060ecd6dfa3d889166baffc4d48c0fb96) [`[TGWolf]`](https://github.com/TGWolf)
|
135
|
+
|
136
|
+
- Rubocop errors [`[af43d40]`](https://github.com/AntiPhotonltd/slackit/commit/af43d40f95530c6901318c984e585cae497ecddf) [`[TGWolf]`](https://github.com/TGWolf)
|
137
|
+
|
138
|
+
- Changelog 1.1.0 [`[29609f5]`](https://github.com/AntiPhotonltd/slackit/commit/29609f5b04330042095d80e0434aa578c72bfaee) [`[TGWolf]`](https://github.com/TGWolf)
|
139
|
+
|
140
|
+
- Added testing section to README [`[4f53027]`](https://github.com/AntiPhotonltd/slackit/commit/4f53027cb09017419509736420067804fd06eedb) [`[TGWolf]`](https://github.com/TGWolf)
|
141
|
+
|
142
|
+
### [v1.0.0](https://github.com/AntiPhotonltd/slackit/releases/v1.0.0)
|
143
|
+
|
144
|
+
> Released on January, 22nd 2019
|
145
|
+
|
146
|
+
- Changelog 1.0.1 [`[5de3eb9]`](https://github.com/AntiPhotonltd/slackit/commit/5de3eb9144b7d880ddf86a4d090176d71d85ab28) [`[TGWolf]`](https://github.com/TGWolf)
|
147
|
+
|
148
|
+
- Tweak README [`[431ad5e]`](https://github.com/AntiPhotonltd/slackit/commit/431ad5e9e7b3c3633e9488bf33e07d7ed4816331) [`[TGWolf]`](https://github.com/TGWolf)
|
149
|
+
|
150
|
+
- Make the cli actually do something useful [`[b21dd45]`](https://github.com/AntiPhotonltd/slackit/commit/b21dd45f0669abc7e9cb48befd8933dfde259e45) [`[TGWolf]`](https://github.com/TGWolf)
|
151
|
+
|
152
|
+
- Badges [`[a5832d4]`](https://github.com/AntiPhotonltd/slackit/commit/a5832d408c40effd71b1c11b704c6997a505e5e2) [`[TGWolf]`](https://github.com/TGWolf)
|
153
|
+
|
154
|
+
- Missing require of httparty [`[e81249d]`](https://github.com/AntiPhotonltd/slackit/commit/e81249dac5c0b2afbad52f6e3e17c28c036880ca) [`[TGWolf]`](https://github.com/TGWolf)
|
155
|
+
|
156
|
+
- Final rubocop fixes [`[e7b1707]`](https://github.com/AntiPhotonltd/slackit/commit/e7b1707a9a5779cac4629a8241c460bb87e947fb) [`[TGWolf]`](https://github.com/TGWolf)
|
157
|
+
|
158
|
+
- Rubucop errors [`[bdc5009]`](https://github.com/AntiPhotonltd/slackit/commit/bdc5009e9645cc08987a079d25a2da80d1633187) [`[TGWolf]`](https://github.com/TGWolf)
|
159
|
+
|
160
|
+
- Initial commit [`[a87dcdc]`](https://github.com/AntiPhotonltd/slackit/commit/a87dcdc732bc852a44ccdbaa42c445f76148b1c5) [`[TGWolf]`](https://github.com/TGWolf)
|
50
161
|
|
51
|
-
[@TGWolf]: https://github.com/TGWolf
|
52
|
-
[@eimlav]: https://github.com/eimlav
|
data/Gemfile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
ruby '>= 2.5.0'
|
2
3
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
5
|
|
5
6
|
# Specify your gem's dependencies in slackit.gemspec
|
6
7
|
gemspec
|
data/README.md
CHANGED
@@ -1,15 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
<h1 align="center">
|
2
|
+
<a href="#"><img src="https://github.com/AntiPhotonltd/branding/blob/master/images/company%20logo/banners/banner-1400-215.png?raw=true" alt="" width="600"></a>
|
3
|
+
<br>
|
4
|
+
Slackit
|
5
|
+
<br>
|
6
|
+
</h1>
|
7
|
+
|
8
|
+
<h4 align="center">Slackit is a very simply Ruby Gem for posting to a slack incoming webhook.</h4>
|
9
|
+
|
10
|
+
<p align="center">
|
11
|
+
<a href="https://travis-ci.org/AntiPhotonltd/slackit">
|
12
|
+
<img src="https://img.shields.io/travis/AntiPhotonltd/slackit/master?style=for-the-badge&logo=travis"
|
13
|
+
alt="Build Status">
|
14
|
+
</a>
|
15
|
+
<a href="https://github.com/AntiPhotonltd/slackit/releases/latest">
|
16
|
+
<img src="https://img.shields.io/github/release/AntiPhotonltd/slackit?color=blueviolet&style=for-the-badge&logo=github&label=Version"
|
17
|
+
alt="Release">
|
18
|
+
</a>
|
19
|
+
<a href="https://github.com/AntiPhotonltd/slackit/releases/latest">
|
20
|
+
<img src="https://img.shields.io/github/release-date/AntiPhotonltd/slackit?color=blueviolet&logo=github&style=for-the-badge"
|
21
|
+
alt="Latest Release">
|
22
|
+
</a>
|
23
|
+
<br/>
|
24
|
+
<a href="https://github.com/AntiPhotonltd/slackit/commits">
|
25
|
+
<img src="https://img.shields.io/github/commits-since/AntiPhotonltd/slackit/latest?color=blueviolet&style=for-the-badge&logo=github"
|
26
|
+
alt="Github commits (since latest release)">
|
27
|
+
</a>
|
28
|
+
<a href="https://github.com/AntiPhotonltd/slackit/commits/master">
|
29
|
+
<img src="https://img.shields.io/github/last-commit/AntiPhotonltd/slackit?color=blueviolet&style=for-the-badge&logo=github"
|
30
|
+
alt="Last Commit">
|
31
|
+
</a>
|
32
|
+
<br />
|
33
|
+
<a href="LICENSE.md">
|
34
|
+
<img src="https://img.shields.io/badge/license-MIT-blueviolet?style=for-the-badge"
|
35
|
+
alt="Software License">
|
36
|
+
</a>
|
37
|
+
<a href="https://github.com/AntiPhotonltd/branding/issues">
|
38
|
+
<img src="https://img.shields.io/github/issues/AntiPhotonltd/branding?logo=github&color=blueviolet&style=for-the-badge"
|
39
|
+
alt="Open an Issue">
|
40
|
+
</a>
|
41
|
+
<a href="https://github.com/AntiPhotonltd/branding/issues?q=is%3Aissue+is%3Aclosed)">
|
42
|
+
<img src="https://img.shields.io/github/issues-closed/AntiPhotonltd/branding?logo=github&color=blueviolet&style=for-the-badge"
|
43
|
+
alt="Open an Issue">
|
44
|
+
</a>
|
45
|
+
<a href="https://github.com/AntiPhotonltd">
|
46
|
+
<img src="https://img.shields.io/badge/Created%20By-AntiPhoton-blueviolet?style=for-the-badge" alt="AntiPhoton Limited">
|
47
|
+
</a>
|
48
|
+
</p>
|
49
|
+
<hr>
|
50
|
+
|
51
|
+
<h1>Slackit <img align="right" src="https://img.shields.io/badge/made%20with-ruby-blueviolet?logo=gnu-bash&logoColor=white&style=for-the-badge" /></h1>
|
8
52
|
|
9
|
-
# Slackit
|
10
53
|
|
11
54
|
Slackit is a very simply Ruby Gem for posting to a slack incoming webhook.
|
12
55
|
|
56
|
+
It is now possible to send attachments and blocks however slackit doesn't take responsibility for creating those only for sending them. For more information on how to use those please refer to the Slack API documentation.
|
57
|
+
|
58
|
+
* [Attachments](https://api.slack.com/reference/messaging/attachments)
|
59
|
+
* [Blocks](https://api.slack.com/block-kit/building)
|
60
|
+
|
13
61
|
## Installation
|
14
62
|
|
15
63
|
Add this line to your application's Gemfile:
|
@@ -32,16 +80,18 @@ Or install it yourself as:
|
|
32
80
|
require "slackit"
|
33
81
|
```
|
34
82
|
|
35
|
-
Initialize client
|
83
|
+
### Initialize client
|
84
|
+
|
85
|
+
#### Initialize with minimal options
|
36
86
|
|
37
87
|
```ruby
|
38
88
|
client = Slackit.new(webhook_url: "slack webhook url")
|
39
89
|
```
|
40
90
|
|
41
|
-
Initialize with options
|
91
|
+
#### Initialize with all options
|
42
92
|
|
43
93
|
```ruby
|
44
|
-
client =
|
94
|
+
client = Slackit.new(
|
45
95
|
webhook_url: "slack webhook url",
|
46
96
|
channel: "#development",
|
47
97
|
username: "mybot",
|
@@ -49,30 +99,84 @@ client = SlackNotify::Client.new(
|
|
49
99
|
)
|
50
100
|
```
|
51
101
|
|
52
|
-
Initialize via shorthand method
|
102
|
+
#### Initialize via shorthand method
|
53
103
|
|
54
104
|
```Ruby
|
55
105
|
client = Slackit.new(options)
|
56
106
|
```
|
57
107
|
|
108
|
+
#### Validating the webhook url
|
109
|
+
|
110
|
+
Firstly slackit will check to ensure that the webhook url starts with `https://hooks.slack.com/services`, this is the slack standard for all invalid webhook urls.
|
111
|
+
|
112
|
+
Secondly slackit will attempt to validate the webhook url, by making a HTTP `GET` request, if the response to the request is a redirect to `https://api.slack.com` then the url is deemed to be invalid.
|
113
|
+
|
114
|
+
This checking can be bypassed by supplying the `-V` command line option to tell slackit this is a `valid` url, this is useful if you know that the URL is valid and working and removes the additional overhead of repeated testing for each message.
|
115
|
+
|
116
|
+
If you want to manually validate a url you can do this using the command line option -v
|
117
|
+
|
118
|
+
```
|
119
|
+
slackit -v -w <slack webhook url>
|
120
|
+
```
|
121
|
+
|
122
|
+
This will run the GET test and also send a test message to the `general` channel to ensure that the supplied token is also valid, if this comes back with a success you `should` be safe to use the -V option from then on.
|
123
|
+
|
124
|
+
> Normal error handling during the post of a message will always be carried out.
|
125
|
+
|
126
|
+
|
127
|
+
### Sending Messages
|
128
|
+
|
129
|
+
#### Simple messages
|
130
|
+
|
131
|
+
```Ruby
|
132
|
+
client.send_message("This is a test message")
|
133
|
+
```
|
134
|
+
|
135
|
+
#### Attachments
|
136
|
+
|
137
|
+
```Ruby
|
138
|
+
client.send_attachment(attachment_json)
|
139
|
+
```
|
140
|
+
> NOTE: We will test to make sure the json is valid and catch errors thrown by the API for invalid formatting, missing values etc. General error from the api is `missing_text_or_fallback_or_attachments`
|
141
|
+
|
142
|
+
#### Blocks
|
143
|
+
|
144
|
+
```Ruby
|
145
|
+
client.send_block(block_json)
|
146
|
+
```
|
147
|
+
|
148
|
+
> NOTE: We will test to make sure the json is valid and catch errors thrown by the API for invalid formatting, missing values etc. General error from the api is `invalid_blocks_format`
|
149
|
+
|
58
150
|
### Command Line Usage
|
59
151
|
|
60
152
|
```
|
61
153
|
Usage: slackit
|
62
154
|
-h, --help Display this screen
|
63
155
|
-c, --channel string The channel to send the message to
|
64
|
-
-i, --icon-emoji string The emoji to use
|
156
|
+
-i, --icon-emoji string The emoji to use for the channel icon [default: :wolf:]
|
65
157
|
-m, --message string The message to send
|
66
158
|
-w, --webhook-url string The slack incoming webhook url to use
|
67
159
|
-u, --username string The username to send as [default: slackit]
|
160
|
+
|
161
|
+
Webhook Validation:
|
162
|
+
-v, --validation-test Run a webbook validation test
|
163
|
+
-V, --validated-webhook Flag the webhook as validated (skips constant validation)
|
164
|
+
|
165
|
+
Message type options:
|
166
|
+
-a, --attachment Treat the message as an attachment
|
167
|
+
-b, --block Treat the message as a block
|
68
168
|
```
|
69
169
|
|
70
|
-
|
170
|
+
#### Pipe message
|
71
171
|
|
72
172
|
Alternatively to using the `-m` parameter, you can pipe your message instead:
|
73
173
|
|
74
174
|
$ echo 'Hello world!' | slackit -w ...
|
75
175
|
|
176
|
+
#### Return values
|
177
|
+
|
178
|
+
For all sucessful sending slackit will return a value of 0. For all errors it will return the value of 1.
|
179
|
+
|
76
180
|
## Development
|
77
181
|
|
78
182
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
data/VERSION.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.10
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'slackit'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "slackit"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/exe/slackit
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'slackit'
|
5
|
+
require 'cmessages'
|
5
6
|
|
6
7
|
# -------------------------------------------------------------------------------- #
|
7
8
|
# Send Mssage to Slack #
|
@@ -11,12 +12,22 @@ require 'slackit'
|
|
11
12
|
|
12
13
|
def send_message_to_slack(options)
|
13
14
|
begin
|
14
|
-
s = Slackit.new(
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
s = Slackit.new(options)
|
16
|
+
|
17
|
+
unless options[:validation_test]
|
18
|
+
if options[:attachment]
|
19
|
+
s.send_attachment(options[:message])
|
20
|
+
elsif options[:block]
|
21
|
+
s.send_block(options[:message])
|
22
|
+
else
|
23
|
+
s.send_message(options[:message])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue Exception => e
|
27
|
+
e.to_s.error
|
18
28
|
exit(1)
|
19
29
|
end
|
30
|
+
exit(0)
|
20
31
|
end
|
21
32
|
|
22
33
|
# -------------------------------------------------------------------------------- #
|
@@ -29,7 +40,7 @@ end
|
|
29
40
|
# -------------------------------------------------------------------------------- #
|
30
41
|
|
31
42
|
def process_arguments
|
32
|
-
options = {}
|
43
|
+
options = { :username => 'slackit', :attachment => false, :block => false }
|
33
44
|
# Enforce the presence of
|
34
45
|
mandatory = %I[webhook_url message]
|
35
46
|
|
@@ -59,11 +70,35 @@ def process_arguments
|
|
59
70
|
opts.on('-u', '--username string', 'The username to send as [default: slackit]') do |username|
|
60
71
|
options[:username] = username
|
61
72
|
end
|
73
|
+
|
74
|
+
opts.separator ''
|
75
|
+
opts.separator 'Webhook Validation:'
|
76
|
+
|
77
|
+
opts.on('-v', '--validation-test', 'Run a webbook validation test') do
|
78
|
+
options[:validation_test] = true
|
79
|
+
options[:message] = 'This is a webhook validation test message'
|
80
|
+
options[:channel] = 'general'
|
81
|
+
end
|
82
|
+
|
83
|
+
opts.on('-V', '--validated-webhook', 'Flag the webhook as validated (skips constant validation)') do
|
84
|
+
options[:validated_webhook] = true
|
85
|
+
end
|
86
|
+
|
87
|
+
opts.separator ''
|
88
|
+
opts.separator 'Message type options:'
|
89
|
+
|
90
|
+
opts.on('-a', '--attachment', 'Treat the message as an attachment') do
|
91
|
+
options[:attachment] = true
|
92
|
+
end
|
93
|
+
|
94
|
+
opts.on('-b', '--block', 'Treat the message as a block') do
|
95
|
+
options[:block] = true
|
96
|
+
end
|
62
97
|
end
|
63
98
|
|
64
99
|
begin
|
65
100
|
optparse.parse!
|
66
|
-
options[:message] = ARGF.read
|
101
|
+
options[:message] = ARGF.read unless STDIN.tty? # override message parameter if data is piped in
|
67
102
|
missing = mandatory.select { |param| options[param].nil? }
|
68
103
|
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
69
104
|
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
@@ -72,6 +107,11 @@ def process_arguments
|
|
72
107
|
exit
|
73
108
|
end
|
74
109
|
|
110
|
+
if options[:attachment] && options[:block]
|
111
|
+
puts 'Error: You cannot use -a and -b at the same time! - aborting'
|
112
|
+
exit
|
113
|
+
end
|
114
|
+
|
75
115
|
exit 0 if send_message_to_slack(options)
|
76
116
|
|
77
117
|
exit 1
|
data/lib/slackit.rb
CHANGED
@@ -1,42 +1,124 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'slackit/version'
|
4
|
-
require '
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
require 'json'
|
7
|
+
require 'cmessages'
|
5
8
|
|
6
9
|
#
|
7
10
|
# To follow
|
8
11
|
#
|
9
12
|
class Slackit
|
10
13
|
def initialize(options = {})
|
11
|
-
@webhook_url
|
12
|
-
@username
|
13
|
-
@channel
|
14
|
-
@icon_emoji
|
14
|
+
@webhook_url = options[:webhook_url]
|
15
|
+
@username = options[:username]
|
16
|
+
@channel = options[:channel]
|
17
|
+
@icon_emoji = options[:icon_emoji]
|
18
|
+
|
19
|
+
@validation_test = options[:validation_test]
|
20
|
+
@validated_webhook = options[:validated_webhook]
|
15
21
|
|
16
22
|
raise ArgumentError.new('Webhook URL required') if @webhook_url.nil?
|
23
|
+
|
24
|
+
if @validation_test
|
25
|
+
if valid_webhook(@webhook_url)
|
26
|
+
@channel = 'general'
|
27
|
+
send_message('This is a validation message')
|
28
|
+
"#{@webhook_url} is a valid url".success
|
29
|
+
else
|
30
|
+
"#{@webhook_url} is NOT a valid url".error
|
31
|
+
end
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
raise ArgumentError.new("Invalid webhook URL: #{@webhook_url} - should start with https://hooks.slack.com/services/") unless @webhook_url.start_with?('https://hooks.slack.com/services/')
|
36
|
+
|
37
|
+
return if valid_webhook(@webhook_url)
|
38
|
+
|
39
|
+
raise ArgumentError.new("Invalid webhook URL: #{@webhook_url} - please check your configuration") unless valid_webhook(@webhook_url)
|
17
40
|
end
|
18
41
|
|
19
|
-
|
20
|
-
|
21
|
-
def send(text)
|
22
|
-
# send as json
|
23
|
-
headers = { 'Content-Type' => 'application/json' }
|
42
|
+
def valid_webhook(url)
|
43
|
+
uri = URI.parse(url)
|
24
44
|
|
25
|
-
|
45
|
+
r = Net::HTTP.get_response(uri)
|
46
|
+
|
47
|
+
return false if (r.code == '301') || (r.code == '302')
|
48
|
+
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Raw message
|
54
|
+
#
|
55
|
+
def send_message(text)
|
26
56
|
text = text.gsub('\\n', "\n") # ensure newlines are not escaped
|
27
|
-
body = { 'text' => text, 'icon_emoji' => @icon_emoji, 'username' => @username }
|
28
57
|
|
29
|
-
|
30
|
-
|
58
|
+
payload = { 'text' => text }
|
59
|
+
|
60
|
+
return send_payload(payload)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Add an alias for backwards compatibility
|
65
|
+
#
|
66
|
+
def send(text)
|
67
|
+
return send_message(text)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Legacy attachments
|
72
|
+
#
|
73
|
+
def send_attachment(attachment)
|
74
|
+
payload = { 'attachments' => [ convert_to_json(attachment) ] }
|
75
|
+
return send_payload(payload)
|
76
|
+
end
|
31
77
|
|
78
|
+
#
|
79
|
+
# New shiney blocks
|
80
|
+
#
|
81
|
+
def send_block(block)
|
82
|
+
payload = convert_to_json(block)
|
83
|
+
return send_payload(payload)
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Convery the string to json
|
88
|
+
#
|
89
|
+
def convert_to_json(json_string)
|
32
90
|
begin
|
33
|
-
|
91
|
+
return JSON.parse(json_string)
|
92
|
+
rescue JSON::ParserError
|
93
|
+
raise ArgumentError.new('Invalid json')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def send_payload(payload)
|
98
|
+
headers = { 'Content-Type' => 'application/json' }
|
99
|
+
|
100
|
+
# Add the additional payload items
|
101
|
+
payload['icon_emoji'] ||= @icon_emoji
|
102
|
+
payload['username'] ||= @username
|
103
|
+
payload['channel'] ||= @channel
|
104
|
+
|
105
|
+
begin
|
106
|
+
uri = URI.parse(@webhook_url)
|
107
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
108
|
+
http.use_ssl = true
|
109
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
110
|
+
request.body = payload.to_json
|
111
|
+
response = http.request(request)
|
112
|
+
|
113
|
+
return true if response.code == '200'
|
114
|
+
|
115
|
+
raise "Invalid webhook URL: #{@webhook_url} - please check your configuration" if response.code == '301' || response.code == '302'
|
34
116
|
|
35
|
-
|
117
|
+
raise "Unknown error for webhook URL: #{@webhook_url}" if response.body.empty?
|
36
118
|
|
37
|
-
|
38
|
-
rescue
|
39
|
-
|
119
|
+
raise response.body
|
120
|
+
rescue Exception => e
|
121
|
+
raise e
|
40
122
|
end
|
41
123
|
end
|
42
124
|
end
|
data/lib/slackit/version.rb
CHANGED
data/slackit.gemspec
CHANGED
@@ -1,33 +1,36 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require 'slackit/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
spec.name = 'slackit'
|
7
|
+
spec.version = Slackit::VERSION
|
8
|
+
spec.authors = ['Tim Gurney aka Wolf']
|
9
|
+
spec.email = ['wolf@tgwolf.com']
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
spec.summary = 'A simple gem for posting to a slack incoming webhook.'
|
12
|
+
spec.description = 'A simple gem for posting raw messages to a slack incoming webhook.'
|
13
|
+
spec.homepage = 'https://github.com/AntiPhotonltd/slackit'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
#end
|
23
|
-
spec.bindir = "exe"
|
24
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = ["lib"]
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
26
21
|
|
27
|
-
|
28
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
-
spec.add_development_dependency "httparty", "~> 0.16.2"
|
22
|
+
spec.required_ruby_version = '>= 2.5'
|
31
23
|
|
32
|
-
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
25
|
+
spec.add_development_dependency 'cmessages', '~> 1.0.0'
|
26
|
+
spec.add_development_dependency 'json', '~> 2.3.0'
|
27
|
+
# spec.add_development_dependency 'net-http', '~> 0.1.0'
|
28
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'uri', '~> 0.10.0'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'cmessages', '~> 1.0.0'
|
33
|
+
# spec.add_runtime_dependency 'net-http', '~> 0.1.0'
|
34
|
+
spec.add_runtime_dependency 'json', '~> 2.3.0'
|
35
|
+
spec.add_runtime_dependency 'uri', '~> 0.10.0'
|
33
36
|
end
|
data/spec/slackit_spec.rb
CHANGED
data/testing/slackit
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'slackit'
|
7
|
+
require 'cmessages'
|
8
|
+
|
9
|
+
# -------------------------------------------------------------------------------- #
|
10
|
+
# Send Mssage to Slack #
|
11
|
+
# -------------------------------------------------------------------------------- #
|
12
|
+
# This function will take the input arguments and then send the message. #
|
13
|
+
# -------------------------------------------------------------------------------- #
|
14
|
+
|
15
|
+
def send_message_to_slack(options)
|
16
|
+
begin
|
17
|
+
s = Slackit.new(options)
|
18
|
+
|
19
|
+
unless options[:validation_test]
|
20
|
+
if options[:attachment]
|
21
|
+
s.send_attachment(options[:message])
|
22
|
+
elsif options[:block]
|
23
|
+
s.send_block(options[:message])
|
24
|
+
else
|
25
|
+
s.send_message(options[:message])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
rescue Exception => e
|
29
|
+
e.to_s.error
|
30
|
+
exit(1)
|
31
|
+
end
|
32
|
+
exit(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
# -------------------------------------------------------------------------------- #
|
36
|
+
# Process Arguments #
|
37
|
+
# -------------------------------------------------------------------------------- #
|
38
|
+
# This function will process the input from the command line and work out what it #
|
39
|
+
# is that the user wants to see. #
|
40
|
+
# #
|
41
|
+
# This is the main processing function where all the processing logic is handled. #
|
42
|
+
# -------------------------------------------------------------------------------- #
|
43
|
+
|
44
|
+
def process_arguments
|
45
|
+
options = { :username => 'slackit', :attachment => false, :block => false }
|
46
|
+
# Enforce the presence of
|
47
|
+
mandatory = %I[webhook_url message]
|
48
|
+
|
49
|
+
optparse = OptionParser.new do |opts|
|
50
|
+
opts.banner = "Usage: #{$PROGRAM_NAME}"
|
51
|
+
|
52
|
+
opts.on('-h', '--help', 'Display this screen') do
|
53
|
+
puts opts
|
54
|
+
exit(1)
|
55
|
+
end
|
56
|
+
opts.on('-c', '--channel string', 'The channel to send the message to') do |channel|
|
57
|
+
options[:channel] = channel
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on('-i', '--icon-emoji string', 'The emoji to use for the channel icon [default: :wolf:]') do |icon_emoji|
|
61
|
+
options[:icon_emoji] = icon_emoji
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on('-m', '--message string', 'The message to send') do |message|
|
65
|
+
options[:message] = message
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on('-w', '--webhook-url string', 'The slack incoming webhook url to use') do |webhook_url|
|
69
|
+
options[:webhook_url] = webhook_url
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on('-u', '--username string', 'The username to send as [default: slackit]') do |username|
|
73
|
+
options[:username] = username
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.separator ''
|
77
|
+
opts.separator 'Webhook Validation:'
|
78
|
+
|
79
|
+
opts.on('-v', '--validation-test', 'Run a webbook validation test') do
|
80
|
+
options[:validation_test] = true
|
81
|
+
options[:message] = 'This is a webhook validation test message'
|
82
|
+
options[:channel] = 'general'
|
83
|
+
end
|
84
|
+
|
85
|
+
opts.on('-V', '--validated-webhook', 'Flag the webhook as validated (skips constant validation)') do
|
86
|
+
options[:validated_webhook] = true
|
87
|
+
end
|
88
|
+
|
89
|
+
opts.separator ''
|
90
|
+
opts.separator 'Message type options:'
|
91
|
+
|
92
|
+
opts.on('-a', '--attachment', 'Treat the message as an attachment') do
|
93
|
+
options[:attachment] = true
|
94
|
+
end
|
95
|
+
|
96
|
+
opts.on('-b', '--block', 'Treat the message as a block') do
|
97
|
+
options[:block] = true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
begin
|
102
|
+
optparse.parse!
|
103
|
+
options[:message] = ARGF.read unless STDIN.tty? # override message parameter if data is piped in
|
104
|
+
missing = mandatory.select { |param| options[param].nil? }
|
105
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
106
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
107
|
+
puts e.to_s
|
108
|
+
puts optparse
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
if options[:attachment] && options[:block]
|
113
|
+
puts 'Error: You cannot use -a and -b at the same time! - aborting'
|
114
|
+
exit
|
115
|
+
end
|
116
|
+
|
117
|
+
exit 0 if send_message_to_slack(options)
|
118
|
+
|
119
|
+
exit 1
|
120
|
+
end
|
121
|
+
|
122
|
+
# -------------------------------------------------------------------------------- #
|
123
|
+
# Main() #
|
124
|
+
# -------------------------------------------------------------------------------- #
|
125
|
+
# The main function where all of the heavy lifting and script config is done. #
|
126
|
+
# -------------------------------------------------------------------------------- #
|
127
|
+
|
128
|
+
def main
|
129
|
+
process_arguments
|
130
|
+
end
|
131
|
+
|
132
|
+
main
|
133
|
+
|
134
|
+
# -------------------------------------------------------------------------------- #
|
135
|
+
# End of Script #
|
136
|
+
# -------------------------------------------------------------------------------- #
|
137
|
+
# This is the end - nothing more to see here. #
|
138
|
+
# -------------------------------------------------------------------------------- #
|
metadata
CHANGED
@@ -1,49 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Gurney aka Wolf
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
18
25
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cmessages
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
21
32
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
33
|
+
version: 1.0.0
|
23
34
|
type: :development
|
24
35
|
prerelease: false
|
25
36
|
version_requirements: !ruby/object:Gem::Requirement
|
26
37
|
requirements:
|
27
|
-
- - "
|
38
|
+
- - "~>"
|
28
39
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
40
|
+
version: 1.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
31
46
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
47
|
+
version: 2.3.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.3.0
|
33
55
|
- !ruby/object:Gem::Dependency
|
34
56
|
name: rake
|
35
57
|
requirement: !ruby/object:Gem::Requirement
|
36
58
|
requirements:
|
37
59
|
- - "~>"
|
38
60
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
61
|
+
version: 12.3.3
|
40
62
|
type: :development
|
41
63
|
prerelease: false
|
42
64
|
version_requirements: !ruby/object:Gem::Requirement
|
43
65
|
requirements:
|
44
66
|
- - "~>"
|
45
67
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
68
|
+
version: 12.3.3
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: rspec
|
49
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,33 +81,61 @@ dependencies:
|
|
59
81
|
- !ruby/object:Gem::Version
|
60
82
|
version: '3.0'
|
61
83
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
84
|
+
name: uri
|
63
85
|
requirement: !ruby/object:Gem::Requirement
|
64
86
|
requirements:
|
65
87
|
- - "~>"
|
66
88
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.
|
89
|
+
version: 0.10.0
|
68
90
|
type: :development
|
69
91
|
prerelease: false
|
70
92
|
version_requirements: !ruby/object:Gem::Requirement
|
71
93
|
requirements:
|
72
94
|
- - "~>"
|
73
95
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
96
|
+
version: 0.10.0
|
75
97
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
98
|
+
name: cmessages
|
77
99
|
requirement: !ruby/object:Gem::Requirement
|
78
100
|
requirements:
|
79
101
|
- - "~>"
|
80
102
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
103
|
+
version: 1.0.0
|
82
104
|
type: :runtime
|
83
105
|
prerelease: false
|
84
106
|
version_requirements: !ruby/object:Gem::Requirement
|
85
107
|
requirements:
|
86
108
|
- - "~>"
|
87
109
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0.
|
110
|
+
version: 1.0.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: json
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.3.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.3.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: uri
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.10.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.10.0
|
89
139
|
description: A simple gem for posting raw messages to a slack incoming webhook.
|
90
140
|
email:
|
91
141
|
- wolf@tgwolf.com
|
@@ -94,6 +144,7 @@ executables:
|
|
94
144
|
extensions: []
|
95
145
|
extra_rdoc_files: []
|
96
146
|
files:
|
147
|
+
- ".caretaker.yml"
|
97
148
|
- ".gitignore"
|
98
149
|
- ".rspec"
|
99
150
|
- ".rubocop.yml"
|
@@ -105,6 +156,7 @@ files:
|
|
105
156
|
- LICENSE.txt
|
106
157
|
- README.md
|
107
158
|
- Rakefile
|
159
|
+
- VERSION.txt
|
108
160
|
- bin/console
|
109
161
|
- bin/setup
|
110
162
|
- exe/slackit
|
@@ -113,11 +165,12 @@ files:
|
|
113
165
|
- slackit.gemspec
|
114
166
|
- spec/slackit_spec.rb
|
115
167
|
- spec/spec_helper.rb
|
168
|
+
- testing/slackit
|
116
169
|
homepage: https://github.com/AntiPhotonltd/slackit
|
117
170
|
licenses:
|
118
171
|
- MIT
|
119
172
|
metadata: {}
|
120
|
-
post_install_message:
|
173
|
+
post_install_message:
|
121
174
|
rdoc_options: []
|
122
175
|
require_paths:
|
123
176
|
- lib
|
@@ -125,15 +178,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
178
|
requirements:
|
126
179
|
- - ">="
|
127
180
|
- !ruby/object:Gem::Version
|
128
|
-
version: '
|
181
|
+
version: '2.5'
|
129
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
183
|
requirements:
|
131
184
|
- - ">="
|
132
185
|
- !ruby/object:Gem::Version
|
133
186
|
version: '0'
|
134
187
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
136
|
-
signing_key:
|
188
|
+
rubygems_version: 3.1.4
|
189
|
+
signing_key:
|
137
190
|
specification_version: 4
|
138
191
|
summary: A simple gem for posting to a slack incoming webhook.
|
139
192
|
test_files: []
|