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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10653c1b73e0d351e8a0f2e9520ed1d4f3dcee6a
4
- data.tar.gz: c673eefe628b7155a6ef2ab70a6327f6b7e9f043
3
+ metadata.gz: 392fe28fa16d20506b7f0f4f2998c5a75efb1bba
4
+ data.tar.gz: bf71726537d047ad3562d5640eeea54d300ba55a
5
5
  SHA512:
6
- metadata.gz: 1ec7f04143af9db13afbff26087a37063234cde85bdb4523846e3530c6ce780c6085001890a369865d3556560525e2a7fde9a92eaf495e6bf202a798f54cc7db
7
- data.tar.gz: d16f5a1811338aabfba7f05ea2b815041dd0db3042df62f8949593d75bfbedcf2a5e375ccabe1e24cc53b1e945bcbb2be24318ad9dd5576ffcd2a3da7e73f87c
6
+ metadata.gz: d391c7b7364b1b6941c41dc9edc43751fa57af624d2e3f6bc2735069152fbe59b6e11633134327990fc5d2d07b8816a0962cb00f0219859074db5013b938b692
7
+ data.tar.gz: 70dbf8f082b35a03faf8f123789089b9e0de97e35b5dcf07d6d323abcc97150d95bf6d05ff088fdfe444dc174c4ab7985a0bad92d4ede0e0dc56f1459570d570
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.4
4
+ - 2.3.0
4
5
  script: bundle exec rake
5
6
  before_install:
6
7
  - gem update --system
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'][get_random_number(image_data['data'].count)]['images']['original']['url']
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
- so_far_away = and_i.rand(max)
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-giphy'
3
- spec.version = '0.3.1'
3
+ spec.version = '0.3.2'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = 'Lita chat interface to giphy api for MOAR GIFS'
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.1
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-01-18 00:00:00.000000000 Z
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.4.5.1
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