lita-onewheel-giphy 0.4.2 → 0.4.3

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: ea5fa7cf083a32d35ea2cf48737ff557b375f6c0
4
- data.tar.gz: beebc189f97b74a11f465051bf4cce5a7d83da82
3
+ metadata.gz: 5372211883a9026d79a4290b171b25b3cf674e82
4
+ data.tar.gz: a4ca41660c7db07b507f5dcf7eed61fbd05885f2
5
5
  SHA512:
6
- metadata.gz: cbf70766a66276f6a214601f01e9df021602e18b695c2239c6e9248ffd61c6fdc6f3550dcda89f1a8bf9526324caddc44ac180480f5e25f4e1ac68634670ed8a
7
- data.tar.gz: 53043edb9424498c10534cabbc4b88fe3111699cef98a0663445ff95740994251e92e6dbd7aeb1143ca1f68f412b57bb64e0072aae7f67fab0a0bb8d200b3c05
6
+ metadata.gz: dbf11d271668b260731bb068983e4efff332da81a4aa7dcbd60679dc29d23400a928dabbfa5df57d2ffce922768f1607afa47b1545fbfa4b37a539b65ebe69a1
7
+ data.tar.gz: 330a64de8363bfbe976a5a1d8ef23ada34a5974a24ef045999000e9e18550b379e767b5bfa1ea440109b8cf8e4679e3ab9af89852dab64230db1c74eba40c81b
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
- - 2.3.0
3
+ - 2.3.4
5
4
  script: bundle exec rake
6
5
  before_install:
7
6
  - gem update --system
@@ -21,6 +21,10 @@ module Lita
21
21
  # :search,
22
22
  command: true,
23
23
  help: {'giphy [keyword]' => 'Returns a random Giphy image with the specified keyword applied.'}
24
+ route /^giphysearch\s+(.+)$/i,
25
+ :search,
26
+ command: true,
27
+ help: {'giphysearch [keyword]' => 'Returns a random Giphy image with the specified keyword applied via search instead of translate.'}
24
28
  route /^gif\s+(.+)$/i,
25
29
  :translate,
26
30
  command: true,
@@ -38,6 +42,7 @@ module Lita
38
42
  keywords = response.matches[0][0]
39
43
  Lita.logger.debug "Searching giphy for #{keywords}"
40
44
  uri = get_search_uri(keywords)
45
+ Lita.logger.debug "search: #{uri}"
41
46
  giphy_data = call_giphy(uri)
42
47
  image = get_random(giphy_data.body)
43
48
  response.reply image
@@ -45,6 +50,7 @@ module Lita
45
50
 
46
51
  def random(response)
47
52
  uri = get_random_uri
53
+ Lita.logger.debug "random: #{uri}"
48
54
  giphy_data = call_giphy(uri)
49
55
  image = get_image(giphy_data.body)
50
56
  response.reply image
@@ -52,6 +58,7 @@ module Lita
52
58
 
53
59
  def trending(response)
54
60
  uri = get_trending_uri
61
+ Lita.logger.debug "trending: #{uri}"
55
62
  giphy_data = call_giphy(uri)
56
63
  image = get_random(giphy_data.body)
57
64
  response.reply image
@@ -60,6 +67,7 @@ module Lita
60
67
  def translate(response)
61
68
  keywords = response.matches[0][0]
62
69
  uri = get_translate_uri(keywords)
70
+ Lita.logger.debug "translate: #{uri}"
63
71
  giphy_data = call_giphy(uri)
64
72
  image = get_translate_image(giphy_data.body)
65
73
  response.reply image
@@ -98,7 +106,7 @@ module Lita
98
106
  def get_random(data)
99
107
  image_data = JSON.parse(data)
100
108
  if image_data['data'].count == 0
101
- Lita.logger.debug 'No images found.'
109
+ Lita.logger.debug 'get_random: No images found.'
102
110
  return
103
111
  end
104
112
  image = image_data['data'][get_random_number(image_data['data'].count)]['images']['original']['url']
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-giphy'
3
- spec.version = '0.4.2'
3
+ spec.version = '0.4.3'
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'
@@ -0,0 +1,11 @@
1
+ {
2
+ "data": [],
3
+ "pagination": {
4
+ "count": 0,
5
+ "offset": 0
6
+ },
7
+ "meta": {
8
+ "status": 200,
9
+ "msg": "OK"
10
+ }
11
+ }
@@ -15,6 +15,7 @@ describe Lita::Handlers::OnewheelGiphy, lita_handler: true do
15
15
  it { is_expected.to route_command('giphy soon') }
16
16
  it { is_expected.to route_command('giphytrending') }
17
17
  it { is_expected.to route_command('giphytranslate boom') }
18
+ it { is_expected.to route_command('giphysearch boom') }
18
19
 
19
20
  it 'gets a giphy by string keywords' do
20
21
  mock_fixture('translate_good')
@@ -28,12 +29,24 @@ describe Lita::Handlers::OnewheelGiphy, lita_handler: true do
28
29
  expect(replies.last).to eq('https://media1.giphy.com/media/T2NINhwlHgOSk/giphy.gif')
29
30
  end
30
31
 
32
+ it 'gets a giphy via search' do
33
+ mock_fixture('search_good')
34
+ send_command 'giphysearch boom'
35
+ expect(replies.last).to eq('http://media2.giphy.com/media/FiGiRei2ICzzG/giphy.gif')
36
+ end
37
+
31
38
  it 'gets a random giphy' do
32
39
  mock_fixture('random_good')
33
40
  send_command 'giphy'
34
41
  expect(replies.last).to eq('http://s3.amazonaws.com/giphygifs/media/Ggjwvmqktuvf2/giphy.gif')
35
42
  end
36
43
 
44
+ it 'gets no trending giphy' do
45
+ mock_fixture('trending_empty')
46
+ send_command 'giphytrending'
47
+ expect(replies.last).to eq(nil)
48
+ end
49
+
37
50
  it 'gets a trending giphy' do
38
51
  mock_fixture('trending_good')
39
52
  send_command 'giphytrending'
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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
@@ -141,6 +141,7 @@ files:
141
141
  - spec/fixtures/random_good.json
142
142
  - spec/fixtures/search_good.json
143
143
  - spec/fixtures/translate_good.json
144
+ - spec/fixtures/trending_empty.json
144
145
  - spec/fixtures/trending_good.json
145
146
  - spec/lita/handlers/onewheel_giphy_spec.rb
146
147
  - spec/spec_helper.rb
@@ -173,6 +174,7 @@ test_files:
173
174
  - spec/fixtures/random_good.json
174
175
  - spec/fixtures/search_good.json
175
176
  - spec/fixtures/translate_good.json
177
+ - spec/fixtures/trending_empty.json
176
178
  - spec/fixtures/trending_good.json
177
179
  - spec/lita/handlers/onewheel_giphy_spec.rb
178
180
  - spec/spec_helper.rb