lita-onewheel-giphy 0.1.0 → 0.2.0
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: 87bf989426f15b16c3d57062f3739d84da6a7655
|
4
|
+
data.tar.gz: a9bd4f871b05bf5920f3ba62acee82caf6f2d103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9f59dd5391fd1dc88afe7731a69f86ca479be4830985cb3b16ee400f678cc24981102671f75d331e12d44cd69305c043f52b3ecbda002d21938f874ce24805
|
7
|
+
data.tar.gz: d9daed5ab853d4a9c3118946c6917f838c272ac6907b4187c05b9be99ed8b383f6e6183a7c38116d7e3bd8e5c1b1edff00da9c0621d297dec7ec44eae25c84c8
|
@@ -10,6 +10,7 @@ module Lita
|
|
10
10
|
|
11
11
|
route /^giphy$/, :random, command: true
|
12
12
|
route /^giphy\s+(.*)$/, :search, command: true
|
13
|
+
route /^giphytrending$/, :trending, command: true
|
13
14
|
|
14
15
|
def search(response)
|
15
16
|
keywords = response.matches[0][0]
|
@@ -26,6 +27,13 @@ module Lita
|
|
26
27
|
response.reply image
|
27
28
|
end
|
28
29
|
|
30
|
+
def trending(response)
|
31
|
+
uri = get_trending_uri
|
32
|
+
giphy_data = call_giphy(uri)
|
33
|
+
image = get_random(giphy_data.body)
|
34
|
+
response.reply image
|
35
|
+
end
|
36
|
+
|
29
37
|
def get_search_uri(keywords)
|
30
38
|
# q - search query term or phrase
|
31
39
|
# limit - (optional) number of results to return, maximum 100. Default 25.
|
@@ -42,6 +50,13 @@ module Lita
|
|
42
50
|
config.api_uri + 'random?' #?q=' + URI.encode(keywords)
|
43
51
|
end
|
44
52
|
|
53
|
+
def get_trending_uri()
|
54
|
+
# limit (optional) limits the number of results returned. By default returns 25 results.
|
55
|
+
# rating - limit results to those rated (y,g, pg, pg-13 or r).
|
56
|
+
# fmt - (optional) return results in html or json format (useful for viewing responses as GIFs to debug/test)
|
57
|
+
config.api_uri + 'trending?'
|
58
|
+
end
|
59
|
+
|
45
60
|
def get_random(data)
|
46
61
|
image_data = JSON.parse(data)
|
47
62
|
image_data['data'][get_random_number(image_data['data'].count)]['images']['original']['url']
|
data/lita-onewheel-giphy.gemspec
CHANGED
@@ -0,0 +1,134 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"type": "gif",
|
5
|
+
"id": "op7uqYWBm3R04",
|
6
|
+
"url": "http://giphy.com/gifs/food-krush-groove-the-fat-boys-op7uqYWBm3R04",
|
7
|
+
"bitly_gif_url": "http://gph.is/1FupHza",
|
8
|
+
"bitly_url": "http://gph.is/1FupHza",
|
9
|
+
"embed_url": "http://giphy.com/embed/op7uqYWBm3R04",
|
10
|
+
"username": "",
|
11
|
+
"source": "http://televandalist.com/post/104471085874",
|
12
|
+
"rating": "y",
|
13
|
+
"caption": "",
|
14
|
+
"content_url": "",
|
15
|
+
"import_datetime": "2014-12-06 06:21:55",
|
16
|
+
"trending_datetime": "2015-04-01 16:05:01",
|
17
|
+
"images": {
|
18
|
+
"fixed_height": {
|
19
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200.gif",
|
20
|
+
"width": "360",
|
21
|
+
"height": "200",
|
22
|
+
"size": "0",
|
23
|
+
"mp4": "http://media0.giphy.com/media/op7uqYWBm3R04/200.mp4",
|
24
|
+
"mp4_size": "367554",
|
25
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/200.webp",
|
26
|
+
"webp_size": "875414"
|
27
|
+
},
|
28
|
+
"fixed_height_still": {
|
29
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200_s.gif",
|
30
|
+
"width": "360",
|
31
|
+
"height": "200"
|
32
|
+
},
|
33
|
+
"fixed_height_downsampled": {
|
34
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200_d.gif",
|
35
|
+
"width": "360",
|
36
|
+
"height": "200",
|
37
|
+
"size": "140417",
|
38
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/200_d.webp",
|
39
|
+
"webp_size": "130658"
|
40
|
+
},
|
41
|
+
"fixed_width": {
|
42
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200w.gif",
|
43
|
+
"width": "200",
|
44
|
+
"height": "111",
|
45
|
+
"size": "0",
|
46
|
+
"mp4": "http://media0.giphy.com/media/op7uqYWBm3R04/200w.mp4",
|
47
|
+
"mp4_size": "342209",
|
48
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/200w.webp",
|
49
|
+
"webp_size": "327936"
|
50
|
+
},
|
51
|
+
"fixed_width_still": {
|
52
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200w_s.gif",
|
53
|
+
"width": "200",
|
54
|
+
"height": "111"
|
55
|
+
},
|
56
|
+
"fixed_width_downsampled": {
|
57
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/200w_d.gif",
|
58
|
+
"width": "200",
|
59
|
+
"height": "111",
|
60
|
+
"size": "368276",
|
61
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/200w_d.webp",
|
62
|
+
"webp_size": "49460"
|
63
|
+
},
|
64
|
+
"fixed_height_small": {
|
65
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/100.gif",
|
66
|
+
"width": "180",
|
67
|
+
"height": "100",
|
68
|
+
"size": "0",
|
69
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/100.webp",
|
70
|
+
"webp_size": "281042"
|
71
|
+
},
|
72
|
+
"fixed_height_small_still": {
|
73
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/100_s.gif",
|
74
|
+
"width": "180",
|
75
|
+
"height": "100"
|
76
|
+
},
|
77
|
+
"fixed_width_small": {
|
78
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/100w.gif",
|
79
|
+
"width": "100",
|
80
|
+
"height": "56",
|
81
|
+
"size": "0",
|
82
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/100w.webp",
|
83
|
+
"webp_size": "108110"
|
84
|
+
},
|
85
|
+
"fixed_width_small_still": {
|
86
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/100w_s.gif",
|
87
|
+
"width": "100",
|
88
|
+
"height": "56"
|
89
|
+
},
|
90
|
+
"downsized": {
|
91
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy.gif",
|
92
|
+
"width": "400",
|
93
|
+
"height": "222",
|
94
|
+
"size": "2071771"
|
95
|
+
},
|
96
|
+
"downsized_still": {
|
97
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy_s.gif",
|
98
|
+
"width": "400",
|
99
|
+
"height": "222"
|
100
|
+
},
|
101
|
+
"downsized_large": {
|
102
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy.gif",
|
103
|
+
"width": "400",
|
104
|
+
"height": "222",
|
105
|
+
"size": "2071771"
|
106
|
+
},
|
107
|
+
"original": {
|
108
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy.gif",
|
109
|
+
"width": "400",
|
110
|
+
"height": "222",
|
111
|
+
"size": "2071771",
|
112
|
+
"frames": "41",
|
113
|
+
"mp4": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy.mp4",
|
114
|
+
"mp4_size": "928142",
|
115
|
+
"webp": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy.webp",
|
116
|
+
"webp_size": "1004522"
|
117
|
+
},
|
118
|
+
"original_still": {
|
119
|
+
"url": "http://media0.giphy.com/media/op7uqYWBm3R04/giphy_s.gif",
|
120
|
+
"width": "400",
|
121
|
+
"height": "222"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
],
|
126
|
+
"pagination": {
|
127
|
+
"count": 25,
|
128
|
+
"offset": 0
|
129
|
+
},
|
130
|
+
"meta": {
|
131
|
+
"status": 200,
|
132
|
+
"msg": "OK"
|
133
|
+
}
|
134
|
+
}
|
@@ -10,6 +10,8 @@ describe Lita::Handlers::OnewheelGiphy, lita_handler: true do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it { is_expected.to route_command('giphy') }
|
13
|
+
it { is_expected.to route_command('giphy soon') }
|
14
|
+
it { is_expected.to route_command('giphytrending') }
|
13
15
|
|
14
16
|
it 'gets a giphy by string keywords' do
|
15
17
|
mock_fixture('search_good')
|
@@ -23,6 +25,12 @@ describe Lita::Handlers::OnewheelGiphy, lita_handler: true do
|
|
23
25
|
expect(replies.last).to eq('http://s3.amazonaws.com/giphygifs/media/Ggjwvmqktuvf2/giphy.gif')
|
24
26
|
end
|
25
27
|
|
28
|
+
it 'gets a trending giphy' do
|
29
|
+
mock_fixture('trending_good')
|
30
|
+
send_command 'giphytrending'
|
31
|
+
expect(replies.last).to eq('http://media0.giphy.com/media/op7uqYWBm3R04/giphy.gif')
|
32
|
+
end
|
33
|
+
|
26
34
|
def mock_fixture(fixture)
|
27
35
|
mock_json = File.open("spec/fixtures/#{fixture}.json").read
|
28
36
|
response = double
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-giphy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- lita-onewheel-giphy.gemspec
|
140
140
|
- spec/fixtures/random_good.json
|
141
141
|
- spec/fixtures/search_good.json
|
142
|
+
- spec/fixtures/trending_good.json
|
142
143
|
- spec/lita/handlers/onewheel_giphy_spec.rb
|
143
144
|
- spec/spec_helper.rb
|
144
145
|
homepage: https://github.com/onewheelskyward/lita-onewheel-giphy
|
@@ -169,5 +170,6 @@ summary: Aims to be a complete implementation of the Giphy api. https://github.
|
|
169
170
|
test_files:
|
170
171
|
- spec/fixtures/random_good.json
|
171
172
|
- spec/fixtures/search_good.json
|
173
|
+
- spec/fixtures/trending_good.json
|
172
174
|
- spec/lita/handlers/onewheel_giphy_spec.rb
|
173
175
|
- spec/spec_helper.rb
|