frinkiac 0.0.1 → 0.0.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: 8f41efb6efbffaa8e37a6350f36a8a9d240c171c
4
- data.tar.gz: 3f5ebbda3a2b40da9ce25c570baa3e2c76e151de
3
+ metadata.gz: 7615609051d44ae710df3264e8dd51ef555fb7a6
4
+ data.tar.gz: 794e7ab721b1883471b91f9a3a9c6fcbdfdb8de9
5
5
  SHA512:
6
- metadata.gz: 7d8b0e996223f13f39bfac24f10a15bb54c2b03609d357a6825c765ccd0903196e8509649dad0f9024fe5d4e653041c797915aaf00ac842a592a489cedee8bac
7
- data.tar.gz: 324c4be30b109235ec22136fa55b869b52f1fe3182998c925e8292ed9ec71d27cb75946c9c14ca2da82ea7e73a47069c7d301908ead9cbaed5319e4b545d869b
6
+ metadata.gz: dd4ba17cba260b3909c3e3870e7222546b3218c9b99633068ec4069a12833a98c13cdf8394b1538669ee1e399e6e71c7612d9d23728118498d695afb1eeff3b1
7
+ data.tar.gz: c39d41b7c81cc7bc25f6396f42f3ac341cf6037489af1fe01516e86021e6f58d466fea119fee3cab6400f8bc4e017ecc4c9a33e9754b72e9fbeb6676163e8a8d
data/README.md CHANGED
@@ -24,6 +24,19 @@ Tha main object defined in this gem is ```Frinkiac::Screencap```, which gives us
24
24
 
25
25
  It also provides an ```image_url``` method, that takes the episode and timestamp information to return a valid image url.
26
26
 
27
+ You can also get the ```caption``` from the image, as well as the ```meme_url```, which returns the caption overlaid on top of the image.
28
+
29
+ You can also specify your own caption for the meme URL like so:
30
+
31
+ ```
32
+ screencap.meme_url("I love those lazy Saturdays")
33
+ ```
34
+
35
+ Or multiple lines of text like so
36
+
37
+ ```
38
+ screencap.meme_url(["I love those lazy Saturdays", "Unlike that fake Saturday that almost got me fired"])
39
+ ```
27
40
 
28
41
  Currently there are only two ways to interact with the API through this gem.
29
42
 
@@ -54,4 +67,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
54
67
  ## License
55
68
 
56
69
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
-
@@ -3,6 +3,7 @@ require 'json'
3
3
 
4
4
  SITE_URL = 'https://frinkiac.com'
5
5
  API_URL = "#{SITE_URL}/api/search"
6
+ CAPTION_URL = "#{SITE_URL}/api/caption"
6
7
 
7
8
  module Frinkiac
8
9
  class Screencap
@@ -18,6 +19,20 @@ module Frinkiac
18
19
  "#{SITE_URL}/img/#{episode}/#{timestamp}.jpg"
19
20
  end
20
21
 
22
+ def meme_url(caption = nil)
23
+ caption = self.caption if caption.nil?
24
+ caption = caption.join("\n") if caption.is_a?(Array)
25
+ "#{SITE_URL}/meme/#{episode}/#{timestamp}.jpg?lines=#{URI.escape caption}"
26
+ end
27
+
28
+ def caption
29
+ @caption ||= begin
30
+ response = Faraday.get("#{CAPTION_URL}?e=#{@episode}&t=#{@timestamp}")
31
+ body = JSON.parse(response.body)
32
+ body["Subtitles"].map { |s| s["Content"] }.join("\n")
33
+ end
34
+ end
35
+
21
36
  def self.search(query)
22
37
  response = Faraday.get("#{API_URL}?q=#{query}")
23
38
  screencaps = JSON.parse(response.body)
@@ -30,4 +45,4 @@ module Frinkiac
30
45
  screencaps[rand(screencaps.size)] if screencaps.any?
31
46
  end
32
47
  end
33
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module Frinkiac
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frinkiac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cesar Camacho
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-07 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler