slack_messaging 1.2.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 +107 -0
- data/Guardfile +5 -0
- data/{LICENSE.txt → LICENSE} +1 -1
- data/README.md +31 -19
- data/Rakefile +1 -2
- data/bin/slack-messaging +6 -1
- data/lib/slack_messaging.rb +9 -7
- data/lib/slack_messaging/config.rb +17 -38
- data/lib/slack_messaging/default_paths.rb +13 -0
- data/lib/slack_messaging/notify_slack.rb +10 -11
- data/lib/slack_messaging/random_message.rb +5 -29
- data/lib/slack_messaging/slack.rb +22 -0
- data/lib/slack_messaging/version.rb +1 -1
- data/spec/slack_messaging/config_spec.rb +42 -33
- data/spec/slack_messaging/notify_slack_spec.rb +38 -29
- data/spec/slack_messaging/random_message_spec.rb +41 -24
- data/spec/spec_helper.rb +5 -5
- metadata +86 -57
- data/.codeclimate.yml +0 -37
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.gitignore +0 -18
- data/.octopolo.yml +0 -4
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.soyuz.yml +0 -12
- data/.travis.yml +0 -23
- data/CHANGELOG.markdown +0 -11
- data/CODE_OF_CONDUCT.md +0 -76
- data/CONTRIBUTING.md +0 -11
- data/lib/slack_messaging/commands/slack.rb +0 -7
- data/lib/slack_messaging/output.rb +0 -13
- data/lib/slack_messaging/scripts/slack.rb +0 -29
- data/slack_messaging.gemspec +0 -32
@@ -1,44 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'slack_messaging'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
describe SlackMessaging::Config do
|
5
|
+
context 'config key methods' do
|
6
|
+
it 'should return nil when not set' do
|
7
|
+
expect(SlackMessaging::Config.doesnt_exist).to eql(nil)
|
8
|
+
expect(SlackMessaging::Config.doesnt_exist?).to eql(false)
|
9
|
+
end
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
it "should return the config value when set" do
|
13
|
-
SlackMessaging::Config.new_value = "testing"
|
14
|
-
expect(SlackMessaging::Config.new_value).to eql("testing")
|
15
|
-
end
|
11
|
+
it 'should return the config value when set' do
|
12
|
+
config_value = Faker::Lorem.word
|
13
|
+
SlackMessaging::Config.new_value = config_value
|
14
|
+
expect(SlackMessaging::Config.new_value).to eql(config_value)
|
16
15
|
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
context 'after loading a config file' do
|
19
|
+
let(:domain) { Faker::Internet.domain_name }
|
20
|
+
let(:sentence) { Faker::Lorem.sentence }
|
21
|
+
|
22
|
+
let(:config_file) do
|
23
|
+
{
|
24
|
+
'domain': domain,
|
25
|
+
'slack': {
|
26
|
+
'slack_option': true,
|
27
|
+
'username': Faker::Name.name,
|
28
|
+
'icon_url': Faker::Internet.url,
|
29
|
+
'channel': Faker::Lorem.word,
|
30
|
+
'webhook': Faker::Internet.url
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
before do
|
36
|
+
allow(YAML).to receive(:load_file).and_return(config_file)
|
37
|
+
allow(File).to receive(:exist?).and_return(true)
|
38
|
+
SlackMessaging::Config.load(Faker::Lorem.word)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'calling a method corresponding to a key in the file should return the value' do
|
42
|
+
expect(SlackMessaging::Config.domain).to eql(domain)
|
43
|
+
expect(SlackMessaging::Config.slack).to be_kind_of(Hash)
|
44
|
+
expect(SlackMessaging::Config.slack[:slack_option]).to eql(true)
|
45
|
+
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
47
|
+
it 'overwriting values should work' do
|
48
|
+
expect(SlackMessaging::Config.slack).to be_kind_of(Hash)
|
49
|
+
SlackMessaging::Config.slack = sentence
|
50
|
+
expect(SlackMessaging::Config.slack).to eql(sentence)
|
42
51
|
end
|
43
52
|
end
|
44
53
|
end
|
@@ -1,34 +1,43 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'slack_messaging'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
"icon_emoji" => ":wine_glass:"}
|
10
|
-
}
|
11
|
-
allow(YAML).to receive(:load_file).and_return(config_file)
|
12
|
-
allow(File).to receive(:exist?).and_return(true)
|
13
|
-
SlackMessaging::Config.load("dummy/path")
|
14
|
-
end
|
4
|
+
describe SlackMessaging::NotifySlack do
|
5
|
+
let(:sentence) { Faker::Lorem.sentence }
|
6
|
+
let(:channel) { Faker::Lorem.word }
|
7
|
+
let(:username) { Faker::Name.name }
|
8
|
+
let(:webhook) { Faker::Internet.url }
|
9
|
+
let(:emoji) { Faker::Internet.url }
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
let(:config_file) do
|
12
|
+
{
|
13
|
+
'slack': {
|
14
|
+
'slack_option': true,
|
15
|
+
'username': username,
|
16
|
+
'icon_emoji': emoji,
|
17
|
+
'channel': channel,
|
18
|
+
'webhook_url': webhook
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
allow(YAML).to receive(:load_file).and_return(config_file)
|
25
|
+
allow(File).to receive(:exist?).and_return(true)
|
26
|
+
SlackMessaging::Config.load(Faker::Lorem.word)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should call HTTParty' do
|
30
|
+
expect(HTTParty).to receive(:post)
|
31
|
+
message = SlackMessaging::NotifySlack.new(sentence)
|
32
|
+
message.perform
|
33
|
+
end
|
23
34
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
35
|
+
it 'should define certain values' do
|
36
|
+
message = SlackMessaging::NotifySlack.new(sentence)
|
37
|
+
expect(message.text).to eq(sentence)
|
38
|
+
expect(message.channel).to eq(channel)
|
39
|
+
expect(message.username).to eq(username)
|
40
|
+
expect(message.webhook_url).to eq(webhook)
|
41
|
+
expect(message.icon_emoji).to eq(emoji)
|
33
42
|
end
|
34
43
|
end
|
@@ -1,26 +1,43 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'slack_messaging'
|
3
|
+
|
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
|
+
|
19
|
+
it 'should get a string message' do
|
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)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should get a message that includes a —' do
|
30
|
+
message = SlackMessaging::RandomMessage.acquire_random_quote
|
31
|
+
expect(message.include?('—')).to eq(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should use HTTParty to ping an API' do
|
35
|
+
expect(HTTParty).to receive(:get)
|
36
|
+
SlackMessaging::RandomMessage.acquire_random_quote
|
37
|
+
end
|
38
|
+
|
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
|
25
42
|
end
|
26
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter '/spec/'
|
5
|
-
end
|
1
|
+
require 'faker'
|
2
|
+
require 'pry'
|
6
3
|
|
7
4
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
8
5
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
@@ -37,6 +34,9 @@ RSpec.configure do |config|
|
|
37
34
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
38
35
|
end
|
39
36
|
|
37
|
+
config.filter_run :focus => true
|
38
|
+
config.run_all_when_everything_filtered = true
|
39
|
+
|
40
40
|
# rspec-mocks config goes here. You can use an alternate test double
|
41
41
|
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
42
42
|
config.mock_with :rspec do |mocks|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emma Sax
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,105 +39,119 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '4.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '4.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: highline
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rack
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: '2.2'
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: '2.2'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1
|
117
|
+
version: '2.1'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1
|
124
|
+
version: '2.1'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: faker
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec
|
140
|
+
name: guard-rspec
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: '4.3'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: '4.3'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: pry
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
@@ -150,7 +164,35 @@ dependencies:
|
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
|
-
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '13.0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '13.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '3.9'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '3.9'
|
195
|
+
description: Sending Personalized Slack Messages to a Slack channel of your choice.
|
154
196
|
email:
|
155
197
|
- emma.sax4@gmail.com
|
156
198
|
executables:
|
@@ -158,43 +200,30 @@ executables:
|
|
158
200
|
extensions: []
|
159
201
|
extra_rdoc_files: []
|
160
202
|
files:
|
161
|
-
- ".codeclimate.yml"
|
162
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
163
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
164
|
-
- ".gitignore"
|
165
|
-
- ".octopolo.yml"
|
166
|
-
- ".rspec"
|
167
|
-
- ".ruby-gemset"
|
168
|
-
- ".ruby-version"
|
169
|
-
- ".soyuz.yml"
|
170
|
-
- ".travis.yml"
|
171
|
-
- CHANGELOG.markdown
|
172
|
-
- CODE_OF_CONDUCT.md
|
173
|
-
- CONTRIBUTING.md
|
174
203
|
- Gemfile
|
175
|
-
-
|
204
|
+
- Gemfile.lock
|
205
|
+
- Guardfile
|
206
|
+
- LICENSE
|
176
207
|
- OutputFile.png
|
177
208
|
- README.md
|
178
209
|
- Rakefile
|
179
210
|
- bin/slack-messaging
|
180
211
|
- lib/slack_messaging.rb
|
181
|
-
- lib/slack_messaging/commands/slack.rb
|
182
212
|
- lib/slack_messaging/config.rb
|
213
|
+
- lib/slack_messaging/default_paths.rb
|
183
214
|
- lib/slack_messaging/notify_slack.rb
|
184
|
-
- lib/slack_messaging/output.rb
|
185
215
|
- lib/slack_messaging/random_message.rb
|
186
|
-
- lib/slack_messaging/
|
216
|
+
- lib/slack_messaging/slack.rb
|
187
217
|
- lib/slack_messaging/version.rb
|
188
|
-
- slack_messaging.gemspec
|
189
218
|
- spec/slack_messaging/config_spec.rb
|
190
219
|
- spec/slack_messaging/notify_slack_spec.rb
|
191
220
|
- spec/slack_messaging/random_message_spec.rb
|
192
221
|
- spec/spec_helper.rb
|
193
|
-
homepage: https://github.com/
|
222
|
+
homepage: https://github.com/emmasax4/slack_messaging
|
194
223
|
licenses:
|
195
224
|
- MIT
|
196
225
|
metadata: {}
|
197
|
-
post_install_message:
|
226
|
+
post_install_message:
|
198
227
|
rdoc_options: []
|
199
228
|
require_paths:
|
200
229
|
- lib
|
@@ -209,12 +238,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
238
|
- !ruby/object:Gem::Version
|
210
239
|
version: '0'
|
211
240
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
213
|
-
signing_key:
|
241
|
+
rubygems_version: 3.1.4
|
242
|
+
signing_key:
|
214
243
|
specification_version: 4
|
215
|
-
summary:
|
244
|
+
summary: Personalized Slack Messages
|
216
245
|
test_files:
|
246
|
+
- spec/spec_helper.rb
|
217
247
|
- spec/slack_messaging/config_spec.rb
|
218
|
-
- spec/slack_messaging/notify_slack_spec.rb
|
219
248
|
- spec/slack_messaging/random_message_spec.rb
|
220
|
-
- spec/
|
249
|
+
- spec/slack_messaging/notify_slack_spec.rb
|