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: ec22241813087110104e20099a63e27acdbbd333
4
- data.tar.gz: e38ea3bfeb32b2e1ea79107f73da2e3e50da9532
3
+ metadata.gz: 33e6d58e09ef53b34950b5a1e6ee0312b928aeaa
4
+ data.tar.gz: 9cdc59f302037d77cf3c9871eec5463776b791b8
5
5
  SHA512:
6
- metadata.gz: d4ca991a24b4f1ff1487009acc70e12c5f0887b9772231bfd24e334915d06ef5c3ccba2bb5668f30fa91e6c908578d7703fce1cd28ec7e583f952d013e223544
7
- data.tar.gz: f1295c5bf3527eedc2bda83339713af0d94a61609af6f166870defd4d4cd1f6dd1b985332e152c711d6d0ad5cef89b84ee207167180a307f8d08535565c11365
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 do_a_barrel_roll
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: 'john dot mem',
21
- api_paste_code: 'just call me the body oh em jeez',
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
- # plz notice me rake
29
- binding.pry
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
- image = parsed.fetch('data', {}).fetch('url')
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.0"
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 'does a barrel roll' do
13
- canary = 'idk'
14
- actual = subject.do_a_barrel_roll
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-ship-to-pastebin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Pritchett