lita-ship-to-pastebin 0.1.0 → 0.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e6d58e09ef53b34950b5a1e6ee0312b928aeaa
|
4
|
+
data.tar.gz: 9cdc59f302037d77cf3c9871eec5463776b791b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 551796a9acb41784457e6083d688dc46ece1ddef1b5652cb2ee6ce2cab69385347a9e66d4cd0b2c6f6df08d7103b5483f483a1df8bc52b2fab9eacb5878897f7
|
7
|
+
data.tar.gz: 43e23d3c6a4d7adce89b52f846a31bc36a3950643644a622faf0ba30c265abe7819abce7927ddf43fc84f68de9dda610600f7d3992e536c081e467ab7043ad47
|
@@ -7,34 +7,29 @@ module Lita
|
|
7
7
|
PASTEBIN_API_KEY = 'd88582e90ba06b60569dc55ab5b678ce'
|
8
8
|
PASTEBIN_URL = 'https://pastebin.com/api/api_post.php'
|
9
9
|
|
10
|
+
PasteBinError = Class.new(StandardError)
|
11
|
+
|
10
12
|
def hi(name)
|
11
13
|
name
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
name = 'slippy'
|
16
|
-
|
16
|
+
def save_to_pastebin(message, title: "Lita's Wall of Text")
|
17
17
|
begin
|
18
18
|
result = Faraday.post PASTEBIN_URL, {
|
19
19
|
api_dev_key: PASTEBIN_API_KEY,
|
20
|
-
api_paste_name:
|
21
|
-
api_paste_code:
|
22
|
-
api_option: 'paste'
|
20
|
+
api_paste_name: title,
|
21
|
+
api_paste_code: message,
|
22
|
+
api_option: 'paste'
|
23
23
|
}
|
24
24
|
rescue Faraday::Error => err
|
25
25
|
raise ConnectionError, err.message
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
parsed = JSON.parse(result.body)
|
32
|
-
|
33
|
-
if parsed.keys.include?('error_message')
|
34
|
-
raise(ImgflipApiError, parsed['error_message'])
|
28
|
+
if !result.success? || result.body.include?('Bad API')
|
29
|
+
raise PasteBinError, result.body
|
35
30
|
end
|
36
31
|
|
37
|
-
|
32
|
+
result.body
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-ship-to-pastebin"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.1"
|
4
4
|
spec.authors = ["Daniel J. Pritchett"]
|
5
5
|
spec.email = ["dpritchett@gmail.com"]
|
6
6
|
spec.description = "Expose helper method to pastebin-ify any input text"
|
@@ -9,10 +9,8 @@ describe Lita::Extensions::ShipToPastebin, lita: true do
|
|
9
9
|
expect(actual).to eq canary
|
10
10
|
end
|
11
11
|
|
12
|
-
it '
|
13
|
-
|
14
|
-
actual
|
15
|
-
|
16
|
-
expect(1).to eq 2
|
12
|
+
it 'saves text to pastebin' do
|
13
|
+
actual = subject.save_to_pastebin 'hey john', title: 'hey there john'
|
14
|
+
expect(actual).to match /https:\/\/pastebin/
|
17
15
|
end
|
18
16
|
end
|