slack_messaging 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b90f38dcdaf24ec98961f9cf3311570daf0087c1308b63483762d158f04161f7
4
- data.tar.gz: 5e8fdef06dd5285ff63d922ca7e1b8e18eef0149104e26a155d8d1bb5916576e
3
+ metadata.gz: 12ec2e4beafc03f085a3a1752070bce7e030cd02e1e57378229400f39a2284ee
4
+ data.tar.gz: f6c4e26dcb8799058f144e24aee9ddf1d4f2f05c0b91deba9f19d5cd1d414303
5
5
  SHA512:
6
- metadata.gz: 2461540b052fc9a790da9e2e11da01b496d08260db928c61c7e11dcd67add9a75e15feab6f03f8dcb029807db6f6205a3fa517d358bc629f606732bed3397b7f
7
- data.tar.gz: 17dcb6ba4aa5f6c98d29611c3e08bb05080aa009c66de4e97ded5194fb31dd3296d4bae091ec9eedc59f142e8d4d862c1d28809a705a0f5282652c1f4f6b049c
6
+ metadata.gz: c3dff63c5569a13e0a713b2e34ca6ef7f22a7ce858523bee5a8483b59b8c17d7053302e3a0f25a670b2ff3ce794f8bd1aef25500e2766594e51b2f35d12ad8ea
7
+ data.tar.gz: 41dc15d6314e4ae1721b2e26163b1e4d6f006f9c7ae6ed93d5ff394b29e98f6399e16f604515eefa54663cb6328356fd31843d6da5228bdf92173889b0380c98
data/Gemfile.lock CHANGED
@@ -5,7 +5,7 @@ PATH
5
5
  activesupport (~> 6.0)
6
6
  gli (~> 2.10)
7
7
  hashie (~> 4.1)
8
- highline_wrapper (~> 0.1.0)
8
+ highline_wrapper (~> 1.0)
9
9
  httparty (~> 0.18)
10
10
  json (~> 2.5)
11
11
  rack (~> 2.2)
@@ -13,7 +13,7 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.1.2.1)
16
+ activesupport (6.1.3)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
@@ -23,11 +23,11 @@ GEM
23
23
  coderay (1.1.3)
24
24
  concurrent-ruby (1.1.8)
25
25
  diff-lcs (1.4.4)
26
- faker (2.15.1)
26
+ faker (2.16.0)
27
27
  i18n (>= 1.6, < 2)
28
28
  ffi (1.14.2)
29
29
  formatador (0.2.5)
30
- gli (2.19.2)
30
+ gli (2.20.0)
31
31
  guard (2.16.2)
32
32
  formatador (>= 0.2.4)
33
33
  listen (>= 2.7, < 4.0)
@@ -44,12 +44,12 @@ GEM
44
44
  rspec (>= 2.99.0, < 4.0)
45
45
  hashie (4.1.0)
46
46
  highline (2.0.3)
47
- highline_wrapper (0.1.0)
47
+ highline_wrapper (1.0.0)
48
48
  highline (~> 2.0)
49
49
  httparty (0.18.1)
50
50
  mime-types (~> 3.0)
51
51
  multi_xml (>= 0.5.2)
52
- i18n (1.8.8)
52
+ i18n (1.8.9)
53
53
  concurrent-ruby (~> 1.0)
54
54
  json (2.5.1)
55
55
  listen (3.4.1)
@@ -59,8 +59,8 @@ GEM
59
59
  method_source (1.0.0)
60
60
  mime-types (3.3.1)
61
61
  mime-types-data (~> 3.2015)
62
- mime-types-data (3.2020.1104)
63
- minitest (5.14.3)
62
+ mime-types-data (3.2021.0225)
63
+ minitest (5.14.4)
64
64
  multi_xml (0.6.0)
65
65
  nenv (0.3.0)
66
66
  notiffany (0.1.3)
@@ -93,7 +93,7 @@ GEM
93
93
  diff-lcs (>= 1.2.0, < 2.0)
94
94
  rspec-support (~> 3.10.0)
95
95
  rspec-support (3.10.2)
96
- rubocop (1.10.0)
96
+ rubocop (1.11.0)
97
97
  parallel (~> 1.10)
98
98
  parser (>= 3.0.0.0)
99
99
  rainbow (>= 2.2.2, < 4.0)
@@ -113,7 +113,7 @@ GEM
113
113
  zeitwerk (2.4.2)
114
114
 
115
115
  PLATFORMS
116
- x86_64-darwin-19
116
+ x86_64-darwin-20
117
117
 
118
118
  DEPENDENCIES
119
119
  bundler (~> 2.2)
@@ -126,4 +126,4 @@ DEPENDENCIES
126
126
  slack_messaging!
127
127
 
128
128
  BUNDLED WITH
129
- 2.2.9
129
+ 2.2.4
data/README.md CHANGED
@@ -86,7 +86,7 @@ I hope you enjoy printing fun and specialized messages to Slack!
86
86
 
87
87
  ### Tests
88
88
 
89
- 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!
89
+ 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!
90
90
 
91
91
  ## Contributing
92
92
 
data/bin/slack-messaging CHANGED
@@ -21,19 +21,20 @@ DOCUMENTATION
21
21
  see Slack Messaging's GitHub repo: https://github.com/emmahsax/slack_messaging
22
22
  "
23
23
 
24
+ pre do |global, _command, _options, _args|
25
+ SlackMessaging::Config.load(global[:config])
26
+ true
27
+ end
28
+
24
29
  desc 'Prints a variety of messages to Slack'
25
30
  command 'send' do |c|
26
- pre do |global, _command, _options, _args|
27
- SlackMessaging::Config.load(global[:config])
28
- true
29
- end
30
-
31
31
  c.action do |_global_options, options, args|
32
32
  SlackMessaging::Send.execute(args, options)
33
33
  end
34
34
  end
35
35
 
36
36
  desc 'Sets up a Slack Messaging config file at ~/.slack_messaging.yml'
37
+ skips_pre
37
38
  command 'setup' do |c|
38
39
  c.action do
39
40
  SlackMessaging::Setup.execute
@@ -2,27 +2,29 @@
2
2
 
3
3
  module SlackMessaging
4
4
  class Config
5
- def self.config
6
- config_data.to_hash
7
- end
5
+ class << self
6
+ def method_missing(method, args = false)
7
+ config_data.send(method, args)
8
+ end
8
9
 
9
- def self.load(path)
10
- load_config(path)
11
- config
12
- end
10
+ def load(path)
11
+ load_config(path)
12
+ config
13
+ end
13
14
 
14
- def self.config_data
15
- @config_data ||= Hashie::Mash.new
16
- end
15
+ private def config
16
+ config_data.to_hash
17
+ end
17
18
 
18
- def self.method_missing(method, args = false)
19
- config_data.send(method, args)
20
- end
19
+ private def config_data
20
+ @config_data ||= Hashie::Mash.new
21
+ end
21
22
 
22
- def self.load_config(file)
23
- raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
23
+ private def load_config(file)
24
+ raise StandardError, "Missing configuration file: #{file}" unless File.exist?(file)
24
25
 
25
- YAML.load_file(file).each { |key, value| config_data.assign_property(key, value) }
26
+ YAML.load_file(file).each { |key, value| config_data.assign_property(key, value) }
27
+ end
26
28
  end
27
29
  end
28
30
  end
@@ -2,12 +2,14 @@
2
2
 
3
3
  module SlackMessaging
4
4
  class DefaultPaths
5
- def self.config
6
- File.join(home, '.slack_messaging.yml')
7
- end
5
+ class << self
6
+ def config
7
+ File.join(home, '.slack_messaging.yml')
8
+ end
8
9
 
9
- def self.home
10
- ENV['HOME'] || '.'
10
+ private def home
11
+ ENV['HOME'] || '.'
12
+ end
11
13
  end
12
14
  end
13
15
  end
@@ -2,21 +2,23 @@
2
2
 
3
3
  module SlackMessaging
4
4
  class Send
5
- attr_accessor :options
5
+ class << self
6
+ attr_accessor :options
6
7
 
7
- def self.execute(args, _options = nil)
8
- if args.empty?
9
- message = SlackMessaging::RandomMessage.acquire_random_quote
10
- print_message(message)
11
- else
12
- args.each do |arg_message|
13
- print_message(arg_message)
8
+ def execute(args, _options = nil)
9
+ if args.empty?
10
+ message = SlackMessaging::RandomMessage.acquire_random_quote
11
+ print_message(message)
12
+ else
13
+ args.each do |arg_message|
14
+ print_message(arg_message)
15
+ end
14
16
  end
15
17
  end
16
- end
17
18
 
18
- def self.print_message(message)
19
- SlackMessaging::NotifySlack.new(message).perform
19
+ private def print_message(message)
20
+ SlackMessaging::NotifySlack.new(message).perform
21
+ end
20
22
  end
21
23
  end
22
24
  end
@@ -2,91 +2,83 @@
2
2
 
3
3
  module SlackMessaging
4
4
  class Setup
5
- def self.execute
6
- if config_file_exists?
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
13
- end
14
-
15
- create_or_update_config_file(ask_config_questions) if answer
16
- end
5
+ class << self
6
+ # rubocop:disable Style/ConditionalAssignment
7
+ def execute
8
+ if config_file_exists?
9
+ answer = highline.ask_yes_no(
10
+ "It looks like the #{default_config} file already exists. Do you wish to replace it? (y/n)",
11
+ { required: true }
12
+ )
13
+ else
14
+ answer = true
15
+ end
17
16
 
18
- def self.create_or_update_config_file(answers)
19
- contents = generate_config_file(answers)
20
- puts "\nCreating or updating your #{default_config} file..."
21
- File.open(default_config, 'w') { |file| file.puts contents }
22
- puts "\nDone!"
23
- end
17
+ create_or_update_config_file(ask_config_questions) if answer
18
+ end
19
+ # rubocop:enable Style/ConditionalAssignment
24
20
 
25
- def self.generate_config_file(answers)
26
- file_contents = ''.dup
27
- file_contents << "slack:\n"
28
- file_contents << " channel: #{answers[:channel].tr('#', '').strip}\n"
29
- file_contents << " username: #{answers[:username].strip}\n"
30
- file_contents << " webhook_url: #{answers[:webhook_url].strip}\n"
31
- file_contents << " icon_emoji: '#{answers[:icon_emoji].strip}'"
32
- file_contents
33
- end
21
+ private def create_or_update_config_file(answers)
22
+ contents = generate_config_file(answers)
23
+ puts "Creating or updating your #{default_config} file..."
24
+ File.open(default_config, 'w') { |file| file.puts contents }
25
+ puts "\nDone!"
26
+ end
34
27
 
35
- def self.config_file_exists?
36
- File.exist?(default_config)
37
- end
28
+ private def generate_config_file(answers)
29
+ file_contents = ''.dup
30
+ file_contents << "slack:\n"
31
+ file_contents << " channel: #{answers[:channel].tr('#', '').strip}\n"
32
+ file_contents << " username: #{answers[:username].strip}\n"
33
+ file_contents << " webhook_url: #{answers[:webhook_url].strip}\n"
34
+ file_contents << " icon_emoji: '#{answers[:icon_emoji].strip}'"
35
+ file_contents
36
+ end
38
37
 
39
- # rubocop:disable Metrics/MethodLength
40
- def self.ask_config_questions
41
- answers = {}
38
+ private def config_file_exists?
39
+ File.exist?(default_config)
40
+ end
42
41
 
43
- answers[:webhook_url] = ask_question(
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.',
47
- required: true
48
- )
42
+ # rubocop:disable Metrics/MethodLength
43
+ private def ask_config_questions
44
+ answers = {}
49
45
 
50
- answers[:channel] = ask_question(
51
- "\nWhat slack channel do you wish to post to? (default is \"#general\")"
52
- ) || 'general'
46
+ answers[:webhook_url] = ask_question(
47
+ "What is your Slack webhook URL? If you don't have one yet, please navigate" \
48
+ ' to https://api.slack.com/messaging/webhooks to create one, and then come back' \
49
+ ' here and paste it in the Terminal.',
50
+ required: true
51
+ )
53
52
 
54
- answers[:username] = ask_question(
55
- "\nWhat slack username do you wish to post as? (default is \"Let's Get Quoty\")"
56
- ) || "Let's Get Quoty"
53
+ answers[:channel] = ask_question(
54
+ 'What slack channel do you wish to post to? (default is "#general")'
55
+ ) || 'general'
57
56
 
58
- answers[:icon_emoji] = ask_question(
59
- "\nWhat emoji would you like to post with (include the colons at the beginning and end" \
60
- ' of the emoji name)? (default is ":mailbox_with_mail:")'
61
- ) || ':mailbox_with_mail:'
57
+ answers[:username] = ask_question(
58
+ "What slack username do you wish to post as? (default is \"Let's Get Quoty\")"
59
+ ) || "Let's Get Quoty"
62
60
 
63
- answers
64
- end
65
- # rubocop:enable Metrics/MethodLength
61
+ answers[:icon_emoji] = ask_question(
62
+ 'What emoji would you like to post with (include the colons at the beginning and end' \
63
+ ' of the emoji name)? (default is ":mailbox_with_mail:")'
64
+ ) || ':mailbox_with_mail:'
66
65
 
67
- # rubocop:disable Metrics/MethodLength
68
- def self.ask_question(prompt, required: false)
69
- answer = highline.ask(prompt)
66
+ answers
67
+ end
68
+ # rubocop:enable Metrics/MethodLength
70
69
 
71
- if required
72
- if answer.empty?
73
- puts "\nThis question is required.\n\n"
74
- ask_question(prompt, required: true)
75
- else
76
- answer
77
- end
78
- else
70
+ private def ask_question(prompt, required: false)
71
+ answer = highline.ask(prompt, { required: required })
79
72
  answer.empty? ? nil : answer
80
73
  end
81
- end
82
- # rubocop:enable Metrics/MethodLength
83
74
 
84
- def self.highline
85
- @highline ||= HighlineWrapper.new
86
- end
75
+ private def highline
76
+ @highline ||= HighlineWrapper.new
77
+ end
87
78
 
88
- def self.default_config
89
- SlackMessaging::DefaultPaths.config
79
+ private def default_config
80
+ SlackMessaging::DefaultPaths.config
81
+ end
90
82
  end
91
83
  end
92
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlackMessaging
4
- VERSION = '3.1.0'
4
+ VERSION = '3.1.1'
5
5
  end
@@ -109,25 +109,6 @@ describe SlackMessaging::Setup do
109
109
  subject.send(:ask_config_questions)
110
110
  end
111
111
 
112
- it 'should recurse if the slack URL is not given' do
113
- allow(highline_wrapper).to receive(:ask).with(
114
- "What is your Slack webhook URL? If you don't have one yet, please navigate" \
115
- ' to https://api.slack.com/messaging/webhooks to create one, and then come back' \
116
- ' here and paste it in the Terminal.'
117
- ).and_return('', Faker::Internet.url)
118
- allow(highline_wrapper).to receive(:ask).with(
119
- "\nWhat slack channel do you wish to post to? (default is \"#general\")"
120
- ).and_return('')
121
- allow(highline_wrapper).to receive(:ask).with(
122
- "\nWhat slack username do you wish to post as? (default is \"Let's Get Quoty\")"
123
- ).and_return('')
124
- allow(highline_wrapper).to receive(:ask).with(
125
- "\nWhat emoji would you like to post with (include the colons at the beginning and end of the emoji name)? (default is \":mailbox_with_mail:\")"
126
- ).and_return('')
127
- expect(subject).to receive(:ask_question).at_least(:twice).and_call_original
128
- subject.send(:ask_config_questions)
129
- end
130
-
131
112
  it 'should return the defaults if nothing is given' do
132
113
  slack_url = Faker::Internet.url
133
114
  defaults = {
@@ -141,13 +122,13 @@ describe SlackMessaging::Setup do
141
122
  required: true
142
123
  ).and_return(slack_url)
143
124
  allow(subject).to receive(:ask_question).with(
144
- "\nWhat slack channel do you wish to post to? (default is \"#general\")"
125
+ 'What slack channel do you wish to post to? (default is "#general")'
145
126
  ).and_return(nil)
146
127
  allow(subject).to receive(:ask_question).with(
147
- "\nWhat slack username do you wish to post as? (default is \"Let's Get Quoty\")"
128
+ "What slack username do you wish to post as? (default is \"Let's Get Quoty\")"
148
129
  ).and_return(nil)
149
130
  allow(subject).to receive(:ask_question).with(
150
- "\nWhat emoji would you like to post with (include the colons at the beginning and end of the emoji name)? (default is \":mailbox_with_mail:\")"
131
+ 'What emoji would you like to post with (include the colons at the beginning and end of the emoji name)? (default is ":mailbox_with_mail:")'
151
132
  ).and_return(nil)
152
133
  expect(subject.send(:ask_config_questions)).to eq(defaults)
153
134
  end
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: 3.1.0
4
+ version: 3.1.1
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-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0
61
+ version: '1.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: 0.1.0
68
+ version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: httparty
71
71
  requirement: !ruby/object:Gem::Requirement