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 +4 -4
- data/README.md +9 -1
- data/lib/lita/handlers/bacon_ipsum.rb +24 -7
- data/lita-bacon-ipsum.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bfe865f1135a2425f3a80372dda10c89631b694
|
4
|
+
data.tar.gz: acc20422b6f0df09b33b6c693f8c4cf8abe966d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: 
|
20
|
+
|
21
|
+
_(optional)_
|
22
|
+
User: lita give me bacon image 800 by 1000
|
23
|
+
Lita: 
|
24
|
+
|
@@ -1,20 +1,37 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
3
|
class BaconIpsum < Handler
|
4
|
-
|
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
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
data/lita-bacon-ipsum.gemspec
CHANGED