lita-bacon-ipsum 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1936babda0a71a1ea10bab750473c0eb9689e03
4
- data.tar.gz: cc29edc12dd7226ed0040571843ea9ca4a505c3b
3
+ metadata.gz: 8bfe865f1135a2425f3a80372dda10c89631b694
4
+ data.tar.gz: acc20422b6f0df09b33b6c693f8c4cf8abe966d2
5
5
  SHA512:
6
- metadata.gz: d15949b1ad56bbaf7d6f6e3fbd8580f7c5e07964116d369f8b761206ac9aaf8786ad3a8f3e3a94bd82440e1013d1d98a58e4b19ea78803d3c43c421b4fdca638
7
- data.tar.gz: 70d1dad8b5ebea79e7438f97da203f459a049d228e2261f7809ba2d177700508faac6abb586f8973299bc2a34ed576e80148308bc6805191854c471fac235f07
6
+ metadata.gz: 9254b48f2ff2c3e9e621b925b81287fc258ddcedd142645caafcdc5ab1f6b2e77de26436d6ba99bc94a9a1b614dd55829885039bc368f14d455fc4452fee8aab
7
+ data.tar.gz: e9cc0db27e33388928d41e6f2a0d2cbc737eb88708de30c5d50020fc56190ea9830af6a7b807b9a4b38716fa9b07edd7c610b23ab041bd4a7f1d2843e2e5072e
data/README.md CHANGED
@@ -12,5 +12,13 @@ gem "lita-bacon-ipsum"
12
12
 
13
13
  ## Usage
14
14
 
15
- User: lita give me bacon
15
+ User: lita give me bacon text
16
16
  Lita: Bacon ipsum dolor amet...
17
+
18
+ User: lita give me bacon image
19
+ Lita: ![600 by 200 Bacon](https://baconmockup.com/600/200/ "600 by 200 Bacon")
20
+
21
+ _(optional)_
22
+ User: lita give me bacon image 800 by 1000
23
+ Lita: ![800 by 1000 Bacon](https://baconmockup.com/800/1000/ "800 by 1000 Bacon")
24
+
@@ -1,20 +1,37 @@
1
1
  module Lita
2
2
  module Handlers
3
3
  class BaconIpsum < Handler
4
- route(/give me bacon/i, :bacon_ipsum, command: true, help: {
4
+
5
+ ## Bacon Text
6
+ route(/give me bacon text/i, :bacon_ipsum_text, command: true, help: {
5
7
  "give me bacon" => "Bacon ipsum dolor amet..."
6
8
  })
7
9
 
8
- def bacon_ipsum(response)
10
+ def bacon_ipsum_text(response)
9
11
  resp = http.get "https://baconipsum.com/api/?type=all-meat&start-with-lorem=1"
12
+
13
+ raise 'BaconFail' unless resp.status == 200
10
14
 
11
15
  bacon = MultiJson.load(resp.body)
12
16
 
13
- if bacon
14
- response.reply bacon[0]
15
- else
16
- response.reply "Sorry, I was unable to retreive bacon for you."
17
- end
17
+ response.reply ">>>#{bacon[0]}"
18
+ rescue
19
+ response.reply "Sorry, I was unable to retreive bacon for you."
20
+ end
21
+
22
+ ## Bacon Images
23
+ route(/give me bacon image ((?<width>\d+) by (?<height>\d+))?/i, :bacon_ipsum_image, command: true, help: {
24
+ "give me bacon image WIDTH by HEIGHT" => "Gives bacon image based on WIDTH and HEIGHT"
25
+ })
26
+
27
+ def bacon_ipsum_image(response)
28
+ random = rand((100...1000).step(100))
29
+ height = response.match_data[:height] ||= random
30
+ width = response.match_data[:width] ||= random
31
+
32
+ response.reply "<http://baconmockup.com/#{width}/#{height}|#{width} by #{height} Bacon>"
33
+ rescue
34
+ response.reply "Sorry, I was unable to retreive bacon for you."
18
35
  end
19
36
 
20
37
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-bacon-ipsum"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.1.4"
4
4
  spec.authors = ["Chris Mikelson"]
5
5
  spec.email = ["chrismikelson@gmail.com"]
6
6
  spec.description = "Get bacon ipsum text from Lita."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-bacon-ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mikelson