onebox 1.8.8 → 1.8.9
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/onebox/engine.rb +3 -0
- data/lib/onebox/engine/twitch_clips_onebox.rb +18 -0
- data/lib/onebox/engine/twitch_stream_onebox.rb +14 -0
- data/lib/onebox/engine/twitch_video_onebox.rb +14 -0
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +0 -1
- data/lib/onebox/mixins/twitch_onebox.rb +26 -0
- data/lib/onebox/version.rb +1 -1
- data/spec/lib/onebox/engine/twitch_clips_onebox_spec.rb +10 -0
- data/spec/lib/onebox/engine/twitch_stream_onebox_spec.rb +10 -0
- data/spec/lib/onebox/engine/twitch_video_onebox_spec.rb +10 -0
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd77f3a379051b4a87a9988c5156c871f0d23cff
|
4
|
+
data.tar.gz: 3e106b3220ff9cb301953571a7b606d83454c320
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bc033bb0d633e3dd42ff2608d6d5cebd0a6e9ba95ce33b675c4022424cfdac3f49e1a5f8c482fd625f5b6ce88a769cf90f937cf5799cf7b222e15754ce3ebb5
|
7
|
+
data.tar.gz: dc0f49bef39c882fa66c4c0c1defd0eed1670fa253b6bcc202fcd1448362a4ea0d37d1aaedf960584637867144c98023183d7fa770e239d0264ecd0c714bcc17
|
data/lib/onebox/engine.rb
CHANGED
@@ -177,3 +177,6 @@ require_relative "engine/flickr_onebox"
|
|
177
177
|
require_relative "engine/flickr_shortened_onebox"
|
178
178
|
require_relative "engine/five_hundred_px_onebox"
|
179
179
|
require_relative "engine/pdf_onebox"
|
180
|
+
require_relative "engine/twitch_clips_onebox"
|
181
|
+
require_relative "engine/twitch_stream_onebox"
|
182
|
+
require_relative "engine/twitch_video_onebox"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../mixins/twitch_onebox'
|
2
|
+
|
3
|
+
class Onebox::Engine::TwitchClipsOnebox
|
4
|
+
|
5
|
+
def self.twitch_regexp
|
6
|
+
/^https?:\/\/clips\.twitch\.tv\/([a-zA-Z0-9_]+\/?[^#\?\/]+)/
|
7
|
+
end
|
8
|
+
include Onebox::Mixins::TwitchOnebox
|
9
|
+
|
10
|
+
def query_params
|
11
|
+
"clip=#{twitch_id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def base_url
|
15
|
+
"clips.twitch.tv/embed?"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../mixins/twitch_onebox'
|
2
|
+
|
3
|
+
class Onebox::Engine::TwitchStreamOnebox
|
4
|
+
|
5
|
+
def self.twitch_regexp
|
6
|
+
/^https?:\/\/(?:www\.)?twitch\.tv\/(?!directory)([a-zA-Z0-9_]{4,25})$/
|
7
|
+
end
|
8
|
+
include Onebox::Mixins::TwitchOnebox
|
9
|
+
|
10
|
+
def query_params
|
11
|
+
"channel=#{twitch_id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../mixins/twitch_onebox'
|
2
|
+
|
3
|
+
class Onebox::Engine::TwitchVideoOnebox
|
4
|
+
|
5
|
+
def self.twitch_regexp
|
6
|
+
/^https?:\/\/(?:www\.)?twitch\.tv\/videos\/([0-9]+)/
|
7
|
+
end
|
8
|
+
include Onebox::Mixins::TwitchOnebox
|
9
|
+
|
10
|
+
def query_params
|
11
|
+
"video=v#{twitch_id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Onebox
|
2
|
+
module Mixins
|
3
|
+
module TwitchOnebox
|
4
|
+
|
5
|
+
def self.included(klass)
|
6
|
+
klass.include(Onebox::Engine)
|
7
|
+
klass.matches_regexp(klass.twitch_regexp)
|
8
|
+
klass.include(InstanceMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
def twitch_id
|
13
|
+
@url.match(self.class.twitch_regexp)[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_url
|
17
|
+
"player.twitch.tv/?"
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_html
|
21
|
+
"<iframe src=\"//#{base_url}#{query_params}&autoplay=false\" width=\"620\" height=\"378\" frameborder=\"0\" style=\"overflow: hidden;\" scrolling=\"no\" allowfullscreen=\"allowfullscreen\"></iframe>"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/onebox/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Onebox::Engine::TwitchClipsOnebox do
|
4
|
+
|
5
|
+
it "has the iframe with the correct channel" do
|
6
|
+
expect(Onebox.preview('https://clips.twitch.tv/FunVastGalagoKlappa').to_s).to match(/<iframe src="\/\/clips\.twitch\.tv\/embed\?clip=FunVastGalagoKlappa/)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Onebox::Engine::TwitchStreamOnebox do
|
4
|
+
|
5
|
+
it "has the iframe with the correct channel" do
|
6
|
+
expect(Onebox.preview('https://www.twitch.tv/theduckie908').to_s).to match(/<iframe src="\/\/player\.twitch\.tv\/\?channel=theduckie908/)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Onebox::Engine::TwitchVideoOnebox do
|
4
|
+
|
5
|
+
it "has the iframe with the correct channel" do
|
6
|
+
expect(Onebox.preview('https://www.twitch.tv/videos/140675974').to_s).to match(/<iframe src="\/\/player\.twitch\.tv\/\?video=v140675974/)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -365,6 +365,9 @@ files:
|
|
365
365
|
- lib/onebox/engine/stack_exchange_onebox.rb
|
366
366
|
- lib/onebox/engine/standard_embed.rb
|
367
367
|
- lib/onebox/engine/steam_store_onebox.rb
|
368
|
+
- lib/onebox/engine/twitch_clips_onebox.rb
|
369
|
+
- lib/onebox/engine/twitch_stream_onebox.rb
|
370
|
+
- lib/onebox/engine/twitch_video_onebox.rb
|
368
371
|
- lib/onebox/engine/twitter_status_onebox.rb
|
369
372
|
- lib/onebox/engine/typeform_onebox.rb
|
370
373
|
- lib/onebox/engine/video_onebox.rb
|
@@ -380,6 +383,7 @@ files:
|
|
380
383
|
- lib/onebox/layout.rb
|
381
384
|
- lib/onebox/layout_support.rb
|
382
385
|
- lib/onebox/matcher.rb
|
386
|
+
- lib/onebox/mixins/twitch_onebox.rb
|
383
387
|
- lib/onebox/preview.rb
|
384
388
|
- lib/onebox/sanitize_config.rb
|
385
389
|
- lib/onebox/status_check.rb
|
@@ -438,6 +442,9 @@ files:
|
|
438
442
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
439
443
|
- spec/lib/onebox/engine/slides_onebox_spec.rb
|
440
444
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
445
|
+
- spec/lib/onebox/engine/twitch_clips_onebox_spec.rb
|
446
|
+
- spec/lib/onebox/engine/twitch_stream_onebox_spec.rb
|
447
|
+
- spec/lib/onebox/engine/twitch_video_onebox_spec.rb
|
441
448
|
- spec/lib/onebox/engine/twitter_status_onebox_spec.rb
|
442
449
|
- spec/lib/onebox/engine/video_onebox_spec.rb
|
443
450
|
- spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
|
@@ -500,7 +507,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
500
507
|
version: '0'
|
501
508
|
requirements: []
|
502
509
|
rubyforge_project:
|
503
|
-
rubygems_version: 2.6.
|
510
|
+
rubygems_version: 2.6.12
|
504
511
|
signing_key:
|
505
512
|
specification_version: 4
|
506
513
|
summary: A gem for turning URLs into previews.
|
@@ -554,6 +561,9 @@ test_files:
|
|
554
561
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
555
562
|
- spec/lib/onebox/engine/slides_onebox_spec.rb
|
556
563
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
564
|
+
- spec/lib/onebox/engine/twitch_clips_onebox_spec.rb
|
565
|
+
- spec/lib/onebox/engine/twitch_stream_onebox_spec.rb
|
566
|
+
- spec/lib/onebox/engine/twitch_video_onebox_spec.rb
|
557
567
|
- spec/lib/onebox/engine/twitter_status_onebox_spec.rb
|
558
568
|
- spec/lib/onebox/engine/video_onebox_spec.rb
|
559
569
|
- spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
|