slack_messaging 3.0.0 → 3.1.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.lock +5 -3
 - data/README.md +1 -1
 - data/lib/slack_messaging.rb +1 -1
 - data/lib/slack_messaging/setup.rb +18 -10
 - data/lib/slack_messaging/version.rb +1 -1
 - data/spec/slack_messaging/notify_slack_spec.rb +7 -9
 - data/spec/slack_messaging/setup_spec.rb +44 -25
 - metadata +9 -12
 - data/lib/slack_messaging/highline_cli.rb +0 -35
 - data/spec/slack_messaging/highline_cli_spec.rb +0 -51
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b90f38dcdaf24ec98961f9cf3311570daf0087c1308b63483762d158f04161f7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5e8fdef06dd5285ff63d922ca7e1b8e18eef0149104e26a155d8d1bb5916576e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2461540b052fc9a790da9e2e11da01b496d08260db928c61c7e11dcd67add9a75e15feab6f03f8dcb029807db6f6205a3fa517d358bc629f606732bed3397b7f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 17dcb6ba4aa5f6c98d29611c3e08bb05080aa009c66de4e97ded5194fb31dd3296d4bae091ec9eedc59f142e8d4d862c1d28809a705a0f5282652c1f4f6b049c
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                slack_messaging (3. 
     | 
| 
      
 4 
     | 
    
         
            +
                slack_messaging (3.1.0)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  activesupport (~> 6.0)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  gli (~> 2.10)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  hashie (~> 4.1)
         
     | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
      
 8 
     | 
    
         
            +
                  highline_wrapper (~> 0.1.0)
         
     | 
| 
       9 
9 
     | 
    
         
             
                  httparty (~> 0.18)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  json (~> 2.5)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  rack (~> 2.2)
         
     | 
| 
         @@ -44,6 +44,8 @@ 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)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  highline (~> 2.0)
         
     | 
| 
       47 
49 
     | 
    
         
             
                httparty (0.18.1)
         
     | 
| 
       48 
50 
     | 
    
         
             
                  mime-types (~> 3.0)
         
     | 
| 
       49 
51 
     | 
    
         
             
                  multi_xml (>= 0.5.2)
         
     | 
| 
         @@ -120,7 +122,7 @@ DEPENDENCIES 
     | 
|
| 
       120 
122 
     | 
    
         
             
              pry (~> 0.13)
         
     | 
| 
       121 
123 
     | 
    
         
             
              rake (~> 13.0)
         
     | 
| 
       122 
124 
     | 
    
         
             
              rspec (~> 3.9)
         
     | 
| 
       123 
     | 
    
         
            -
              rubocop
         
     | 
| 
      
 125 
     | 
    
         
            +
              rubocop (~> 1.10)
         
     | 
| 
       124 
126 
     | 
    
         
             
              slack_messaging!
         
     | 
| 
       125 
127 
     | 
    
         | 
| 
       126 
128 
     | 
    
         
             
            BUNDLED WITH
         
     | 
    
        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/lib/slack_messaging.rb
    CHANGED
    
    
| 
         @@ -36,21 +36,17 @@ module SlackMessaging 
     | 
|
| 
       36 
36 
     | 
    
         
             
                  File.exist?(default_config)
         
     | 
| 
       37 
37 
     | 
    
         
             
                end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                # rubocop:disable Metrics/MethodLength 
     | 
| 
      
 39 
     | 
    
         
            +
                # rubocop:disable Metrics/MethodLength
         
     | 
| 
       40 
40 
     | 
    
         
             
                def self.ask_config_questions
         
     | 
| 
       41 
41 
     | 
    
         
             
                  answers = {}
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                  answers[:webhook_url] = ask_question(
         
     | 
| 
       44 
44 
     | 
    
         
             
                    "What is your Slack webhook URL? If you don't have one yet, please navigate" \
         
     | 
| 
       45 
45 
     | 
    
         
             
                    ' to https://api.slack.com/messaging/webhooks to create one, and then come back' \
         
     | 
| 
       46 
     | 
    
         
            -
                    ' here and paste it in the Terminal.'
         
     | 
| 
      
 46 
     | 
    
         
            +
                    ' here and paste it in the Terminal.',
         
     | 
| 
      
 47 
     | 
    
         
            +
                    required: true
         
     | 
| 
       47 
48 
     | 
    
         
             
                  )
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                  unless answers[:webhook_url]
         
     | 
| 
       50 
     | 
    
         
            -
                    puts "\nExiting because Slack webhoook is required..."
         
     | 
| 
       51 
     | 
    
         
            -
                    exit
         
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
50 
     | 
    
         
             
                  answers[:channel] = ask_question(
         
     | 
| 
       55 
51 
     | 
    
         
             
                    "\nWhat slack channel do you wish to post to? (default is \"#general\")"
         
     | 
| 
       56 
52 
     | 
    
         
             
                  ) || 'general'
         
     | 
| 
         @@ -68,13 +64,25 @@ module SlackMessaging 
     | 
|
| 
       68 
64 
     | 
    
         
             
                end
         
     | 
| 
       69 
65 
     | 
    
         
             
                # rubocop:enable Metrics/MethodLength
         
     | 
| 
       70 
66 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
                 
     | 
| 
      
 67 
     | 
    
         
            +
                # rubocop:disable Metrics/MethodLength
         
     | 
| 
      
 68 
     | 
    
         
            +
                def self.ask_question(prompt, required: false)
         
     | 
| 
       72 
69 
     | 
    
         
             
                  answer = highline.ask(prompt)
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 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
         
     | 
| 
      
 79 
     | 
    
         
            +
                    answer.empty? ? nil : answer
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
       74 
81 
     | 
    
         
             
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
                # rubocop:enable Metrics/MethodLength
         
     | 
| 
       75 
83 
     | 
    
         | 
| 
       76 
84 
     | 
    
         
             
                def self.highline
         
     | 
| 
       77 
     | 
    
         
            -
                  @highline ||=  
     | 
| 
      
 85 
     | 
    
         
            +
                  @highline ||= HighlineWrapper.new
         
     | 
| 
       78 
86 
     | 
    
         
             
                end
         
     | 
| 
       79 
87 
     | 
    
         | 
| 
       80 
88 
     | 
    
         
             
                def self.default_config
         
     | 
| 
         @@ -28,20 +28,18 @@ describe SlackMessaging::NotifySlack do 
     | 
|
| 
       28 
28 
     | 
    
         
             
                SlackMessaging::Config.load(Faker::Lorem.word)
         
     | 
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
              subject { SlackMessaging::NotifySlack }
         
     | 
| 
      
 31 
     | 
    
         
            +
              subject { SlackMessaging::NotifySlack.new(sentence) }
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              it 'should call HTTParty' do
         
     | 
| 
       34 
34 
     | 
    
         
             
                expect(HTTParty).to receive(:post)
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                message.perform
         
     | 
| 
      
 35 
     | 
    
         
            +
                subject.perform
         
     | 
| 
       37 
36 
     | 
    
         
             
              end
         
     | 
| 
       38 
37 
     | 
    
         | 
| 
       39 
38 
     | 
    
         
             
              it 'should define certain values' do
         
     | 
| 
       40 
     | 
    
         
            -
                 
     | 
| 
       41 
     | 
    
         
            -
                expect( 
     | 
| 
       42 
     | 
    
         
            -
                expect( 
     | 
| 
       43 
     | 
    
         
            -
                expect( 
     | 
| 
       44 
     | 
    
         
            -
                expect( 
     | 
| 
       45 
     | 
    
         
            -
                expect(message.icon_emoji).to eq(emoji)
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(subject.text).to eq(sentence)
         
     | 
| 
      
 40 
     | 
    
         
            +
                expect(subject.channel).to eq(channel)
         
     | 
| 
      
 41 
     | 
    
         
            +
                expect(subject.username).to eq(username)
         
     | 
| 
      
 42 
     | 
    
         
            +
                expect(subject.webhook_url).to eq(webhook)
         
     | 
| 
      
 43 
     | 
    
         
            +
                expect(subject.icon_emoji).to eq(emoji)
         
     | 
| 
       46 
44 
     | 
    
         
             
              end
         
     | 
| 
       47 
45 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,8 +4,7 @@ require 'spec_helper' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'slack_messaging'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            describe SlackMessaging::Setup do
         
     | 
| 
       7 
     | 
    
         
            -
              let(: 
     | 
| 
       8 
     | 
    
         
            -
              let(:highline_cli) { double(:highline_cli, ask: response, ask_yes_no: true) }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:highline_wrapper) { double(:highline_wrapper, ask: Faker::Lorem.word, ask_yes_no: true) }
         
     | 
| 
       9 
8 
     | 
    
         
             
              let(:answers) do
         
     | 
| 
       10 
9 
     | 
    
         
             
                {
         
     | 
| 
       11 
10 
     | 
    
         
             
                  channel: Faker::Lorem.word,
         
     | 
| 
         @@ -16,7 +15,7 @@ describe SlackMessaging::Setup do 
     | 
|
| 
       16 
15 
     | 
    
         
             
              end
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
              before do
         
     | 
| 
       19 
     | 
    
         
            -
                allow( 
     | 
| 
      
 18 
     | 
    
         
            +
                allow(HighlineWrapper).to receive(:new).and_return(highline_wrapper)
         
     | 
| 
       20 
19 
     | 
    
         
             
                allow(subject).to receive(:puts)
         
     | 
| 
       21 
20 
     | 
    
         
             
              end
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
         @@ -30,7 +29,7 @@ describe SlackMessaging::Setup do 
     | 
|
| 
       30 
29 
     | 
    
         
             
                it 'should ask a question if the config file exists' do
         
     | 
| 
       31 
30 
     | 
    
         
             
                  allow(subject).to receive(:config_file_exists?).and_return(true)
         
     | 
| 
       32 
31 
     | 
    
         
             
                  allow(File).to receive(:exists?).and_return(true)
         
     | 
| 
       33 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(highline_wrapper).to receive(:ask_yes_no).and_return(true)
         
     | 
| 
       34 
33 
     | 
    
         
             
                  allow(subject).to receive(:create_or_update_config_file).and_return(true)
         
     | 
| 
       35 
34 
     | 
    
         
             
                  allow(subject).to receive(:ask_config_questions).and_return(true)
         
     | 
| 
       36 
35 
     | 
    
         
             
                  subject.execute
         
     | 
| 
         @@ -38,7 +37,7 @@ describe SlackMessaging::Setup do 
     | 
|
| 
       38 
37 
     | 
    
         | 
| 
       39 
38 
     | 
    
         
             
                it 'should call to create or update the config file' do
         
     | 
| 
       40 
39 
     | 
    
         
             
                  allow(File).to receive(:exists?).and_return(true)
         
     | 
| 
       41 
     | 
    
         
            -
                  allow( 
     | 
| 
      
 40 
     | 
    
         
            +
                  allow(highline_wrapper).to receive(:ask_yes_no).and_return(true)
         
     | 
| 
       42 
41 
     | 
    
         
             
                  expect(subject).to receive(:create_or_update_config_file).and_return(true)
         
     | 
| 
       43 
42 
     | 
    
         
             
                  expect(subject).to receive(:ask_config_questions).and_return(true)
         
     | 
| 
       44 
43 
     | 
    
         
             
                  subject.execute
         
     | 
| 
         @@ -47,7 +46,7 @@ describe SlackMessaging::Setup do 
     | 
|
| 
       47 
46 
     | 
    
         
             
                it 'should skip if the user opts not to continue' do
         
     | 
| 
       48 
47 
     | 
    
         
             
                  allow(subject).to receive(:config_file_exists?).and_return(true)
         
     | 
| 
       49 
48 
     | 
    
         
             
                  allow(File).to receive(:exists?).and_return(true)
         
     | 
| 
       50 
     | 
    
         
            -
                  allow( 
     | 
| 
      
 49 
     | 
    
         
            +
                  allow(highline_wrapper).to receive(:ask_yes_no).and_return(false)
         
     | 
| 
       51 
50 
     | 
    
         
             
                  expect(subject).not_to receive(:create_or_update_config_file)
         
     | 
| 
       52 
51 
     | 
    
         
             
                  expect(subject).not_to receive(:ask_config_questions)
         
     | 
| 
       53 
52 
     | 
    
         
             
                  subject.execute
         
     | 
| 
         @@ -88,49 +87,69 @@ describe SlackMessaging::Setup do 
     | 
|
| 
       88 
87 
     | 
    
         | 
| 
       89 
88 
     | 
    
         
             
              describe '#self.ask_question' do
         
     | 
| 
       90 
89 
     | 
    
         
             
                it 'should use highline to ask a question' do
         
     | 
| 
       91 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 90 
     | 
    
         
            +
                  expect(highline_wrapper).to receive(:ask).and_return('')
         
     | 
| 
       92 
91 
     | 
    
         
             
                  subject.send(:ask_question, Faker::Lorem.sentence)
         
     | 
| 
       93 
92 
     | 
    
         
             
                end
         
     | 
| 
       94 
93 
     | 
    
         | 
| 
       95 
94 
     | 
    
         
             
                it 'should return nil if the highline client gets an empty string' do
         
     | 
| 
       96 
     | 
    
         
            -
                  allow( 
     | 
| 
      
 95 
     | 
    
         
            +
                  allow(highline_wrapper).to receive(:ask).and_return('')
         
     | 
| 
       97 
96 
     | 
    
         
             
                  expect(subject.send(:ask_question, Faker::Lorem.sentence)).to be_nil
         
     | 
| 
       98 
97 
     | 
    
         
             
                end
         
     | 
| 
       99 
98 
     | 
    
         | 
| 
       100 
99 
     | 
    
         
             
                it 'should return the answer if it is given' do
         
     | 
| 
       101 
100 
     | 
    
         
             
                  answer = Faker::Lorem.sentence
         
     | 
| 
       102 
     | 
    
         
            -
                  allow( 
     | 
| 
      
 101 
     | 
    
         
            +
                  allow(highline_wrapper).to receive(:ask).and_return(answer)
         
     | 
| 
       103 
102 
     | 
    
         
             
                  expect(subject.send(:ask_question, Faker::Lorem.sentence)).to be(answer)
         
     | 
| 
       104 
103 
     | 
    
         
             
                end
         
     | 
| 
       105 
104 
     | 
    
         
             
              end
         
     | 
| 
       106 
105 
     | 
    
         | 
| 
       107 
106 
     | 
    
         
             
              describe '#self.ask_config_questions' do
         
     | 
| 
       108 
107 
     | 
    
         
             
                it 'should call to ask at least four questions' do
         
     | 
| 
       109 
     | 
    
         
            -
                  expect(subject).to receive(:ask_question).at_least(4).times
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(subject).to receive(:ask_question).at_least(4).times.and_return(Faker::Lorem.word)
         
     | 
| 
       110 
109 
     | 
    
         
             
                  subject.send(:ask_config_questions)
         
     | 
| 
       111 
110 
     | 
    
         
             
                end
         
     | 
| 
       112 
111 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
                it 'should  
     | 
| 
       114 
     | 
    
         
            -
                  allow( 
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 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)
         
     | 
| 
       116 
129 
     | 
    
         
             
                end
         
     | 
| 
       117 
130 
     | 
    
         | 
| 
       118 
131 
     | 
    
         
             
                it 'should return the defaults if nothing is given' do
         
     | 
| 
       119 
132 
     | 
    
         
             
                  slack_url = Faker::Internet.url
         
     | 
| 
      
 133 
     | 
    
         
            +
                  defaults = {
         
     | 
| 
      
 134 
     | 
    
         
            +
                    channel: 'general',
         
     | 
| 
      
 135 
     | 
    
         
            +
                    username: "Let's Get Quoty",
         
     | 
| 
      
 136 
     | 
    
         
            +
                    webhook_url: slack_url,
         
     | 
| 
      
 137 
     | 
    
         
            +
                    icon_emoji: ':mailbox_with_mail:'
         
     | 
| 
      
 138 
     | 
    
         
            +
                  }
         
     | 
| 
       120 
139 
     | 
    
         
             
                  allow(subject).to receive(:ask_question).with(
         
     | 
| 
       121 
     | 
    
         
            -
                    " 
     | 
| 
       122 
     | 
    
         
            -
                     
     | 
| 
       123 
     | 
    
         
            -
                    ' here and paste it in the Terminal.'
         
     | 
| 
      
 140 
     | 
    
         
            +
                    "What is your Slack webhook URL? If you don't have one yet, please navigate to https://api.slack.com/messaging/webhooks to create one, and then come back here and paste it in the Terminal.",
         
     | 
| 
      
 141 
     | 
    
         
            +
                    required: true
         
     | 
| 
       124 
142 
     | 
    
         
             
                  ).and_return(slack_url)
         
     | 
| 
       125 
     | 
    
         
            -
                  allow(subject).to receive(:ask_question). 
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
                     
     | 
| 
       133 
     | 
    
         
            -
                  )
         
     | 
| 
      
 143 
     | 
    
         
            +
                  allow(subject).to receive(:ask_question).with(
         
     | 
| 
      
 144 
     | 
    
         
            +
                    "\nWhat slack channel do you wish to post to? (default is \"#general\")"
         
     | 
| 
      
 145 
     | 
    
         
            +
                  ).and_return(nil)
         
     | 
| 
      
 146 
     | 
    
         
            +
                  allow(subject).to receive(:ask_question).with(
         
     | 
| 
      
 147 
     | 
    
         
            +
                    "\nWhat slack username do you wish to post as? (default is \"Let's Get Quoty\")"
         
     | 
| 
      
 148 
     | 
    
         
            +
                  ).and_return(nil)
         
     | 
| 
      
 149 
     | 
    
         
            +
                  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:\")"
         
     | 
| 
      
 151 
     | 
    
         
            +
                  ).and_return(nil)
         
     | 
| 
      
 152 
     | 
    
         
            +
                  expect(subject.send(:ask_config_questions)).to eq(defaults)
         
     | 
| 
       134 
153 
     | 
    
         
             
                end
         
     | 
| 
       135 
154 
     | 
    
         
             
              end
         
     | 
| 
       136 
155 
     | 
    
         
             
            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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.1.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-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-03-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -53,19 +53,19 @@ dependencies: 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '4.1'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name:  
     | 
| 
      
 56 
     | 
    
         
            +
              name: highline_wrapper
         
     | 
| 
       57 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
59 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
     | 
    
         
            -
                    version:  
     | 
| 
      
 61 
     | 
    
         
            +
                    version: 0.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:  
     | 
| 
      
 68 
     | 
    
         
            +
                    version: 0.1.0
         
     | 
| 
       69 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
70 
     | 
    
         
             
              name: httparty
         
     | 
| 
       71 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -196,16 +196,16 @@ dependencies: 
     | 
|
| 
       196 
196 
     | 
    
         
             
              name: rubocop
         
     | 
| 
       197 
197 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       198 
198 
     | 
    
         
             
                requirements:
         
     | 
| 
       199 
     | 
    
         
            -
                - - " 
     | 
| 
      
 199 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       200 
200 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       201 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 201 
     | 
    
         
            +
                    version: '1.10'
         
     | 
| 
       202 
202 
     | 
    
         
             
              type: :development
         
     | 
| 
       203 
203 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       204 
204 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       205 
205 
     | 
    
         
             
                requirements:
         
     | 
| 
       206 
     | 
    
         
            -
                - - " 
     | 
| 
      
 206 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       207 
207 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       208 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 208 
     | 
    
         
            +
                    version: '1.10'
         
     | 
| 
       209 
209 
     | 
    
         
             
            description: Sending Personalized Slack Messages to a Slack channel of your choice.
         
     | 
| 
       210 
210 
     | 
    
         
             
            email:
         
     | 
| 
       211 
211 
     | 
    
         
             
            executables:
         
     | 
| 
         @@ -224,14 +224,12 @@ files: 
     | 
|
| 
       224 
224 
     | 
    
         
             
            - lib/slack_messaging.rb
         
     | 
| 
       225 
225 
     | 
    
         
             
            - lib/slack_messaging/config.rb
         
     | 
| 
       226 
226 
     | 
    
         
             
            - lib/slack_messaging/default_paths.rb
         
     | 
| 
       227 
     | 
    
         
            -
            - lib/slack_messaging/highline_cli.rb
         
     | 
| 
       228 
227 
     | 
    
         
             
            - lib/slack_messaging/notify_slack.rb
         
     | 
| 
       229 
228 
     | 
    
         
             
            - lib/slack_messaging/random_message.rb
         
     | 
| 
       230 
229 
     | 
    
         
             
            - lib/slack_messaging/send.rb
         
     | 
| 
       231 
230 
     | 
    
         
             
            - lib/slack_messaging/setup.rb
         
     | 
| 
       232 
231 
     | 
    
         
             
            - lib/slack_messaging/version.rb
         
     | 
| 
       233 
232 
     | 
    
         
             
            - spec/slack_messaging/config_spec.rb
         
     | 
| 
       234 
     | 
    
         
            -
            - spec/slack_messaging/highline_cli_spec.rb
         
     | 
| 
       235 
233 
     | 
    
         
             
            - spec/slack_messaging/notify_slack_spec.rb
         
     | 
| 
       236 
234 
     | 
    
         
             
            - spec/slack_messaging/random_message_spec.rb
         
     | 
| 
       237 
235 
     | 
    
         
             
            - spec/slack_messaging/setup_spec.rb
         
     | 
| 
         @@ -262,7 +260,6 @@ summary: Personalized Slack Messages 
     | 
|
| 
       262 
260 
     | 
    
         
             
            test_files:
         
     | 
| 
       263 
261 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       264 
262 
     | 
    
         
             
            - spec/slack_messaging/config_spec.rb
         
     | 
| 
       265 
     | 
    
         
            -
            - spec/slack_messaging/highline_cli_spec.rb
         
     | 
| 
       266 
263 
     | 
    
         
             
            - spec/slack_messaging/notify_slack_spec.rb
         
     | 
| 
       267 
264 
     | 
    
         
             
            - spec/slack_messaging/random_message_spec.rb
         
     | 
| 
       268 
265 
     | 
    
         
             
            - spec/slack_messaging/setup_spec.rb
         
     | 
| 
         @@ -1,35 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module SlackMessaging
         
     | 
| 
       4 
     | 
    
         
            -
              class HighlineCli
         
     | 
| 
       5 
     | 
    
         
            -
                def ask(prompt)
         
     | 
| 
       6 
     | 
    
         
            -
                  highline_client.ask(prompt) do |conf|
         
     | 
| 
       7 
     | 
    
         
            -
                    conf.readline = true
         
     | 
| 
       8 
     | 
    
         
            -
                  end.to_s
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def ask_yes_no(prompt)
         
     | 
| 
       12 
     | 
    
         
            -
                  answer = highline_client.ask(prompt) do |conf|
         
     | 
| 
       13 
     | 
    
         
            -
                    conf.readline = true
         
     | 
| 
       14 
     | 
    
         
            -
                  end.to_s
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  answer.empty? ? true : !!(answer =~ /^y/i)
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                def ask_options(prompt, choices)
         
     | 
| 
       20 
     | 
    
         
            -
                  choices_as_string_options = ''.dup
         
     | 
| 
       21 
     | 
    
         
            -
                  choices.each { |choice| choices_as_string_options << "#{choices.index(choice) + 1}. #{choice}\n" }
         
     | 
| 
       22 
     | 
    
         
            -
                  compiled_prompt = "#{prompt}\n#{choices_as_string_options.strip}"
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  index = highline_client.ask(compiled_prompt) do |conf|
         
     | 
| 
       25 
     | 
    
         
            -
                    conf.readline = true
         
     | 
| 
       26 
     | 
    
         
            -
                  end.to_i - 1
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                  choices[index]
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                private def highline_client
         
     | 
| 
       32 
     | 
    
         
            -
                  @highline_client ||= HighLine.new
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
       35 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,51 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'slack_messaging'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            describe SlackMessaging::HighlineCli do
         
     | 
| 
       7 
     | 
    
         
            -
              let(:response) { double(:response, readline: true, to_i: 3) }
         
     | 
| 
       8 
     | 
    
         
            -
              let(:highline_client) { double(:highline_cli, ask: response) }
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              before do
         
     | 
| 
       11 
     | 
    
         
            -
                allow(HighLine).to receive(:new).and_return(highline_client)
         
     | 
| 
       12 
     | 
    
         
            -
              end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
              describe '#ask' do
         
     | 
| 
       15 
     | 
    
         
            -
                it 'should ask the highline client ask' do
         
     | 
| 
       16 
     | 
    
         
            -
                  expect(highline_client).to receive(:ask)
         
     | 
| 
       17 
     | 
    
         
            -
                  subject.ask(Faker::Lorem.sentence)
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                it 'should return a string' do
         
     | 
| 
       21 
     | 
    
         
            -
                  expect(subject.ask(Faker::Lorem.sentence)).to be_a(String)
         
     | 
| 
       22 
     | 
    
         
            -
                end
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
              describe '#ask_yes_no' do
         
     | 
| 
       26 
     | 
    
         
            -
                it 'should ask the highline client ask' do
         
     | 
| 
       27 
     | 
    
         
            -
                  expect(highline_client).to receive(:ask)
         
     | 
| 
       28 
     | 
    
         
            -
                  subject.ask_yes_no(Faker::Lorem.sentence)
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                it 'should return a boolean' do
         
     | 
| 
       32 
     | 
    
         
            -
                  expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_falsey
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                it 'should return true if we say yes' do
         
     | 
| 
       36 
     | 
    
         
            -
                  allow(response).to receive(:to_s).and_return('y')
         
     | 
| 
       37 
     | 
    
         
            -
                  expect(subject.ask_yes_no(Faker::Lorem.sentence)).to be_truthy
         
     | 
| 
       38 
     | 
    
         
            -
                end
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              describe '#ask_options' do
         
     | 
| 
       42 
     | 
    
         
            -
                it 'should ask the highline client ask' do
         
     | 
| 
       43 
     | 
    
         
            -
                  expect(highline_client).to receive(:ask)
         
     | 
| 
       44 
     | 
    
         
            -
                  subject.ask_options(Faker::Lorem.sentence, %w[one two three])
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                it 'should return a string from the options' do
         
     | 
| 
       48 
     | 
    
         
            -
                  expect(subject.ask_options(Faker::Lorem.sentence, %w[one two three])).to be_a(String)
         
     | 
| 
       49 
     | 
    
         
            -
                end
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
            end
         
     |