slack_messaging 2.2.0 → 3.0.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/Gemfile +2 -0
- data/Gemfile.lock +22 -1
- data/Guardfile +3 -1
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/bin/slack-messaging +11 -8
- data/lib/slack_messaging.rb +5 -1
- data/lib/slack_messaging/config.rb +3 -2
- data/lib/slack_messaging/default_paths.rb +4 -4
- data/lib/slack_messaging/highline_cli.rb +3 -1
- data/lib/slack_messaging/notify_slack.rb +2 -0
- data/lib/slack_messaging/random_message.rb +3 -1
- data/lib/slack_messaging/{slack.rb → send.rb} +6 -6
- data/lib/slack_messaging/setup.rb +19 -16
- data/lib/slack_messaging/version.rb +3 -1
- data/spec/slack_messaging/config_spec.rb +9 -7
- data/spec/slack_messaging/highline_cli_spec.rb +7 -5
- data/spec/slack_messaging/notify_slack_spec.rb +9 -7
- data/spec/slack_messaging/random_message_spec.rb +2 -0
- data/spec/slack_messaging/setup_spec.rb +13 -9
- data/spec/spec_helper.rb +3 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6742192033a64bb2935e5af6486ea356d54684f501515f22eb8a24c200fff61
|
4
|
+
data.tar.gz: 0d880c5cd858c778f06c9047e911927a1cb2ab2ee6b53a89b20b9e23a61ad2a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8458be91785ae94772e960f5f0705a2a611b36c286f694d0eb0ac4abe86fdd9d6867aa89d45dc9c44d721dbdb7bd9f34365ca5121f1d85ac0fd027d33439dbf4
|
7
|
+
data.tar.gz: 7485f64ff53624785968f06a25e109a8042aa1e7e63412d7c7a40b78da8209f643e06f62130b3c8e7ba8d0677db2445950b2a9fca0ceb5199b03c71d10592bd3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack_messaging (
|
4
|
+
slack_messaging (3.0.0)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
gli (~> 2.10)
|
7
7
|
hashie (~> 4.1)
|
@@ -19,6 +19,7 @@ GEM
|
|
19
19
|
minitest (>= 5.1)
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
zeitwerk (~> 2.3)
|
22
|
+
ast (2.4.2)
|
22
23
|
coderay (1.1.3)
|
23
24
|
concurrent-ruby (1.1.8)
|
24
25
|
diff-lcs (1.4.4)
|
@@ -63,14 +64,20 @@ GEM
|
|
63
64
|
notiffany (0.1.3)
|
64
65
|
nenv (~> 0.1)
|
65
66
|
shellany (~> 0.0)
|
67
|
+
parallel (1.20.1)
|
68
|
+
parser (3.0.0.0)
|
69
|
+
ast (~> 2.4.1)
|
66
70
|
pry (0.14.0)
|
67
71
|
coderay (~> 1.1)
|
68
72
|
method_source (~> 1.0)
|
69
73
|
rack (2.2.3)
|
74
|
+
rainbow (3.0.0)
|
70
75
|
rake (13.0.3)
|
71
76
|
rb-fsevent (0.10.4)
|
72
77
|
rb-inotify (0.10.1)
|
73
78
|
ffi (~> 1.0)
|
79
|
+
regexp_parser (2.1.1)
|
80
|
+
rexml (3.2.4)
|
74
81
|
rspec (3.10.0)
|
75
82
|
rspec-core (~> 3.10.0)
|
76
83
|
rspec-expectations (~> 3.10.0)
|
@@ -84,10 +91,23 @@ GEM
|
|
84
91
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
92
|
rspec-support (~> 3.10.0)
|
86
93
|
rspec-support (3.10.2)
|
94
|
+
rubocop (1.10.0)
|
95
|
+
parallel (~> 1.10)
|
96
|
+
parser (>= 3.0.0.0)
|
97
|
+
rainbow (>= 2.2.2, < 4.0)
|
98
|
+
regexp_parser (>= 1.8, < 3.0)
|
99
|
+
rexml
|
100
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
101
|
+
ruby-progressbar (~> 1.7)
|
102
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
103
|
+
rubocop-ast (1.4.1)
|
104
|
+
parser (>= 2.7.1.5)
|
105
|
+
ruby-progressbar (1.11.0)
|
87
106
|
shellany (0.0.1)
|
88
107
|
thor (1.1.0)
|
89
108
|
tzinfo (2.0.4)
|
90
109
|
concurrent-ruby (~> 1.0)
|
110
|
+
unicode-display_width (2.0.0)
|
91
111
|
zeitwerk (2.4.2)
|
92
112
|
|
93
113
|
PLATFORMS
|
@@ -100,6 +120,7 @@ DEPENDENCIES
|
|
100
120
|
pry (~> 0.13)
|
101
121
|
rake (~> 13.0)
|
102
122
|
rspec (~> 3.9)
|
123
|
+
rubocop
|
103
124
|
slack_messaging!
|
104
125
|
|
105
126
|
BUNDLED WITH
|
data/Guardfile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
|
2
4
|
watch(%r{^spec/.+_spec\.rb$})
|
3
5
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
6
|
watch('spec/spec_helper.rb') { 'spec' }
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Slack Messaging [](https://github.com/emmahsax/slack_messaging/actions/workflows/main.yml)
|
2
2
|
|
3
3
|
This is a simple project designed to post messages to a given Slack channel as a bot.
|
4
4
|
|
@@ -53,7 +53,7 @@ mv ~/.slack_messaging.yml /PATH/TO/FILE/config.yml
|
|
53
53
|
And then you can pass in that specific file location like this:
|
54
54
|
|
55
55
|
```bash
|
56
|
-
slack-messaging --config="/PATH/TO/FILE/config.yml"
|
56
|
+
slack-messaging --config="/PATH/TO/FILE/config.yml" send
|
57
57
|
```
|
58
58
|
|
59
59
|
Once the config file is set up, the project is ready to go!
|
@@ -61,7 +61,7 @@ Once the config file is set up, the project is ready to go!
|
|
61
61
|
To print a friendly message to Slack, run:
|
62
62
|
|
63
63
|
```bash
|
64
|
-
slack-messaging
|
64
|
+
slack-messaging send
|
65
65
|
```
|
66
66
|
|
67
67
|
Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote. The random quotes are selected using the [Quotable API](http://api.quotable.io/).
|
@@ -69,13 +69,13 @@ Here, no specific message is being given to print to Slack, so slack_messaging w
|
|
69
69
|
However, what if you wanted to print something specific? Well, you can! Just run:
|
70
70
|
|
71
71
|
```bash
|
72
|
-
slack-messaging
|
72
|
+
slack-messaging send 'MESSAGE 1'
|
73
73
|
```
|
74
74
|
|
75
75
|
You can even print multiple messages at once:
|
76
76
|
|
77
77
|
```bash
|
78
|
-
slack-messaging
|
78
|
+
slack-messaging send 'MESSAGE 1' 'MESSAGE 2' 'MESSAGE 3' ... 'MESSAGE N'
|
79
79
|
```
|
80
80
|
|
81
81
|
The output of slack_messaging will look something like this:
|
data/Rakefile
CHANGED
data/bin/slack-messaging
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
2
5
|
require 'rubygems'
|
3
6
|
require 'gli'
|
4
7
|
require_relative '../lib/slack_messaging'
|
@@ -10,29 +13,29 @@ version SlackMessaging::VERSION
|
|
10
13
|
|
11
14
|
wrap_help_text :verbatim
|
12
15
|
|
13
|
-
flag [:config], :
|
16
|
+
flag [:config], desc: 'Slack Messaging config file path', default_value: SlackMessaging::DefaultPaths.config
|
14
17
|
|
15
|
-
program_long_desc "
|
18
|
+
program_long_desc "
|
16
19
|
DOCUMENTATION
|
17
20
|
For documentation and help in setting up your configuration files,
|
18
21
|
see Slack Messaging's GitHub repo: https://github.com/emmahsax/slack_messaging
|
19
|
-
"
|
22
|
+
"
|
20
23
|
|
21
24
|
desc 'Prints a variety of messages to Slack'
|
22
|
-
command '
|
23
|
-
pre do |global,
|
25
|
+
command 'send' do |c|
|
26
|
+
pre do |global, _command, _options, _args|
|
24
27
|
SlackMessaging::Config.load(global[:config])
|
25
28
|
true
|
26
29
|
end
|
27
30
|
|
28
|
-
c.action do |
|
29
|
-
SlackMessaging::
|
31
|
+
c.action do |_global_options, options, args|
|
32
|
+
SlackMessaging::Send.execute(args, options)
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
desc 'Sets up a Slack Messaging config file at ~/.slack_messaging.yml'
|
34
37
|
command 'setup' do |c|
|
35
|
-
c.action do
|
38
|
+
c.action do
|
36
39
|
SlackMessaging::Setup.execute
|
37
40
|
end
|
38
41
|
end
|
data/lib/slack_messaging.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'hashie'
|
3
5
|
require 'httparty'
|
4
6
|
require 'highline'
|
5
7
|
require 'json'
|
6
8
|
|
7
|
-
|
9
|
+
files = "#{File.expand_path(File.join(File.dirname(File.absolute_path(__FILE__)), 'slack_messaging'))}/**/*.rb"
|
10
|
+
|
11
|
+
Dir[files].each do |file|
|
8
12
|
require_relative file
|
9
13
|
end
|
10
14
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
4
|
class Config
|
3
5
|
def self.config
|
@@ -9,8 +11,6 @@ module SlackMessaging
|
|
9
11
|
config
|
10
12
|
end
|
11
13
|
|
12
|
-
private
|
13
|
-
|
14
14
|
def self.config_data
|
15
15
|
@config_data ||= Hashie::Mash.new
|
16
16
|
end
|
@@ -21,6 +21,7 @@ module SlackMessaging
|
|
21
21
|
|
22
22
|
def self.load_config(file)
|
23
23
|
raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
|
24
|
+
|
24
25
|
YAML.load_file(file).each { |key, value| config_data.assign_property(key, value) }
|
25
26
|
end
|
26
27
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
4
|
class DefaultPaths
|
3
5
|
def self.config
|
4
|
-
File.join(
|
6
|
+
File.join(home, '.slack_messaging.yml')
|
5
7
|
end
|
6
8
|
|
7
|
-
private
|
8
|
-
|
9
9
|
def self.home
|
10
|
-
ENV['HOME']
|
10
|
+
ENV['HOME'] || '.'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
4
|
class HighlineCli
|
3
5
|
def ask(prompt)
|
@@ -15,7 +17,7 @@ module SlackMessaging
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def ask_options(prompt, choices)
|
18
|
-
choices_as_string_options = ''
|
20
|
+
choices_as_string_options = ''.dup
|
19
21
|
choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
|
20
22
|
compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
|
21
23
|
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
4
|
class RandomMessage
|
3
5
|
def self.acquire_random_quote
|
4
6
|
random_quote = HTTParty.get('http://api.quotable.io/random', headers: { 'Content-Type': 'application/json' }).body
|
5
7
|
quote_content = JSON.parse(random_quote)['content']
|
6
8
|
quote_author = JSON.parse(random_quote)['author']
|
7
|
-
|
9
|
+
"\"#{quote_content}\"\n—#{quote_author}"
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,20 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
|
-
class
|
4
|
+
class Send
|
3
5
|
attr_accessor :options
|
4
6
|
|
5
|
-
def self.execute(args,
|
7
|
+
def self.execute(args, _options = nil)
|
6
8
|
if args.empty?
|
7
9
|
message = SlackMessaging::RandomMessage.acquire_random_quote
|
8
10
|
print_message(message)
|
9
11
|
else
|
10
|
-
args.each do |
|
11
|
-
print_message(
|
12
|
+
args.each do |arg_message|
|
13
|
+
print_message(arg_message)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
private
|
17
|
-
|
18
18
|
def self.print_message(message)
|
19
19
|
SlackMessaging::NotifySlack.new(message).perform
|
20
20
|
end
|
@@ -1,20 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlackMessaging
|
2
4
|
class Setup
|
3
5
|
def self.execute
|
4
6
|
if config_file_exists?
|
5
|
-
answer = highline.ask_yes_no(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
answer = highline.ask_yes_no(
|
8
|
+
"It looks like the #{default_config} file already exists. Do you wish to replace it? (y/n)"
|
9
|
+
)
|
10
|
+
puts
|
11
|
+
else
|
12
|
+
answer = true
|
11
13
|
end
|
12
14
|
|
13
|
-
create_or_update_config_file(ask_config_questions)
|
15
|
+
create_or_update_config_file(ask_config_questions) if answer
|
14
16
|
end
|
15
17
|
|
16
|
-
private
|
17
|
-
|
18
18
|
def self.create_or_update_config_file(answers)
|
19
19
|
contents = generate_config_file(answers)
|
20
20
|
puts "\nCreating or updating your #{default_config} file..."
|
@@ -23,7 +23,7 @@ module SlackMessaging
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.generate_config_file(answers)
|
26
|
-
file_contents = ''
|
26
|
+
file_contents = ''.dup
|
27
27
|
file_contents << "slack:\n"
|
28
28
|
file_contents << " channel: #{answers[:channel].tr('#', '').strip}\n"
|
29
29
|
file_contents << " username: #{answers[:username].strip}\n"
|
@@ -33,16 +33,17 @@ module SlackMessaging
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.config_file_exists?
|
36
|
-
File.
|
36
|
+
File.exist?(default_config)
|
37
37
|
end
|
38
38
|
|
39
|
+
# rubocop:disable Metrics/MethodLength:
|
39
40
|
def self.ask_config_questions
|
40
41
|
answers = {}
|
41
42
|
|
42
43
|
answers[:webhook_url] = ask_question(
|
43
|
-
"
|
44
|
-
|
45
|
-
|
44
|
+
"What is your Slack webhook URL? If you don't have one yet, please navigate" \
|
45
|
+
' to https://api.slack.com/messaging/webhooks to create one, and then come back' \
|
46
|
+
' here and paste it in the Terminal.'
|
46
47
|
)
|
47
48
|
|
48
49
|
unless answers[:webhook_url]
|
@@ -59,11 +60,13 @@ module SlackMessaging
|
|
59
60
|
) || "Let's Get Quoty"
|
60
61
|
|
61
62
|
answers[:icon_emoji] = ask_question(
|
62
|
-
"\nWhat emoji would you like to post with (include the colons at the beginning and end
|
63
|
-
|
63
|
+
"\nWhat emoji would you like to post with (include the colons at the beginning and end" \
|
64
|
+
' of the emoji name)? (default is ":mailbox_with_mail:")'
|
65
|
+
) || ':mailbox_with_mail:'
|
64
66
|
|
65
67
|
answers
|
66
68
|
end
|
69
|
+
# rubocop:enable Metrics/MethodLength
|
67
70
|
|
68
71
|
def self.ask_question(prompt)
|
69
72
|
answer = highline.ask(prompt)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'slack_messaging'
|
3
5
|
|
@@ -23,13 +25,13 @@ describe SlackMessaging::Config do
|
|
23
25
|
|
24
26
|
let(:config_file) do
|
25
27
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
domain: domain,
|
29
|
+
slack: {
|
30
|
+
slack_option: true,
|
31
|
+
username: Faker::Name.name,
|
32
|
+
icon_url: Faker::Internet.url,
|
33
|
+
channel: Faker::Lorem.word,
|
34
|
+
webhook: Faker::Internet.url
|
33
35
|
}
|
34
36
|
}
|
35
37
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'slack_messaging'
|
3
5
|
|
@@ -10,7 +12,7 @@ describe SlackMessaging::HighlineCli do
|
|
10
12
|
end
|
11
13
|
|
12
14
|
describe '#ask' do
|
13
|
-
it 'should ask the highline client ask'do
|
15
|
+
it 'should ask the highline client ask' do
|
14
16
|
expect(highline_client).to receive(:ask)
|
15
17
|
subject.ask(Faker::Lorem.sentence)
|
16
18
|
end
|
@@ -21,7 +23,7 @@ describe SlackMessaging::HighlineCli do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
describe '#ask_yes_no' do
|
24
|
-
it 'should ask the highline client ask'do
|
26
|
+
it 'should ask the highline client ask' do
|
25
27
|
expect(highline_client).to receive(:ask)
|
26
28
|
subject.ask_yes_no(Faker::Lorem.sentence)
|
27
29
|
end
|
@@ -37,13 +39,13 @@ describe SlackMessaging::HighlineCli do
|
|
37
39
|
end
|
38
40
|
|
39
41
|
describe '#ask_options' do
|
40
|
-
it 'should ask the highline client ask'do
|
42
|
+
it 'should ask the highline client ask' do
|
41
43
|
expect(highline_client).to receive(:ask)
|
42
|
-
subject.ask_options(Faker::Lorem.sentence, [
|
44
|
+
subject.ask_options(Faker::Lorem.sentence, %w[one two three])
|
43
45
|
end
|
44
46
|
|
45
47
|
it 'should return a string from the options' do
|
46
|
-
expect(subject.ask_options(Faker::Lorem.sentence, [
|
48
|
+
expect(subject.ask_options(Faker::Lorem.sentence, %w[one two three])).to be_a(String)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'slack_messaging'
|
3
5
|
|
@@ -10,12 +12,12 @@ describe SlackMessaging::NotifySlack do
|
|
10
12
|
|
11
13
|
let(:config_file) do
|
12
14
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
slack: {
|
16
|
+
slack_option: true,
|
17
|
+
username: username,
|
18
|
+
icon_emoji: emoji,
|
19
|
+
channel: channel,
|
20
|
+
webhook_url: webhook
|
19
21
|
}
|
20
22
|
}
|
21
23
|
end
|
@@ -34,7 +36,7 @@ describe SlackMessaging::NotifySlack do
|
|
34
36
|
message.perform
|
35
37
|
end
|
36
38
|
|
37
|
-
|
39
|
+
it 'should define certain values' do
|
38
40
|
message = subject.new(sentence)
|
39
41
|
expect(message.text).to eq(sentence)
|
40
42
|
expect(message.channel).to eq(channel)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'slack_messaging'
|
3
5
|
|
@@ -19,13 +21,14 @@ describe SlackMessaging::Setup do
|
|
19
21
|
end
|
20
22
|
|
21
23
|
after do
|
22
|
-
SlackMessaging::Setup.instance_variable_set(
|
24
|
+
SlackMessaging::Setup.instance_variable_set('@highline', nil)
|
23
25
|
end
|
24
26
|
|
25
27
|
subject { SlackMessaging::Setup }
|
26
28
|
|
27
29
|
describe '#self.execute' do
|
28
30
|
it 'should ask a question if the config file exists' do
|
31
|
+
allow(subject).to receive(:config_file_exists?).and_return(true)
|
29
32
|
allow(File).to receive(:exists?).and_return(true)
|
30
33
|
expect(highline_cli).to receive(:ask_yes_no).and_return(true)
|
31
34
|
allow(subject).to receive(:create_or_update_config_file).and_return(true)
|
@@ -41,12 +44,13 @@ describe SlackMessaging::Setup do
|
|
41
44
|
subject.execute
|
42
45
|
end
|
43
46
|
|
44
|
-
it 'should
|
47
|
+
it 'should skip if the user opts not to continue' do
|
48
|
+
allow(subject).to receive(:config_file_exists?).and_return(true)
|
45
49
|
allow(File).to receive(:exists?).and_return(true)
|
46
50
|
allow(highline_cli).to receive(:ask_yes_no).and_return(false)
|
47
51
|
expect(subject).not_to receive(:create_or_update_config_file)
|
48
52
|
expect(subject).not_to receive(:ask_config_questions)
|
49
|
-
|
53
|
+
subject.execute
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -72,12 +76,12 @@ describe SlackMessaging::Setup do
|
|
72
76
|
|
73
77
|
describe '#self.config_file_exists?' do
|
74
78
|
it 'should return true if the file exists' do
|
75
|
-
allow(File).to receive(:
|
79
|
+
allow(File).to receive(:exist?).and_return(true)
|
76
80
|
expect(subject.send(:config_file_exists?)).to eq(true)
|
77
81
|
end
|
78
82
|
|
79
83
|
it 'should return false if the file does not exist' do
|
80
|
-
allow(File).to receive(:
|
84
|
+
allow(File).to receive(:exist?).and_return(false)
|
81
85
|
expect(subject.send(:config_file_exists?)).to eq(false)
|
82
86
|
end
|
83
87
|
end
|
@@ -108,15 +112,15 @@ describe SlackMessaging::Setup do
|
|
108
112
|
|
109
113
|
it 'should exit if the slack URL is not given' do
|
110
114
|
allow(subject).to receive(:ask_question).and_return(nil)
|
111
|
-
expect{ subject.send(:ask_config_questions) }.to raise_error(SystemExit)
|
115
|
+
expect { subject.send(:ask_config_questions) }.to raise_error(SystemExit)
|
112
116
|
end
|
113
117
|
|
114
118
|
it 'should return the defaults if nothing is given' do
|
115
119
|
slack_url = Faker::Internet.url
|
116
120
|
allow(subject).to receive(:ask_question).with(
|
117
121
|
"\nWhat is your Slack webhook URL? If you don't have one yet, please navigate" \
|
118
|
-
|
119
|
-
|
122
|
+
' to https://api.slack.com/messaging/webhooks to create one, and then come back' \
|
123
|
+
' here and paste it in the Terminal.'
|
120
124
|
).and_return(slack_url)
|
121
125
|
allow(subject).to receive(:ask_question).and_return(nil)
|
122
126
|
expect(subject.send(:ask_config_questions)).to eq(
|
@@ -124,7 +128,7 @@ describe SlackMessaging::Setup do
|
|
124
128
|
channel: 'general',
|
125
129
|
username: "Let's Get Quoty",
|
126
130
|
webhook_url: slack_url,
|
127
|
-
icon_emoji:
|
131
|
+
icon_emoji: ':mailbox_with_mail:'
|
128
132
|
}
|
129
133
|
)
|
130
134
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faker'
|
2
4
|
require 'pry'
|
3
5
|
|
@@ -34,7 +36,7 @@ RSpec.configure do |config|
|
|
34
36
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
35
37
|
end
|
36
38
|
|
37
|
-
config.filter_run :
|
39
|
+
config.filter_run focus: true
|
38
40
|
config.run_all_when_everything_filtered = true
|
39
41
|
|
40
42
|
# rspec-mocks config goes here. You can use an alternate test double
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emma Sax
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '3.9'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
description: Sending Personalized Slack Messages to a Slack channel of your choice.
|
196
210
|
email:
|
197
211
|
executables:
|
@@ -213,8 +227,8 @@ files:
|
|
213
227
|
- lib/slack_messaging/highline_cli.rb
|
214
228
|
- lib/slack_messaging/notify_slack.rb
|
215
229
|
- lib/slack_messaging/random_message.rb
|
230
|
+
- lib/slack_messaging/send.rb
|
216
231
|
- lib/slack_messaging/setup.rb
|
217
|
-
- lib/slack_messaging/slack.rb
|
218
232
|
- lib/slack_messaging/version.rb
|
219
233
|
- spec/slack_messaging/config_spec.rb
|
220
234
|
- spec/slack_messaging/highline_cli_spec.rb
|
@@ -234,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
234
248
|
requirements:
|
235
249
|
- - ">="
|
236
250
|
- !ruby/object:Gem::Version
|
237
|
-
version: '
|
251
|
+
version: '2.4'
|
238
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
253
|
requirements:
|
240
254
|
- - ">="
|