onebox 1.8.8 → 1.8.9

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: 193a79cfcb0e3461c479883dd4a043c56beb92ad
4
- data.tar.gz: 8f993f55c01ed4c72957828b08acfe22dee40200
3
+ metadata.gz: fd77f3a379051b4a87a9988c5156c871f0d23cff
4
+ data.tar.gz: 3e106b3220ff9cb301953571a7b606d83454c320
5
5
  SHA512:
6
- metadata.gz: 64b633a02255964ac679fa5a2ca15646d1917d77226a535ef6488360b1f71181ccc9d3499c55d40af1d86b15055d558e365d8d0fce2b52fea9e462b71ad96698
7
- data.tar.gz: 45084fe78481d3177bcb06a1cbca15f795475b7b4b969af89ddab52cb1209628d81215ea0c361d673515bf95d8feeb78d8b3b32948b05fd5c81d6cbdeb24b08b
6
+ metadata.gz: 8bc033bb0d633e3dd42ff2608d6d5cebd0a6e9ba95ce33b675c4022424cfdac3f49e1a5f8c482fd625f5b6ce88a769cf90f937cf5799cf7b222e15754ce3ebb5
7
+ data.tar.gz: dc0f49bef39c882fa66c4c0c1defd0eed1670fa253b6bcc202fcd1448362a4ea0d37d1aaedf960584637867144c98023183d7fa770e239d0264ecd0c714bcc17
@@ -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
@@ -116,7 +116,6 @@ module Onebox
116
116
  tmz.com
117
117
  torontosun.com
118
118
  tumblr.com
119
- twitch.tv
120
119
  twitpic.com
121
120
  usatoday.com
122
121
  viddler.com
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.8"
2
+ VERSION = "1.8.9"
3
3
  end
@@ -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.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-05-24 00:00:00.000000000 Z
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.7
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