slack_messaging 1.0.1 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +95 -0
- data/Guardfile +5 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +48 -20
- data/Rakefile +0 -1
- data/bin/slack-messaging +6 -1
- data/lib/slack_messaging.rb +4 -8
- data/lib/slack_messaging/config.rb +8 -56
- data/lib/slack_messaging/notify_slack.rb +8 -7
- data/lib/slack_messaging/random_message.rb +19 -19
- data/lib/slack_messaging/slack.rb +25 -0
- data/lib/slack_messaging/version.rb +1 -1
- data/spec/slack_messaging/config_spec.rb +4 -23
- data/spec/slack_messaging/notify_slack_spec.rb +3 -3
- data/spec/slack_messaging/random_message_spec.rb +3 -2
- data/spec/spec_helper.rb +3 -0
- metadata +49 -44
- data/.gitignore +0 -18
- data/.octopolo.yml +0 -4
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.soyuz.yml +0 -12
- data/.travis.yml +0 -10
- data/CHANGELOG.markdown +0 -5
- data/lib/slack_messaging/commands/slack.rb +0 -7
- data/lib/slack_messaging/scripts/slack.rb +0 -29
- data/slack_messaging.gemspec +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 21d4c79502e68eea2cf007a81f3a1e49a1f2b3fc670a68515f91d2671470c7b6
|
4
|
+
data.tar.gz: 013f88ec707d9bea10b2186962bd4b82e0106cb8754185f0fedb9448b8e3dfb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4cc5277991115cb449882eb7f069b6eb135c2c0d944692fbab654c2938c84441ab6bd3b0c9c47f748402d5b8390d34fe2a65ee433b165b3c10df1f230b4d672
|
7
|
+
data.tar.gz: bb984c22a6a030630daec5848b91fcc73dd5a08090a2711878895741f8cc3317dbc37182a918b00e33b0790a69024f4a251cbfd13aabf214a7ae39f1d24a9c70
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
slack_messaging (1.3.1)
|
5
|
+
activesupport (~> 6.0)
|
6
|
+
gli (~> 2.10)
|
7
|
+
hashie (~> 4.1)
|
8
|
+
highline (~> 2.0)
|
9
|
+
rack (~> 2.2)
|
10
|
+
slack-notifier (~> 1.5.1)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (6.0.3.3)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 0.7, < 2)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
coderay (1.1.3)
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
ffi (1.13.1)
|
25
|
+
formatador (0.2.5)
|
26
|
+
gli (2.19.2)
|
27
|
+
guard (2.16.2)
|
28
|
+
formatador (>= 0.2.4)
|
29
|
+
listen (>= 2.7, < 4.0)
|
30
|
+
lumberjack (>= 1.0.12, < 2.0)
|
31
|
+
nenv (~> 0.1)
|
32
|
+
notiffany (~> 0.0)
|
33
|
+
pry (>= 0.9.12)
|
34
|
+
shellany (~> 0.0)
|
35
|
+
thor (>= 0.18.1)
|
36
|
+
guard-compat (1.2.1)
|
37
|
+
guard-rspec (4.7.3)
|
38
|
+
guard (~> 2.1)
|
39
|
+
guard-compat (~> 1.1)
|
40
|
+
rspec (>= 2.99.0, < 4.0)
|
41
|
+
hashie (4.1.0)
|
42
|
+
highline (2.0.3)
|
43
|
+
i18n (1.8.5)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
listen (3.2.1)
|
46
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
47
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
48
|
+
lumberjack (1.2.8)
|
49
|
+
method_source (1.0.0)
|
50
|
+
minitest (5.14.2)
|
51
|
+
nenv (0.3.0)
|
52
|
+
notiffany (0.1.3)
|
53
|
+
nenv (~> 0.1)
|
54
|
+
shellany (~> 0.0)
|
55
|
+
pry (0.13.1)
|
56
|
+
coderay (~> 1.1)
|
57
|
+
method_source (~> 1.0)
|
58
|
+
rack (2.2.3)
|
59
|
+
rake (13.0.1)
|
60
|
+
rb-fsevent (0.10.4)
|
61
|
+
rb-inotify (0.10.1)
|
62
|
+
ffi (~> 1.0)
|
63
|
+
rspec (3.9.0)
|
64
|
+
rspec-core (~> 3.9.0)
|
65
|
+
rspec-expectations (~> 3.9.0)
|
66
|
+
rspec-mocks (~> 3.9.0)
|
67
|
+
rspec-core (3.9.3)
|
68
|
+
rspec-support (~> 3.9.3)
|
69
|
+
rspec-expectations (3.9.2)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.9.0)
|
72
|
+
rspec-mocks (3.9.1)
|
73
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
+
rspec-support (~> 3.9.0)
|
75
|
+
rspec-support (3.9.3)
|
76
|
+
shellany (0.0.1)
|
77
|
+
slack-notifier (1.5.1)
|
78
|
+
thor (1.0.1)
|
79
|
+
thread_safe (0.3.6)
|
80
|
+
tzinfo (1.2.7)
|
81
|
+
thread_safe (~> 0.1)
|
82
|
+
zeitwerk (2.4.0)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
ruby
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
bundler (~> 2.1)
|
89
|
+
guard-rspec (~> 4.3)
|
90
|
+
rake (~> 13.0)
|
91
|
+
rspec (~> 3.9)
|
92
|
+
slack_messaging!
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
2.1.4
|
data/Guardfile
ADDED
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,29 +1,44 @@
|
|
1
|
-
# Slack Messaging [![
|
1
|
+
# Slack Messaging [![Maintainability](https://api.codeclimate.com/v1/badges/c74baada70ad96048dc7/maintainability)](https://codeclimate.com/github/emmasax4/slack_messaging/maintainability) ![Develop](https://github.com/emmasax4/slack_messaging/workflows/Develop/badge.svg)
|
2
2
|
|
3
3
|
This is a simple project designed to post messages to a given Slack channel as a bot.
|
4
4
|
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'slack_messaging'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install slack_messaging
|
20
|
+
|
5
21
|
### Usage
|
6
22
|
|
7
|
-
|
23
|
+
This project requires a config file that should look like this:
|
8
24
|
|
9
25
|
```
|
10
|
-
|
11
|
-
|
26
|
+
slack:
|
27
|
+
channel: "#<AWESOME CHANNEL NAME>"
|
28
|
+
username: <AWESOME USER NAME>
|
29
|
+
webhook_url: <WEBHOOK URL>
|
30
|
+
icon_emoji: ":<SOME EMOJI>:"
|
12
31
|
```
|
13
32
|
|
14
|
-
|
33
|
+
The default is for the file to be named `~/.slack_messaging.yml`, but a different path can be passed in like this:
|
15
34
|
|
16
35
|
```
|
17
|
-
slack
|
18
|
-
channel: "#[AWESOME CHANNEL NAME]"
|
19
|
-
username: [AWESOME USER NAME]
|
20
|
-
webhook_url: [WEBHOOK URL]
|
21
|
-
icon_emoji: ":[SOME EMOJI]:"
|
36
|
+
$ slack-messaging --config="/PATH/TO/FILE/config.yml" slack
|
22
37
|
```
|
23
38
|
|
24
39
|
To obtain the webhook url, go to [this link](https://api.slack.com/incoming-webhooks).
|
25
40
|
|
26
|
-
Okay, now the project will
|
41
|
+
Okay, now the project will be ready to rock and roll.
|
27
42
|
|
28
43
|
To print a friendly message to Slack, run:
|
29
44
|
|
@@ -31,7 +46,7 @@ To print a friendly message to Slack, run:
|
|
31
46
|
slack-messaging slack
|
32
47
|
```
|
33
48
|
|
34
|
-
from the main directory. Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote, which are all defined in [`lib/slack_messaging/random_message.rb`](https://github.com/
|
49
|
+
from the main directory. Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote, which are all defined in [`lib/slack_messaging/random_message.rb`](https://github.com/emmasax4/slack_messaging/blob/main/lib/slack_messaging/random_message.rb). Feel free to change the messages or add more to cater what you'd like slack_messaging to say.
|
35
50
|
|
36
51
|
However, what if you wanted to print something specific? Well, you can! Just run:
|
37
52
|
|
@@ -47,18 +62,31 @@ slack-messaging slack "MESSAGE 1" "MESSAGE 2" "MESSAGE 3" ... "MESSAGE N"
|
|
47
62
|
|
48
63
|
The output of slack_messaging will look something like this:
|
49
64
|
|
50
|
-
<img src="https://github.com/
|
65
|
+
<img src="https://github.com/emmasax4/slack_messaging/blob/main/OutputFile.png" width="1000">
|
51
66
|
|
52
67
|
I hope you enjoy printing fun and specialized messages to Slack!
|
53
68
|
|
54
69
|
### Tests
|
55
70
|
|
56
|
-
To run the tests, run `rspec` from the command line.
|
71
|
+
To run the tests, run `bundle exec rspec` from the command line. GitHub Actions will also run the tests upon every commit to make sure they're up to date and that everything is working correctly. Locally, you can also run `bundle exec guard` to automatically run tests as you develop! There are currently only tests for the `notify_slack` and `random_message` classes. Feel free to help us add more!
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
To submit a feature request, bug ticket, etc, please submit an official [GitHub Issue](https://github.com/emmasax4/slack_messaging/issues/new).
|
76
|
+
|
77
|
+
To report any security vulnerabilities, please view this project's [Security Policy](https://github.com/emmasax4/slack_messaging/security/policy).
|
78
|
+
|
79
|
+
This repository does have a standard [Code of Conduct](https://github.com/emmasax4/slack_messaging/blob/main/.github/code_of_conduct.md).
|
80
|
+
|
81
|
+
## Releasing
|
82
|
+
|
83
|
+
To make a new release of this gem:
|
57
84
|
|
58
|
-
|
85
|
+
1. Merge the pull request via the big green button
|
86
|
+
2. Run `git tag vX.X.X` and `git push --tag`
|
87
|
+
3. Make a new release [here](https://github.com/emmasax4/slack_messaging/releases/new)
|
88
|
+
4. Run `gem build *.gemspec`
|
89
|
+
5. Run `gem push *.gem` to push the new gem to RubyGems
|
90
|
+
6. Run `rm *.gem` to clean up your local repository
|
59
91
|
|
60
|
-
|
61
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create a new Pull Request
|
92
|
+
To set up your local machine to push to RubyGems via the API, see the [RubyGems documentation](https://guides.rubygems.org/publishing/#publishing-to-rubygemsorg).
|
data/Rakefile
CHANGED
data/bin/slack-messaging
CHANGED
@@ -16,7 +16,12 @@ program_long_desc """
|
|
16
16
|
DOCUMENTATION
|
17
17
|
"""
|
18
18
|
|
19
|
-
|
19
|
+
desc 'Prints a variety of messages to Slack'
|
20
|
+
command 'slack' do |c|
|
21
|
+
c.action do |global_options, options, args|
|
22
|
+
SlackMessaging::Slack.execute(args, options) # args are optional string to print
|
23
|
+
end
|
24
|
+
end
|
20
25
|
|
21
26
|
pre do |global,command,options,args|
|
22
27
|
SlackMessaging::Config.load(global[:config])
|
data/lib/slack_messaging.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
require_relative
|
3
|
-
require_relative 'slack_messaging/config'
|
4
|
-
require_relative 'slack_messaging/notify_slack'
|
5
|
-
require_relative 'slack_messaging/random_message'
|
6
|
-
|
7
|
-
module SlackMessaging
|
8
|
-
|
1
|
+
Dir[File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'slack_messaging')) + "/**/*.rb"].each do |file|
|
2
|
+
require_relative file
|
9
3
|
end
|
4
|
+
|
5
|
+
module SlackMessaging; end
|
@@ -1,14 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'hashie'
|
2
3
|
|
3
4
|
module SlackMessaging
|
4
|
-
|
5
|
-
module PrivateAttrAccessor
|
6
|
-
def private_attr_accessor(*names)
|
7
|
-
private
|
8
|
-
attr_accessor *names
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
5
|
class DefaultPaths
|
13
6
|
class << self
|
14
7
|
def config
|
@@ -22,15 +15,10 @@ module SlackMessaging
|
|
22
15
|
end
|
23
16
|
|
24
17
|
class Config
|
25
|
-
|
26
|
-
CONFIG_DEFAULTS = {}
|
27
|
-
|
28
18
|
class << self
|
29
|
-
extend PrivateAttrAccessor
|
30
|
-
private_attr_accessor :config_data
|
31
19
|
|
32
20
|
def config
|
33
|
-
|
21
|
+
config_data.to_hash
|
34
22
|
end
|
35
23
|
|
36
24
|
def load(path)
|
@@ -38,54 +26,18 @@ module SlackMessaging
|
|
38
26
|
config
|
39
27
|
end
|
40
28
|
|
41
|
-
def
|
42
|
-
|
43
|
-
config
|
29
|
+
private def config_data
|
30
|
+
@config_data ||= Hashie::Mash.new
|
44
31
|
end
|
45
32
|
|
46
|
-
def
|
47
|
-
|
33
|
+
private def method_missing(method, args=false)
|
34
|
+
config_data.send(method, args)
|
48
35
|
end
|
49
|
-
private :data
|
50
36
|
|
51
|
-
def
|
52
|
-
CONFIG_DEFAULTS[key.to_sym]
|
53
|
-
end
|
54
|
-
private :default_value
|
55
|
-
|
56
|
-
def method_missing(method, args=false)
|
57
|
-
return data[method] if data[method]
|
58
|
-
return default_value(method) if default_value(method)
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
private :method_missing
|
62
|
-
|
63
|
-
def load_config(file)
|
37
|
+
private def load_config(file)
|
64
38
|
raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
|
65
|
-
|
39
|
+
YAML.load_file(file).each{ |key,value| config_data.assign_property(key, value) }
|
66
40
|
end
|
67
|
-
private :load_config
|
68
|
-
|
69
|
-
# We want all ouf our YAML loaded keys to be symbols
|
70
|
-
# taken from http://devblog.avdi.org/2009/07/14/recursively-symbolize-keys/
|
71
|
-
def symbolize_keys(hash)
|
72
|
-
hash.inject({}){|result, (key, value)|
|
73
|
-
new_key = case key
|
74
|
-
when String then key.to_sym
|
75
|
-
else key
|
76
|
-
end
|
77
|
-
new_value = case value
|
78
|
-
when Hash then symbolize_keys(value)
|
79
|
-
else value
|
80
|
-
end
|
81
|
-
result[new_key] = new_value
|
82
|
-
result
|
83
|
-
}
|
84
|
-
end
|
85
|
-
private :symbolize_keys
|
86
|
-
|
87
41
|
end
|
88
|
-
|
89
|
-
MissingConfig = Class.new(StandardError)
|
90
42
|
end
|
91
43
|
end
|
@@ -13,13 +13,14 @@ module SlackMessaging
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform
|
16
|
-
options = {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
options = {
|
17
|
+
webhook_url: webhook_url,
|
18
|
+
channel: channel,
|
19
|
+
username: username,
|
20
|
+
icon_emoji: icon_emoji,
|
21
|
+
http_options: { open_timeout: 10 }
|
22
|
+
}
|
23
|
+
::Slack::Notifier.new(webhook_url, options).ping(text)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -3,25 +3,25 @@ module SlackMessaging
|
|
3
3
|
attr_accessor :text
|
4
4
|
|
5
5
|
MESSAGE_ARRAY = [
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
6
|
+
"A true friend is someone who thinks that you are a good egg even though he knows that you are slightly cracked.\n--Bernard Meltzer",
|
7
|
+
"If you can't make it good, at least make it look good.\n--Bill Gates",
|
8
|
+
"I'm convinced of this: Good done anywhere is good done everywhere.\n--Maya Angelou",
|
9
|
+
"The real trouble with reality is that there's no background music.\n--Anonymous",
|
10
|
+
"Whatever you are, be a good one.\n--Abraham Lincoln",
|
11
|
+
"Good, better, best. Never let it rest. 'Til your good is better and your better is best.\n--St. Jerome",
|
12
|
+
"Despite everything, I believe that people are really good at heart.\n--Anne Frank",
|
13
|
+
"Life is 10% what happens to you and 90% how you react to it.\n--Charles R. Swindoll",
|
14
|
+
"The way to get started is to quit talking and begin doing.\n--Walt Disney",
|
15
|
+
"A creative man is motivated by the desire to achieve, not by the desire to beat others.\n--Ayn Rand",
|
16
|
+
"Problems are not stop signs, they are guidelines.\n--Robert H. Schuller",
|
17
|
+
"Correction does much, but encouragement does more.\n--Johann Wolfgang von Goethe",
|
18
|
+
"Positive anything is better than negative nothing.\n--Elbert Hubbard",
|
19
|
+
"To succeed, you need to find something to hold on to, something to motivate you, something to inspire you.\n--Joyce Meyer",
|
20
|
+
"If you're not making mistakes, then you're not doing anything. I'm positive that a doer makes mistakes.\n--John Wooden",
|
21
|
+
"The best way to deal with other people is to just let them be other people.\n--Anonymous",
|
22
|
+
"Talk to yourself like you would to someone you love.\n--Brenee Brown",
|
23
|
+
"Don't let small minds convince you that your dreams are too big.\n--Anonymous",
|
24
|
+
]
|
25
25
|
|
26
26
|
def initialize
|
27
27
|
self.text = MESSAGE_ARRAY[rand(MESSAGE_ARRAY.length)]
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'highline'
|
2
|
+
|
3
|
+
module SlackMessaging
|
4
|
+
class Slack
|
5
|
+
class << self
|
6
|
+
attr_accessor :options
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.execute(args, options=nil)
|
10
|
+
if args.empty?
|
11
|
+
message = SlackMessaging::RandomMessage.new # generate a new random message
|
12
|
+
print_message(message.get_text)
|
13
|
+
else
|
14
|
+
args.each do |message|
|
15
|
+
print_message(message)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.print_message(message)
|
21
|
+
slack_job = SlackMessaging::NotifySlack.new(message)
|
22
|
+
slack_job.perform
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -4,32 +4,13 @@ require 'slack_messaging'
|
|
4
4
|
module SlackMessaging
|
5
5
|
describe Config do
|
6
6
|
|
7
|
-
context "#set_config_options" do
|
8
|
-
it "should create a corresponding method that returns the value" do
|
9
|
-
SlackMessaging::Config.set_config_options(test: "something")
|
10
|
-
expect(SlackMessaging::Config.test).to eql("something")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "setting a new key should return the entire config hash" do
|
14
|
-
items = SlackMessaging::Config.config.count
|
15
|
-
expect(SlackMessaging::Config.set_config_options(test1: "something_else").count).to eql(items + 1)
|
16
|
-
expect(SlackMessaging::Config.set_config_options(test2: "something else").count).to eql(items + 2)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#config_data" do
|
21
|
-
it "should be a private method" do
|
22
|
-
expect(SlackMessaging::Config).not_to respond_to(:config_data)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
7
|
context "config key methods" do
|
27
8
|
it "should return nil when not set" do
|
28
9
|
expect(SlackMessaging::Config.doesnt_exist).to eql(nil)
|
10
|
+
expect(SlackMessaging::Config.doesnt_exist?).to eql(false)
|
29
11
|
end
|
30
|
-
|
31
12
|
it "should return the config value when set" do
|
32
|
-
SlackMessaging::Config.
|
13
|
+
SlackMessaging::Config.new_value = "testing"
|
33
14
|
expect(SlackMessaging::Config.new_value).to eql("testing")
|
34
15
|
end
|
35
16
|
end
|
@@ -37,7 +18,7 @@ module SlackMessaging
|
|
37
18
|
context "after loading a config file" do
|
38
19
|
before do
|
39
20
|
config_file = {"domain" => "example_domain",
|
40
|
-
"slack" => {"slack_option"=>true,
|
21
|
+
"slack" => {"slack_option" => true,
|
41
22
|
"username" => "Rspec Tester",
|
42
23
|
"icon_url" => "http://fake.url",
|
43
24
|
"channel" => "#test-channel",
|
@@ -55,7 +36,7 @@ module SlackMessaging
|
|
55
36
|
|
56
37
|
it "overwriting values should work" do
|
57
38
|
expect(SlackMessaging::Config.slack).to be_kind_of(Hash)
|
58
|
-
SlackMessaging::Config.
|
39
|
+
SlackMessaging::Config.slack = "this is a string now"
|
59
40
|
expect(SlackMessaging::Config.slack).to eql("this is a string now")
|
60
41
|
end
|
61
42
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'slack_messaging'
|
2
3
|
|
3
4
|
module SlackMessaging
|
4
5
|
describe NotifySlack do
|
@@ -15,7 +16,7 @@ module SlackMessaging
|
|
15
16
|
|
16
17
|
it 'should ping Slack Notifier' do
|
17
18
|
notifier = double('notifier', ping: true)
|
18
|
-
allow(Slack::Notifier).to receive(:new).and_return(notifier)
|
19
|
+
allow(::Slack::Notifier).to receive(:new).and_return(notifier)
|
19
20
|
expect(notifier).to receive(:ping).and_return(true)
|
20
21
|
message = NotifySlack.new("Test message")
|
21
22
|
message.perform
|
@@ -29,6 +30,5 @@ module SlackMessaging
|
|
29
30
|
expect(message.webhook_url).to eq("https://hooks.slack.com/services/totallyrandom/fakewebhookurl")
|
30
31
|
expect(message.icon_emoji).to eq(":wine_glass:")
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
34
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -31,6 +31,9 @@ RSpec.configure do |config|
|
|
31
31
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
32
|
end
|
33
33
|
|
34
|
+
config.filter_run :focus => true
|
35
|
+
config.run_all_when_everything_filtered = true
|
36
|
+
|
34
37
|
# rspec-mocks config goes here. You can use an alternate test double
|
35
38
|
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
39
|
config.mock_with :rspec do |mocks|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emma Sax
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,104 +39,118 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '4.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '4.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: highline
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '2.2'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '2.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: slack-notifier
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.5.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.5.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1
|
103
|
+
version: '2.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1
|
110
|
+
version: '2.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.3'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.3'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rake
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '13.0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '13.0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rspec
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 3.
|
145
|
+
version: '3.9'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 3.
|
139
|
-
description: Sending Personalized Slack Messages
|
152
|
+
version: '3.9'
|
153
|
+
description: Sending Personalized Slack Messages to a Slack channel of your choice.
|
140
154
|
email:
|
141
155
|
- emma.sax4@gmail.com
|
142
156
|
executables:
|
@@ -144,38 +158,30 @@ executables:
|
|
144
158
|
extensions: []
|
145
159
|
extra_rdoc_files: []
|
146
160
|
files:
|
147
|
-
- ".gitignore"
|
148
|
-
- ".octopolo.yml"
|
149
|
-
- ".rspec"
|
150
|
-
- ".ruby-gemset"
|
151
|
-
- ".ruby-version"
|
152
|
-
- ".soyuz.yml"
|
153
|
-
- ".travis.yml"
|
154
|
-
- CHANGELOG.markdown
|
155
161
|
- Gemfile
|
156
|
-
-
|
162
|
+
- Gemfile.lock
|
163
|
+
- Guardfile
|
164
|
+
- LICENSE
|
157
165
|
- OutputFile.png
|
158
166
|
- README.md
|
159
167
|
- Rakefile
|
160
168
|
- bin/slack-messaging
|
161
169
|
- lib/slack_messaging.rb
|
162
|
-
- lib/slack_messaging/commands/slack.rb
|
163
170
|
- lib/slack_messaging/config.rb
|
164
171
|
- lib/slack_messaging/notify_slack.rb
|
165
172
|
- lib/slack_messaging/output.rb
|
166
173
|
- lib/slack_messaging/random_message.rb
|
167
|
-
- lib/slack_messaging/
|
174
|
+
- lib/slack_messaging/slack.rb
|
168
175
|
- lib/slack_messaging/version.rb
|
169
|
-
- slack_messaging.gemspec
|
170
176
|
- spec/slack_messaging/config_spec.rb
|
171
177
|
- spec/slack_messaging/notify_slack_spec.rb
|
172
178
|
- spec/slack_messaging/random_message_spec.rb
|
173
179
|
- spec/spec_helper.rb
|
174
|
-
homepage: https://github.com/
|
180
|
+
homepage: https://github.com/emmasax4/slack_messaging
|
175
181
|
licenses:
|
176
182
|
- MIT
|
177
183
|
metadata: {}
|
178
|
-
post_install_message:
|
184
|
+
post_install_message:
|
179
185
|
rdoc_options: []
|
180
186
|
require_paths:
|
181
187
|
- lib
|
@@ -190,13 +196,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
196
|
- !ruby/object:Gem::Version
|
191
197
|
version: '0'
|
192
198
|
requirements: []
|
193
|
-
|
194
|
-
|
195
|
-
signing_key:
|
199
|
+
rubygems_version: 3.1.2
|
200
|
+
signing_key:
|
196
201
|
specification_version: 4
|
197
|
-
summary:
|
202
|
+
summary: Personalized Slack Messages
|
198
203
|
test_files:
|
204
|
+
- spec/spec_helper.rb
|
199
205
|
- spec/slack_messaging/config_spec.rb
|
200
|
-
- spec/slack_messaging/notify_slack_spec.rb
|
201
206
|
- spec/slack_messaging/random_message_spec.rb
|
202
|
-
- spec/
|
207
|
+
- spec/slack_messaging/notify_slack_spec.rb
|
data/.gitignore
DELETED
data/.octopolo.yml
DELETED
data/.rspec
DELETED
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
slack_messaging
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-2.2.5
|
data/.soyuz.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
defaults:
|
2
|
-
deploy_cmd: gem push *.gem
|
3
|
-
before_deploy_cmds:
|
4
|
-
- sed -i "" -e "s/\".*/\"$(git tag| sed s/v// | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -1)\"/" lib/sport_ngin_aws_auditor/version.rb
|
5
|
-
- git add lib/slack_messaging/version.rb
|
6
|
-
- git commit -m "Version Bump" && git push
|
7
|
-
- gem build slack_messaging.gemspec
|
8
|
-
after_deploy_cmds:
|
9
|
-
- rm *.gem
|
10
|
-
environments:
|
11
|
-
-
|
12
|
-
rubygems: {}
|
data/.travis.yml
DELETED
data/CHANGELOG.markdown
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'highline/import'
|
2
|
-
require_relative "../notify_slack"
|
3
|
-
require_relative "../random_message"
|
4
|
-
|
5
|
-
module SlackMessaging
|
6
|
-
module Scripts
|
7
|
-
class Slack
|
8
|
-
class << self
|
9
|
-
attr_accessor :options
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.execute(args, options=nil)
|
13
|
-
if args.empty?
|
14
|
-
message = RandomMessage.new # generate a new random message
|
15
|
-
print_message(message.get_text)
|
16
|
-
else
|
17
|
-
args.each do |message|
|
18
|
-
print_message(message)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.print_message(message)
|
24
|
-
slack_job = NotifySlack.new(message)
|
25
|
-
slack_job.perform
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/slack_messaging.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'slack_messaging/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "slack_messaging"
|
8
|
-
spec.version = SlackMessaging::VERSION
|
9
|
-
spec.authors = ["Emma Sax"]
|
10
|
-
spec.email = ["emma.sax4@gmail.com"]
|
11
|
-
spec.summary = %q{Sending Personalized Slack Messages}
|
12
|
-
spec.description = %q{Sending Personalized Slack Messages}
|
13
|
-
spec.homepage = "https://github.com/emmasax1/slack_messaging"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency 'hashie', '~> 3.3'
|
22
|
-
spec.add_dependency 'gli', '~> 2.10'
|
23
|
-
spec.add_dependency 'highline', '~> 1.6'
|
24
|
-
spec.add_dependency 'slack-notifier', '~> 1.5.1'
|
25
|
-
spec.add_dependency 'rack', '~> 1.3.0'
|
26
|
-
spec.add_dependency 'activesupport', '~> 3.2'
|
27
|
-
|
28
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
29
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.4.0"
|
31
|
-
end
|