frinkiac 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/frinkiac.gemspec +3 -2
- data/lib/frinkiac/screencap.rb +12 -2
- data/lib/frinkiac/version.rb +1 -1
- metadata +24 -11
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70c4f08466ce28e543aad3104f077bcb7826e4aa
|
4
|
+
data.tar.gz: 68ceec3a8aee9418fc8cd37a48a3c937a07a9c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698a5c84d7625c336d45835c0ba149e49c4cfa7f737f2e630ed38e28572212a771a309d77363e94bbf3f821cb838bc4237a3a82be9a3d2e325a68d1af4ba4711
|
7
|
+
data.tar.gz: 24449eddfc56184ed166035dfbea2d717f6f30ee93ad764fa1d7500e98cc7a882f754ae95872076a25921f620c947ac510b6f804896fdc310017ab24388e660a
|
data/frinkiac.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'vcr', '~> 3.0.1'
|
27
27
|
spec.add_development_dependency 'webmock', '~> 1.22.6'
|
28
28
|
|
29
|
-
spec.add_dependency 'faraday'
|
30
|
-
spec.add_dependency 'json'
|
29
|
+
spec.add_dependency 'faraday', '~> 0.9.2'
|
30
|
+
spec.add_dependency 'json', '~> 1.8.3'
|
31
|
+
spec.add_dependency 'word_wrap', '~> 1.0.0'
|
31
32
|
end
|
data/lib/frinkiac/screencap.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'json'
|
3
|
+
require 'word_wrap'
|
3
4
|
|
4
5
|
SITE_URL = 'https://frinkiac.com'
|
5
6
|
API_URL = "#{SITE_URL}/api/search"
|
@@ -22,14 +23,16 @@ module Frinkiac
|
|
22
23
|
def meme_url(caption = nil)
|
23
24
|
caption = self.caption if caption.nil?
|
24
25
|
caption = caption.join("\n") if caption.is_a?(Array)
|
26
|
+
|
25
27
|
"#{SITE_URL}/meme/#{episode}/#{timestamp}.jpg?lines=#{URI.escape caption}"
|
26
28
|
end
|
27
29
|
|
28
30
|
def caption
|
29
31
|
@caption ||= begin
|
30
|
-
response = Faraday.get("#{CAPTION_URL}?e=#{
|
32
|
+
response = Faraday.get("#{CAPTION_URL}?e=#{episode}&t=#{timestamp}")
|
31
33
|
body = JSON.parse(response.body)
|
32
|
-
|
34
|
+
|
35
|
+
format_captions(body['Subtitles'].collect { |s| s['Content'] })
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -44,5 +47,12 @@ module Frinkiac
|
|
44
47
|
screencaps = search(query)
|
45
48
|
screencaps[rand(screencaps.size)] if screencaps.any?
|
46
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def format_captions(captions)
|
53
|
+
caption_string = captions.join(' ')
|
54
|
+
|
55
|
+
WordWrap.ww(caption_string, 25).chop
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
data/lib/frinkiac/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,30 +98,44 @@ dependencies:
|
|
98
98
|
name: faraday
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.9.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.9.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.8.3
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.8.3
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: word_wrap
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: 1.0.0
|
125
139
|
description: Gem to wrap Frinkiac.com API
|
126
140
|
email:
|
127
141
|
- ccamacho@gapintelligence.com
|
@@ -130,7 +144,6 @@ extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
146
|
- ".gitignore"
|
133
|
-
- ".travis.yml"
|
134
147
|
- CODE_OF_CONDUCT.md
|
135
148
|
- Gemfile
|
136
149
|
- LICENSE.txt
|
data/.travis.yml
DELETED