lita-onewheel-giphy 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/LICENSE +19 -0
- data/lib/lita/handlers/onewheel_giphy.rb +16 -7
- data/lita-onewheel-giphy.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 392fe28fa16d20506b7f0f4f2998c5a75efb1bba
|
4
|
+
data.tar.gz: bf71726537d047ad3562d5640eeea54d300ba55a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d391c7b7364b1b6941c41dc9edc43751fa57af624d2e3f6bc2735069152fbe59b6e11633134327990fc5d2d07b8816a0962cb00f0219859074db5013b938b692
|
7
|
+
data.tar.gz: 70dbf8f082b35a03faf8f123789089b9e0de97e35b5dcf07d6d323abcc97150d95bf6d05ff088fdfe444dc174c4ab7985a0bad92d4ede0e0dc56f1459570d570
|
data/.travis.yml
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2016 Andrew Kreps
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -27,6 +27,7 @@ module Lita
|
|
27
27
|
|
28
28
|
def search(response)
|
29
29
|
keywords = response.matches[0][0]
|
30
|
+
Lita.logger.debug "Searching giphy for #{keywords}"
|
30
31
|
uri = get_search_uri(keywords)
|
31
32
|
giphy_data = call_giphy(uri)
|
32
33
|
image = get_random(giphy_data.body)
|
@@ -87,28 +88,36 @@ module Lita
|
|
87
88
|
|
88
89
|
def get_random(data)
|
89
90
|
image_data = JSON.parse(data)
|
90
|
-
image_data['data']
|
91
|
+
if image_data['data'].count == 0
|
92
|
+
Lita.logger.debug 'No images found.'
|
93
|
+
return
|
94
|
+
end
|
95
|
+
image = image_data['data'][get_random_number(image_data['data'].count)]['images']['original']['url']
|
96
|
+
Lita.logger.debug "get_random returning #{image}"
|
97
|
+
image
|
91
98
|
end
|
92
99
|
|
93
100
|
def get_random_number(max)
|
94
101
|
and_i = Random.new
|
95
|
-
|
96
|
-
puts "rand: #{so_far_away}"
|
97
|
-
so_far_away
|
102
|
+
and_i.rand(max)
|
98
103
|
end
|
99
104
|
|
100
105
|
def get_image(data)
|
101
106
|
image_data = JSON.parse(data)
|
102
|
-
image_data['data']['image_original_url']
|
107
|
+
image = image_data['data']['image_original_url']
|
108
|
+
Lita.logger.debug "get_image returning #{image}"
|
109
|
+
image
|
103
110
|
end
|
104
111
|
|
105
112
|
def get_translate_image(data)
|
106
113
|
image_data = JSON.parse(data)
|
107
|
-
image_data['data']['images']['original']['url']
|
114
|
+
image = image_data['data']['images']['original']['url']
|
115
|
+
Lita.logger.debug "get_translate_image returning #{image}"
|
116
|
+
image
|
108
117
|
end
|
109
118
|
|
110
119
|
def call_giphy(uri)
|
111
|
-
Lita.logger.debug("Calling giphy with #{uri}")
|
120
|
+
Lita.logger.debug("Calling giphy with #{uri + 'api_key=' + config.api_key}")
|
112
121
|
RestClient.get uri + 'api_key=' + config.api_key
|
113
122
|
end
|
114
123
|
|
data/lita-onewheel-giphy.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-giphy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".gitignore"
|
133
133
|
- ".travis.yml"
|
134
134
|
- Gemfile
|
135
|
+
- LICENSE
|
135
136
|
- README.rst
|
136
137
|
- Rakefile
|
137
138
|
- lib/lita-onewheel-giphy.rb
|
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
165
|
version: '0'
|
165
166
|
requirements: []
|
166
167
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.5.1
|
168
169
|
signing_key:
|
169
170
|
specification_version: 4
|
170
171
|
summary: Aims to be a complete implementation of the Giphy api. https://github.com/giphy/GiphyAPI
|