gembed 1.0.4 → 1.1.0

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: 4afaa678c73a728078b4bf3a42c51cc6966ddd91b7a466456006c6839d667c87
4
- data.tar.gz: d4f2caf1e786db3cfcb20d1fd2f6ac40c2dae970ae89a9ece5af158d83121523
3
+ metadata.gz: 83230c760b84d9add2b2d68e88b5b674db9181e01ea926f75614cb83c758d23e
4
+ data.tar.gz: 2466be5e3329960e902c6a7d58bda8335e0760a50c4a72a9bbd4425e98e4e96b
5
5
  SHA512:
6
- metadata.gz: 9c98ea7c684f858026f9fb7e1b64c248f57a09401b17cde6b20bbf0099e7c258fc4b6b54e95a6b97806d96b8c35614ecd376628a19741a9407f58ad374a1e32f
7
- data.tar.gz: a3e0abd42a8199a00c20338b55a35079322bdcac10a6255d0b731095b9b635770bc99b02d54f75502da451ce5e0f98e51cd3b0d0ea43de98b7228cb42cf49587
6
+ metadata.gz: e02fd109beee46f5fcb1ea4fcc4076ea102dd8cba2db2c9934b9ac38b4800df60365b5e9e1de08055aec8683aa954c922891576b26ffcc77376f67950aaed1f3
7
+ data.tar.gz: 87604ab8c5d44259aad298242a984d4f67aa8d6bb61c782ed89fdda55799b1d0e4c73d1fd11a17695d9663e0463dcb6bff474e9c50f29e18bb81a629b45ef180
data/lib/gembed.rb CHANGED
@@ -6,7 +6,8 @@ module Gembed
6
6
  @sources = Hash[
7
7
  "loom.com" => Loom,
8
8
  "youtube.com" => Youtube,
9
- "youtu.be" => Youtube
9
+ "youtu.be" => Youtube,
10
+ "vimeo.com" => Vimeo
10
11
  ]
11
12
 
12
13
  class << self
@@ -19,6 +20,15 @@ module Gembed
19
20
  end
20
21
  end
21
22
 
23
+ def get_id(url)
24
+ source = find_source(url)
25
+ if @sources[source].nil?
26
+ return "Source not supported"
27
+ else
28
+ @sources[source].find_id(url)
29
+ end
30
+ end
31
+
22
32
  # Gets domain of the url
23
33
  def find_source(url)
24
34
  @source = url.match(/\/\/[www.]*[a-zA-Z0-9]*\.[a-z]*/).to_s.gsub(/\/\/[www.]*/,'')
data/lib/gembed/loom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Gembed
2
2
  class Loom
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>"
3
+ def self.embed(url, height: "100%", width: "100%")
4
+ result = "<iframe src='https://www.loom.com/embed/#{find_id(url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: #{width}; height: #{height};'></iframe>"
5
5
  result.respond_to?(:html_safe) ? result.html_safe : result
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Gembed
2
2
  class Youtube
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>"
3
+ def self.embed(url, height: "100%", width: "100%")
4
+ result = "<iframe src='https://www.youtube.com/embed/#{find_id(url)}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen style='position: absolute; top: 0; left: 0; width: #{width}; height: #{height};'></iframe>"
5
5
  result.respond_to?(:html_safe) ? result.html_safe : result
6
6
  end
7
7
 
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.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Paul
@@ -10,7 +10,8 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Embed media by URL.
13
+ description: Use gembed to embed media in your applications. Give it a url and gembed
14
+ will embed it for you. As simple as that! For a full list of sources see the wiki.
14
15
  email: hello@johnraj.me
15
16
  executables: []
16
17
  extensions: []
@@ -41,5 +42,5 @@ requirements: []
41
42
  rubygems_version: 3.1.2
42
43
  signing_key:
43
44
  specification_version: 4
44
- summary: A gem for embeding media.
45
+ summary: A ruby gem for embedding various media sources by url.
45
46
  test_files: []