gembed 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 259d14abdc8d372aecbfee297f0479b1c3b2fbd8fdb13a28ca9984db468223ae
4
- data.tar.gz: 63836501b6f719bfca5552aaea14bd215252da169459eb64291be1a673c7a0d4
3
+ metadata.gz: 4afaa678c73a728078b4bf3a42c51cc6966ddd91b7a466456006c6839d667c87
4
+ data.tar.gz: d4f2caf1e786db3cfcb20d1fd2f6ac40c2dae970ae89a9ece5af158d83121523
5
5
  SHA512:
6
- metadata.gz: 269c02870fa87254a3fb95427148bd8a094de214ebaf63e6c6489241a54d0a433421922cbff87aab29cb2a8bea7da1aee957eb3eb3dd0671e8345bb95e2daf29
7
- data.tar.gz: 9053eb325da2b400fe59ba648cdeff38dcf1df4861554ecb5d86bd7cb8a2269c52acebfacbff9cc79b4d2515c94757660b66b2d9a3b33dd34e86824414878da4
6
+ metadata.gz: 9c98ea7c684f858026f9fb7e1b64c248f57a09401b17cde6b20bbf0099e7c258fc4b6b54e95a6b97806d96b8c35614ecd376628a19741a9407f58ad374a1e32f
7
+ data.tar.gz: a3e0abd42a8199a00c20338b55a35079322bdcac10a6255d0b731095b9b635770bc99b02d54f75502da451ce5e0f98e51cd3b0d0ea43de98b7228cb42cf49587
data/lib/gembed/loom.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Gembed
2
2
  class Loom
3
- def self.embed(source, url)
4
- result = "<div style='position: relative; padding-bottom: 62.5%; height: 0;'><iframe src='https://www.loom.com/embed/#{find_id(source, url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'></iframe></div>"
3
+ def self.embed(url)
4
+ result = "<div style='position: relative; padding-bottom: 62.5%; height: 0;'><iframe src='https://www.loom.com/embed/#{find_id(url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'></iframe></div>"
5
5
  result.respond_to?(:html_safe) ? result.html_safe : result
6
6
  end
7
7
 
8
- def self.find_id(source, url)
8
+ def self.find_id(url)
9
9
  url.split("share/")[1]
10
10
  end
11
11
  end
@@ -1,16 +1,20 @@
1
1
  module Gembed
2
2
  class Youtube
3
- def self.embed(source, url)
4
- result = "<div style='position: relative; padding-bottom: 62.5%; height: 0;'><iframe width='100%' height='100%' src='https://www.youtube.com/embed/#{find_id(source, url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'></iframe></div>"
3
+ def self.embed(url)
4
+ result = "<div style='position: relative; padding-bottom: 62.5%; height: 0;'><iframe width='100%' height='100%' src='https://www.youtube.com/embed/#{find_id(url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'></iframe></div>"
5
5
  result.respond_to?(:html_safe) ? result.html_safe : result
6
6
  end
7
7
 
8
- def self.find_id(source, url)
9
- if source == "youtube.com"
10
- (url.split("v=")[1]).split('&')[0]
8
+ def self.find_id(url)
9
+ id = ''
10
+ url = url.gsub(/(>|<)/i,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/)
11
+ if url[2] != nil
12
+ id = url[2].split(/[^0-9a-z_\-]/i)
13
+ id = id[0];
11
14
  else
12
- url.split(".be/")[1]
15
+ id = url;
13
16
  end
17
+ id
14
18
  end
15
19
  end
16
- end
20
+ end
data/lib/gembed.rb CHANGED
@@ -15,7 +15,7 @@ module Gembed
15
15
  if @sources[source].nil?
16
16
  return source_error(url)
17
17
  else
18
- @sources[source].embed(source, url)
18
+ @sources[source].embed(url)
19
19
  end
20
20
  end
21
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gembed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Paul