slack_messaging 1.4.0 → 2.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.lock +4 -1
- data/README.md +1 -1
- data/lib/slack_messaging.rb +1 -0
- data/lib/slack_messaging/random_message.rb +5 -25
- data/lib/slack_messaging/slack.rb +4 -2
- data/lib/slack_messaging/version.rb +1 -1
- data/spec/slack_messaging/random_message_spec.rb +30 -11
- data/spec/spec_helper.rb +1 -0
- metadata +30 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db2a04a6f53bd5e7d0d1017fe6fd5f6c715cc89d108be3dad1eb3a433f944be0
|
|
4
|
+
data.tar.gz: 5487fbcfcf279a48911d773c928826b8f7b2e021710d457c0fa256fa1660562e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76485ac006bb26c047e57e06283ced474b36c5924229dbd58b83a3ea8e2e30e92e8ca916fb7fd24b538ad235a54f427f29e03e4f1dcff382b57eb69d7b71e578
|
|
7
|
+
data.tar.gz: fe229444fe0b9a050d29a6b8c2fc653f287b85d49f965efc76cc81b5f7f3eb677fd79376a0fff012460febc1cd61d4896e9b6f0cf2098557b7a34130de155c42
|
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
slack_messaging (
|
|
4
|
+
slack_messaging (2.0.0.pre.test)
|
|
5
5
|
activesupport (~> 6.0)
|
|
6
6
|
gli (~> 2.10)
|
|
7
7
|
hashie (~> 4.1)
|
|
8
8
|
highline (~> 2.0)
|
|
9
9
|
httparty
|
|
10
|
+
json
|
|
10
11
|
rack (~> 2.2)
|
|
11
12
|
|
|
12
13
|
GEM
|
|
@@ -47,6 +48,7 @@ GEM
|
|
|
47
48
|
multi_xml (>= 0.5.2)
|
|
48
49
|
i18n (1.8.5)
|
|
49
50
|
concurrent-ruby (~> 1.0)
|
|
51
|
+
json (2.3.1)
|
|
50
52
|
listen (3.3.1)
|
|
51
53
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
52
54
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
@@ -96,6 +98,7 @@ DEPENDENCIES
|
|
|
96
98
|
bundler (~> 2.1)
|
|
97
99
|
faker
|
|
98
100
|
guard-rspec (~> 4.3)
|
|
101
|
+
pry
|
|
99
102
|
rake (~> 13.0)
|
|
100
103
|
rspec (~> 3.9)
|
|
101
104
|
slack_messaging!
|
data/README.md
CHANGED
|
@@ -50,7 +50,7 @@ To print a friendly message to Slack, run:
|
|
|
50
50
|
slack-messaging slack
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
from the main directory. Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote
|
|
53
|
+
from the main directory. 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/).
|
|
54
54
|
|
|
55
55
|
However, what if you wanted to print something specific? Well, you can! Just run:
|
|
56
56
|
|
data/lib/slack_messaging.rb
CHANGED
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
module SlackMessaging
|
|
2
2
|
class RandomMessage
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"Whatever you are, be a good one.\n--Abraham Lincoln",
|
|
9
|
-
"Good, better, best. Never let it rest. 'Til your good is better and your better is best.\n--St. Jerome",
|
|
10
|
-
"Despite everything, I believe that people are really good at heart.\n--Anne Frank",
|
|
11
|
-
"Life is 10% what happens to you and 90% how you react to it.\n--Charles R. Swindoll",
|
|
12
|
-
"The way to get started is to quit talking and begin doing.\n--Walt Disney",
|
|
13
|
-
"A creative man is motivated by the desire to achieve, not by the desire to beat others.\n--Ayn Rand",
|
|
14
|
-
"Problems are not stop signs, they are guidelines.\n--Robert H. Schuller",
|
|
15
|
-
"Correction does much, but encouragement does more.\n--Johann Wolfgang von Goethe",
|
|
16
|
-
"Positive anything is better than negative nothing.\n--Elbert Hubbard",
|
|
17
|
-
"To succeed, you need to find something to hold on to, something to motivate you, something to inspire you.\n--Joyce Meyer",
|
|
18
|
-
"If you're not making mistakes, then you're not doing anything. I'm positive that a doer makes mistakes.\n--John Wooden",
|
|
19
|
-
"The best way to deal with other people is to just let them be other people.\n--Anonymous",
|
|
20
|
-
"Talk to yourself like you would to someone you love.\n--Brenee Brown",
|
|
21
|
-
"Don't let small minds convince you that your dreams are too big.\n--Anonymous",
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
attr_accessor :text
|
|
25
|
-
|
|
26
|
-
def initialize
|
|
27
|
-
self.text = MESSAGE_ARRAY[rand(MESSAGE_ARRAY.length)]
|
|
3
|
+
def self.acquire_random_quote
|
|
4
|
+
random_quote = HTTParty.get('http://api.quotable.io/random', headers: { 'Content-Type': 'application/json' }).body
|
|
5
|
+
quote_content = JSON.parse(random_quote)['content']
|
|
6
|
+
quote_author = JSON.parse(random_quote)['author']
|
|
7
|
+
return "\"#{quote_content}\"" + "\n" + "—#{quote_author}"
|
|
28
8
|
end
|
|
29
9
|
end
|
|
30
10
|
end
|
|
@@ -4,8 +4,8 @@ module SlackMessaging
|
|
|
4
4
|
|
|
5
5
|
def self.execute(args, options = nil)
|
|
6
6
|
if args.empty?
|
|
7
|
-
message = SlackMessaging::RandomMessage.
|
|
8
|
-
print_message(message
|
|
7
|
+
message = SlackMessaging::RandomMessage.acquire_random_quote
|
|
8
|
+
print_message(message)
|
|
9
9
|
else
|
|
10
10
|
args.each do |message|
|
|
11
11
|
print_message(message)
|
|
@@ -13,6 +13,8 @@ module SlackMessaging
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
private
|
|
17
|
+
|
|
16
18
|
def self.print_message(message)
|
|
17
19
|
SlackMessaging::NotifySlack.new(message).perform
|
|
18
20
|
end
|
|
@@ -2,23 +2,42 @@ require 'spec_helper'
|
|
|
2
2
|
require 'slack_messaging'
|
|
3
3
|
|
|
4
4
|
describe SlackMessaging::RandomMessage do
|
|
5
|
+
let(:quote_object) { double(:quote_object, body: quote_json) }
|
|
6
|
+
|
|
7
|
+
let(:quote_json) do
|
|
8
|
+
"{\"_id\":\"4MRaRRKq4Tcg\",
|
|
9
|
+
\"tags\":[\"famous-quotes\"],
|
|
10
|
+
\"content\":\"There are two ways of spreading light: to be the candle or the mirror that reflects it.\",
|
|
11
|
+
\"author\":\"Edith Wharton\",\"length\":87
|
|
12
|
+
}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
allow(HTTParty).to receive(:get).and_return(quote_object)
|
|
17
|
+
end
|
|
18
|
+
|
|
5
19
|
it 'should get a string message' do
|
|
6
|
-
message = SlackMessaging::RandomMessage.
|
|
7
|
-
expect(message
|
|
20
|
+
message = SlackMessaging::RandomMessage.acquire_random_quote
|
|
21
|
+
expect(message).to be_instance_of(String)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should get a message that includes a newline' do
|
|
25
|
+
message = SlackMessaging::RandomMessage.acquire_random_quote
|
|
26
|
+
expect(message.include?("\n")).to eq(true)
|
|
8
27
|
end
|
|
9
28
|
|
|
10
|
-
it 'should get a message
|
|
11
|
-
message = SlackMessaging::RandomMessage.
|
|
12
|
-
expect(message.
|
|
29
|
+
it 'should get a message that includes a —' do
|
|
30
|
+
message = SlackMessaging::RandomMessage.acquire_random_quote
|
|
31
|
+
expect(message.include?('—')).to eq(true)
|
|
13
32
|
end
|
|
14
33
|
|
|
15
|
-
it 'should
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
it 'should use HTTParty to ping an API' do
|
|
35
|
+
expect(HTTParty).to receive(:get)
|
|
36
|
+
SlackMessaging::RandomMessage.acquire_random_quote
|
|
18
37
|
end
|
|
19
38
|
|
|
20
|
-
it 'should
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
it 'should have the JSON parse the response content twice' do
|
|
40
|
+
expect(JSON).to receive(:parse).at_least(2).times.and_return(JSON.parse(quote_json))
|
|
41
|
+
SlackMessaging::RandomMessage.acquire_random_quote
|
|
23
42
|
end
|
|
24
43
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 2.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: 2020-11-
|
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: json
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: rack
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +150,20 @@ dependencies:
|
|
|
136
150
|
- - "~>"
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
152
|
version: '4.3'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: pry
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
139
167
|
- !ruby/object:Gem::Dependency
|
|
140
168
|
name: rake
|
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|