iframely 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/iframely/requester.rb +3 -4
- data/lib/iframely/version.rb +1 -1
- data/test/iframely_requester_test.rb +13 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d85ce6fb09a8b3f3d37a9afd8ebe76cb0e8a690
|
|
4
|
+
data.tar.gz: d6767ac4f0be24979004f084c3f34152511b46f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1b2d3a45ca1cf95bd7237aec31d8616d459d9d77c7adcf9d36c343b2f39e463cceeb07d984b120691eef7c1a324a99e572531b6f37ca95b66c801293ea65eaa
|
|
7
|
+
data.tar.gz: 7618adc31fc435ef1382aaf3342d49b31a0b8fc0990c568748d853d68257a74d6869649127c67f75bd39f517c515ae6f7e67c30f821918e4fbffa4c986a079f1
|
data/lib/iframely/requester.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Iframely
|
|
|
17
17
|
@cache_options = cache_options
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def get_iframely_json embed_url
|
|
21
21
|
fetch cache_key(:iframely, embed_url) do
|
|
22
22
|
response = iframely_connection.get do |req|
|
|
23
23
|
req.params['api_key'] = api_key
|
|
@@ -29,7 +29,7 @@ module Iframely
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def get_iframely_model embed_url
|
|
32
|
-
json =
|
|
32
|
+
json = get_iframely_json embed_url
|
|
33
33
|
if json.has_key? 'error'
|
|
34
34
|
raise Iframely::Error, json['error']
|
|
35
35
|
else
|
|
@@ -37,7 +37,7 @@ module Iframely
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def get_oembed_json embed_url
|
|
41
41
|
fetch cache_key(:oembed, embed_url) do
|
|
42
42
|
response = oembed_connection.get do |req|
|
|
43
43
|
req.params['api_key'] = api_key
|
|
@@ -52,7 +52,6 @@ module Iframely
|
|
|
52
52
|
|
|
53
53
|
def cache_key type, url
|
|
54
54
|
CACHE_KEY_PREFIX + type.to_s + ':' + url.to_s
|
|
55
|
-
return CACHE_KEY_PREFIX
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
def fetch cache_key, &block
|
data/lib/iframely/version.rb
CHANGED
|
@@ -3,23 +3,31 @@ require './test/test_helper'
|
|
|
3
3
|
class IframelyRequesterTers < Minitest::Test
|
|
4
4
|
API_KEY = 'some_key'
|
|
5
5
|
EMBED_URL = 'some_url'
|
|
6
|
+
BODY = "{\n \"id\": \"g41eH1\",\n \"url\": \"http://www.youtube.com/embed/LG3oB2n0MU8\",\n \"meta\": {\n \"title\": \"Empire vs MVP.P, SLTV Lan Finals Day 1 Game 1\",\n \"date\": \"2014-04-17T16:37:31.000Z\",\n \"author\": \"dotasltv\",\n \"category\": \"Gaming\",\n \"description\": \"\xD0\x94\xD0\xB5\xD0\xB2\xD1\x8F\xD1\x82\xD1\x8B\xD0\xB9 \xD1\x81\xD0\xB5\xD0\xB7\xD0\xBE\xD0\xBD STARLADDER.TV \xD0\xB2 \xD1\x80\xD0\xB0\xD0\xB7\xD0\xB3\xD0\xB0\xD1\x80\xD0\xB5! \xD0\x9A\xD1\x83\xD0\xBF\xD0\xB8 \xD0\xB1\xD0\xB8\xD0\xBB\xD0\xB5\xD1\x82, \xD0\xBF\xD0\xBE\xD0\xB4\xD0\xB4\xD0\xB5\xD1\x80\xD0\xB6\xD0\xB8 \xD0\xBB\xD1\x8E\xD0\xB1\xD0\xB8\xD0\xBC\xD1\x8B\xD0\xB5 \xD0\xBA\xD0\xBE\xD0\xBC\xD0\xB0\xD0\xBD\xD0\xB4\xD1\x8B \xD0\xB8 \xD0\xBF\xD0\xBE\xD0\xBB\xD1\x83\xD1\x87\xD0\xB8 \xD1\x8D\xD0\xBA\xD1\x81\xD0\xBA\xD0\xBB\xD1\x8E\xD0\xB7\xD0\xB8\xD0\xB2\xD0\xBD\xD1\x8B\xD0\xB9 \xD1\x81\xD1\x8D\xD1\x82 \xD0\xBD\xD0\xB0 \xD0\x9B\xD0\xB8\xD1\x87\xD0\xB0, \xD0\xB0 \xD1\x82\xD0\xB0\xD0\xBA\xD0\xB6\xD0\xB5 \xD1\x83\xD0\xBD\xD0\xB8\xD0\xBA\xD0\xB0\xD0\xBB\xD1\x8C\xD0\xBD\xD1\x8B\xD0\xB9 Loading Screen.\\n\xD0\x9C\xD0\xB0\xD0\xB3\xD0\xB0\xD0\xB7\xD0\xB8\xD0\xBD \xD0\xB7\xD0\xB0 \xD1\x83\xD0\xB3\xD0\xBB\xD0\xBE\xD0\xBC \xE2\x86\x92 http://www.dota2.com/store/itemdetails/20417\\n\xE2\x80\x94\\n\xD0\x91\xD1\x83\xD0\xB4\xD1\x8C\xD1\x82\xD0\xB5 \xD0\xB2 \xD0\xBA\xD1\x83\xD1\x80\xD1\x81\xD0\xB5 \xD0\xB2\xD1\x81\xD0\xB5\xD1\x85 \xD0\xBF\xD0\xBE\xD1\x81\xD0\xBB\xD0\xB5\xD0\xB4\xD0\xBD\xD0\xB8\xD1\x85 \xD1\x81\xD0\xBE\xD0\xB1\xD1\x8B\xD1\x82\xD0\xB8\xD0\xB9 \xD0\xBD\xD0\xB0\xD1\x88\xD0\xB5\xD0\xB9 \xD0\xBB\xD0\xB8\xD0\xB3\xD0\xB8!\\nhttp://dota2.starladder.tv \\nhttp://vk.com/dotastarladder\\nhttp://facebook.com/dotasltv\\nhttp://twitter.com/dotasltv\\nhttp://twitch.tv/starladder1/new\",\n \"duration\": \"4642\",\n \"likes\": \"303\",\n \"views\": \"33476\",\n \"site\": \"YouTube\"\n },\n \"links\": {\n \"player\": [\n {\n \"href\": \"https://www.youtube.com/embed/LG3oB2n0MU8?wmode=transparent&rel=0&autohide=1&showinfo=0&enablejsapi=1\",\n \"rel\": [\n \"player\",\n \"html5\"\n ],\n \"type\": \"text/html\",\n \"media\": {\n \"aspect-ratio\": 1.778\n }\n }\n ],\n \"thumbnail\": [\n {\n \"href\": \"https://i1.ytimg.com/vi/LG3oB2n0MU8/mqdefault.jpg\",\n \"rel\": [\n \"thumbnail\"\n ],\n \"type\": \"image/jpeg\",\n \"media\": {\n \"width\": 320,\n \"height\": 180\n }\n },\n {\n \"href\": \"https://i1.ytimg.com/vi/LG3oB2n0MU8/maxresdefault.jpg\",\n \"rel\": [\n \"thumbnail\"\n ],\n \"type\": \"image/jpeg\",\n \"media\": {\n \"width\": 1280,\n \"height\": 720\n }\n }\n ],\n \"icon\": [\n {\n \"href\": \"https://s.ytimg.com/yts/img/favicon_32-vflWoMFGx.png\",\n \"type\": \"image/png\",\n \"rel\": [\n \"icon\"\n ],\n \"media\": {\n \"width\": 32,\n \"height\": 32\n }\n }\n ]\n },\n \"html\": \"<div style=\\\"left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.243%;\\\"><iframe src=\\\"//iframe.ly/g41eH1\\\" frameborder=\\\"0\\\" allowfullscreen=\\\"true\\\" webkitallowfullscreen=\\\"true\\\" mozallowfullscreen=\\\"true\\\" style=\\\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\\\"></iframe></div>\"\n}"
|
|
6
7
|
|
|
7
8
|
def setup
|
|
8
9
|
@iframely = Iframely::Requester.new api_key: API_KEY
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def
|
|
12
|
+
def test_request_iframely_json
|
|
12
13
|
stub_request(:get, Iframely::IFRAMELY_API_URL + "?api_key=some_key&url=some_url").
|
|
13
|
-
to_return(:status => 200, :body =>
|
|
14
|
+
to_return(:status => 200, :body => BODY)
|
|
15
|
+
|
|
16
|
+
@iframely.get_iframely_json EMBED_URL
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_request_iframely_model
|
|
20
|
+
stub_request(:get, Iframely::IFRAMELY_API_URL + "?api_key=some_key&url=some_url").
|
|
21
|
+
to_return(:status => 200, :body => BODY)
|
|
14
22
|
|
|
15
|
-
@iframely.
|
|
23
|
+
@iframely.get_iframely_model EMBED_URL
|
|
16
24
|
end
|
|
17
25
|
|
|
18
|
-
def
|
|
26
|
+
def test_request_oembed_json
|
|
19
27
|
stub_request(:get, Iframely::OEMBED_API_URL + "?api_key=some_key&url=some_url").
|
|
20
28
|
to_return(:status => 200, :body => "{}")
|
|
21
29
|
|
|
22
|
-
@iframely.
|
|
30
|
+
@iframely.get_oembed_json EMBED_URL
|
|
23
31
|
end
|
|
24
32
|
|
|
25
33
|
end
|