integral-video-embed 0.1.12

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3d226458870e9abfebe568d92f1b764d271fe18b7bfde96dd82e0e0f2c077f5d
4
+ data.tar.gz: 7d7ae443cd139676e9b348380f7af6430387248d5dce8445e3370835add2a4a9
5
+ SHA512:
6
+ metadata.gz: 94a348fdff678d748183beb82d2c60c872bc014de3907840ec4a3477acfb85ff3ffbbbf8ba57f72e0f15277a8320552bd585913c3b5487d0ea27fb2f6d9aabdc
7
+ data.tar.gz: 32555148403738443e13b7ed7a4da70de958ec7acd9f7e69ab0c312e93b9dc378706829cf64227c25f94560e03939e3d37cf0af8373aedfe42e5e46b346d3b59
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 [Integral Design](https://integral-design.ru).
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Integral Video Embed
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/integral-video-embed.svg)](https://badge.fury.io/rb/integral-video-embed)
4
+
5
+ ## Features
6
+
7
+ Helps embed videos from known providers like YouTube into HTML
8
+
9
+ ## Requirements
10
+
11
+ 1. [Ruby 2.5.0+](https://www.ruby-lang.org)
12
+
13
+ ## Setup
14
+
15
+ To install, run:
16
+
17
+ ```bash
18
+ gem install integral-video-embed
19
+ ```
20
+
21
+ Add the following to your Gemfile:
22
+
23
+ ```bash
24
+ gem "integral-video-embed"
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ 1. Probably, within a Rails helper:
30
+
31
+ ```ruby
32
+ def bootstrap_embed(uid)
33
+ Integral::Video::Embed::Bootstrap.html(uid, provider: "YouTube", proportions: "16by9").html_safe
34
+ end
35
+
36
+ def embed_vk(uid, hash:)
37
+ Integral::Video::Embed::Generic.html(uid, provider: "Вконтакте").html_safe
38
+ end
39
+ ```
40
+
41
+ 1. and within a Rails view:
42
+
43
+ ```slim
44
+ = embed_youtube(@video.uid)
45
+ = embed_vk(@video.uid, @video.uhash)
46
+ ```
47
+
48
+ ### Labnol embed
49
+
50
+ This is [a very cool technique](https://www.labnol.org/internet/light-youtube-embeds/27941/) by [Amit Agarwal](https://www.labnol.org/about/) that allows not to download the YouTube player with its whole bunch of resources for each embedded video — untill the user clicks on it — but instead show a lightweight proxy of a YouTube player (a poster and a button) that looks almost the same as the player.
51
+
52
+ To use Labnol embed you have to bring CSS / JS dependency. I improved the original code a little and put it right into the gem folder.
53
+
54
+ 1. Copy & paste `vendor/assets/plugins/youtube-labnol-extended-1.3` folder into you Rails `/vendor/assets/plugins` folder.
55
+
56
+ 1. To include `plugins` folder add it to `assets.rb`:
57
+
58
+ ```ruby
59
+ Rails.application.config.assets.paths << Rails.root.join("vendor", "assets", "plugins")
60
+ ```
61
+
62
+ 1. Make button image (`button.svg`) publicly accessible with help of `app/assets/config/manifest.js`
63
+
64
+ ```js
65
+ //= link ../../../vendor/assets/plugins/youtube-labnol-extended-1.3/button.svg
66
+ ```
67
+
68
+ And then as usual:
69
+
70
+ 1. within a Rails helper:
71
+
72
+ ```ruby
73
+ def embed_labnol(uid, thumbnail: nil)
74
+ Integral::Video::Embed::Labnol.html(uid, thumbnail: thumbnail).html_safe
75
+ end
76
+ ```
77
+
78
+ 1. and within a Rails view:
79
+
80
+ ```slim
81
+ = embed_labnol(@video.uid)
82
+ ```
83
+
84
+ ## License
85
+
86
+ Copyright 2019 [Integral Design](https://integral-design.dev).
87
+ Read [LICENSE](LICENSE.md) for details.
88
+
89
+ ## History
90
+
91
+ Read [CHANGES](CHANGES.md) for details. Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
92
+
93
+ ## Credits
94
+
95
+ Developed by [Sergey Pedan]() at [Integral Design](https://integral-design.dev).
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Embed
6
+ module Bootstrap
7
+
8
+ PROPORTIONS = ["16by9", "4by3"]
9
+
10
+ class << self
11
+ def html(uid, provider:, hash: nil, proportions: "16by9")
12
+ fail ArgumentError, "`uid` must be provided, you passed #{uid.inspect}" if uid.nil? || uid == ""
13
+ fail ArgumentError, "`provider` must be provided, you passed #{provider.inspect}" if provider.nil? || provider == ""
14
+ fail ArgumentError, "`proportions` must be provided to embed via Bootstrap strategy" if proportions.nil? || proportions == ""
15
+ fail ArgumentError, "`proportions` must be one of #{PROPORTIONS.inspect}" unless PROPORTIONS.include? proportions
16
+ provider_names = Integral::Video::Provider.names
17
+ fail ArgumentError, "Unkown provider '#{provider}'. Supported are: #{provider_names.inspect}" unless provider_names.include? provider
18
+
19
+ src = Integral::Video::Provider.new(provider).iframe_src(uid, hash)
20
+ fail StandardError, "`Integral::Video::Provider` error: `iframe_src` could not be calculated when it must be. Seems like you will have to manually correct this gem's code. Such is open source." unless src
21
+
22
+ <<~HEREDOC
23
+ <div class="embed-responsive embed-responsive-#{proportions}">
24
+ <iframe class="embed-responsive-item" src="#{src}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
25
+ </div>
26
+ HEREDOC
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Embed
6
+ module Generic
7
+ class << self
8
+ def html(uid, provider:, hash: nil, width: nil, height: nil)
9
+ fail ArgumentError, "`uid` must be provided, you passed #{uid.inspect}" if uid.nil? || uid == ""
10
+ fail ArgumentError, "`provider` must be provided, you passed #{provider.inspect}" if provider.nil? || provider == ""
11
+ provider_names = Integral::Video::Provider.names
12
+ fail ArgumentError, "Unkown provider '#{provider}'. Supported are: #{provider_names.inspect}" unless provider_names.include? provider
13
+
14
+ src = Integral::Video::Provider.new(provider).iframe_src(uid, hash)
15
+ fail StandardError, "`Integral::Video::Provider` error: `iframe_src` could not be calculated when it must be. Seems like you will have to manually correct this gem's code. Such is open source." unless src
16
+
17
+ fail ArgumentError, "`width` must be an Integer for generic embed strategy" unless width.is_a? Integer
18
+ fail ArgumentError, "`height` must be an Integer for generic embed strategy" unless height.is_a? Integer
19
+ <<~HEREDOC
20
+ <iframe width="#{width}" height="#{height}" src="#{src}" frameborder="0" allow="autoplay; encrypted-media" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
21
+ HEREDOC
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Embed
6
+ # Gem identity information.
7
+ module Identity
8
+ def self.name
9
+ "integral-video-embed"
10
+ end
11
+
12
+ def self.label
13
+ "Integral Video Embed"
14
+ end
15
+
16
+ def self.version
17
+ "0.1.12"
18
+ end
19
+
20
+ def self.version_label
21
+ "#{label} #{version}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Embed
6
+ module Instagram
7
+
8
+ require "time"
9
+
10
+ class << self
11
+ def html(uid:, text:, username:, account_name:, time_iso:)
12
+ time = Time.iso8601(time_iso)
13
+
14
+ <<~HEREDOC
15
+ <blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="https://www.instagram.com/p/#{uid}/" data-instgrm-version="12" style="background:#FFF; border: 0; border-radius: 3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width: 540px; min-width: 326px; padding: 0; width: 99.375%; width: -webkit-calc(100% - 2px); width: calc(100% - 2px);">
16
+ <div style="padding: 16px;">
17
+ <a href="https://www.instagram.com/p/#{uid}/" style="background:#FFFFFF; line-height: 0; padding: 0 0; text-align: center; text-decoration: none; width: 100%;" target="_blank">
18
+ <div style="display: flex; flex-direction: row; align-items: center;">
19
+ <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div>
20
+ <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;">
21
+ <div style="background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div>
22
+ <div style="background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div>
23
+ </div>
24
+ </div>
25
+ <div style="padding: 19% 0;"></div>
26
+ <div style="display:block; height: 50px; margin: 0 auto 12px; width: 50px;">
27
+ <svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink">
28
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
29
+ <g transform="translate(-511.000000, -20.000000)" fill="#000000">
30
+ <path d="M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631"></path>
31
+ </g>
32
+ </g>
33
+ </svg>
34
+ </div>
35
+ <div style="padding-top: 8px;">
36
+ <div style="color: #3897f0; font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: 550; line-height: 18px;">Открыть в Instagram</div>
37
+ </div>
38
+ <div style="padding: 12.5% 0;"></div>
39
+ <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;">
40
+ <div>
41
+ <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div>
42
+ <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div>
43
+ <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div>
44
+ </div>
45
+ <div style="margin-left: 8px;">
46
+ <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div>
47
+ <div style="width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div>
48
+ </div>
49
+ <div style="margin-left: auto;">
50
+ <div style="width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div>
51
+ <div style="background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div>
52
+ <div style="width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div>
53
+ </div>
54
+ </div>
55
+ </a>
56
+ <p style="margin: 8px 0 0 0; padding: 0 4px;"> <a href="https://www.instagram.com/p/#{uid}/" style="color: #000; font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 17px; text-decoration: none; word-wrap: break-word;" target="_blank">#{text}</a></p>
57
+ <p style="color: #c9c8cd; font-family: Arial, sans-serif; font-size: 14px; line-height: 17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding: 8px 0 7px; text-align: center; text-overflow: ellipsis; white-space: nowrap;">Пост <a href="https://www.instagram.com/#{username}/" style="color: #c9c8cd; font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; line-height: 17px;" target="_blank">#{account_name}</a> (@#{username}) on <time style="font-family: Arial, sans-serif; font-size: 14px; line-height: 17px;" datetime="#{time.iso8601}">#{time.strftime("%-d %B %Y, %H:%M")}</time></p>
58
+ </div>
59
+ </blockquote>
60
+
61
+ <script async src="https://www.instagram.com/embed.js"></script>
62
+ HEREDOC
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Embed
6
+ module Labnol
7
+ class << self
8
+ def html(uid, thumbnail: nil)
9
+ fail ArgumentError, "`uid` must be provided, you passed #{uid.inspect}" if uid.nil? || uid == ""
10
+ thumbnail = nil if thumbnail == ""
11
+ [
12
+ "<div",
13
+ " class=\"labnol__youtube-player\"",
14
+ " data-id=\"#{uid}\"",
15
+ (" data-thumbnail=\"#{thumbnail}\"" if thumbnail),
16
+ "></div>"
17
+ ].reject(&:nil?).join
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "provider"
4
+ require_relative "embed/identity"
5
+ require_relative "embed/generic"
6
+ require_relative "embed/bootstrap"
7
+ require_relative "embed/labnol"
8
+ require_relative "embed/instagram"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ module Poster
6
+
7
+ def youtube_poster(uid)
8
+ "https://i.ytimg.com/vi/#{uid}/maxresdefault.jpg"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Integral
4
+ module Video
5
+ class Provider
6
+
7
+ DB = [
8
+ {
9
+ color: "#e60000",
10
+ embed_url: "https://www.youtube.com/embed/${uid}?rel=0",
11
+ fa_icon: "youtube",
12
+ name: "YouTube",
13
+ page_url: "https://youtube.com/watch/?v=${uid}",
14
+ poster_url: "https://i.ytimg.com/vi/${uid}/maxresdefault.jpg",
15
+ uid: "youtube"
16
+ }, {
17
+ color: "#e50054",
18
+ embed_url: "https://odysee.com/$/embed/${uid}",
19
+ fa_icon: nil,
20
+ name: "Odysee",
21
+ page_url: "https://odysee.com/@LIFTINGTHEVEIL:5/How-to-save-the-world,-in-three-easy-steps.:9",
22
+ poster_url: nil,
23
+ uid: "odysee"
24
+ }, {
25
+ color: "#00ADEF",
26
+ embed_url: "https://player.vimeo.com/video/${uid}",
27
+ fa_icon: "vimeo-square",
28
+ name: "Vimeo",
29
+ page_url: "https://vimeo.com/${uid}",
30
+ poster_url: nil,
31
+ uid: "vimeo"
32
+ }, {
33
+ color: "#45668e",
34
+ embed_url: "https://vk.com/video_ext.php?oid=${oid}&id=${id}&hash=${hash}&hd=2",
35
+ fa_icon: "vk",
36
+ name: "Вконтакте",
37
+ page_url: "https://vk.com/video${uid}",
38
+ poster_url: nil,
39
+ uid: "vkontakte"
40
+ }
41
+ ].freeze
42
+
43
+
44
+ # Methods
45
+
46
+ def initialize(name)
47
+ fail ArgumentError, "`Provider name` must be provided" if name.nil? || name == ""
48
+ self.class.find_by(name: name) || fail(ArgumentError, "Provider `name` not supported. Currently supported: #{self.class.names.join(", ")}")
49
+ @name = name
50
+ end
51
+
52
+
53
+ def iframe_src(uid, hash=nil)
54
+ validate_uid! uid
55
+
56
+ if @name == "Вконтакте"
57
+ fail ArgumentError, "`uid` you provided (#{uid.inspect}) is not a valid VK UID" unless uid.include? "_"
58
+ fail ArgumentError, "`hash` must be provided for videos from VK, you passed #{hash.inspect}" if hash.nil? || hash == ""
59
+ oid, id = uid.split("_")
60
+ provider_hash[:embed_url].sub("${id}", id).sub("${oid}", oid).sub("${hash}", hash)
61
+ else
62
+ provider_hash[:embed_url].sub("${uid}", uid)
63
+ end
64
+ end
65
+
66
+
67
+ def fa_icon_id
68
+ provider_hash[:fa_icon]
69
+ end
70
+
71
+
72
+ def fa_icon
73
+ "<span class=\"fa fa-#{fa_icon_id}\" style=\"color: #{provider_hash[:color]}\"></span>".html_safe
74
+ end
75
+
76
+
77
+ def page_url(uid)
78
+ validate_uid! uid
79
+ return unless provider_hash[:page_url]
80
+ provider_hash[:page_url].sub("${uid}", uid)
81
+ end
82
+
83
+
84
+ def poster_url(uid)
85
+ validate_uid! uid
86
+ return unless provider_hash[:poster_url]
87
+ provider_hash[:poster_url].sub("${uid}", uid)
88
+ end
89
+
90
+
91
+ private
92
+
93
+
94
+ def provider_hash
95
+ self.class.find_by(name: @name)
96
+ end
97
+
98
+
99
+ def validate_uid!(uid)
100
+ fail ArgumentError, "`uid` must be provided, you passed #{uid.inspect}" if uid.nil? || uid == ""
101
+ end
102
+
103
+
104
+ # Class methods
105
+
106
+ class << self
107
+
108
+ def all
109
+ DB
110
+ end
111
+
112
+ def for_select
113
+ DB.map { |hash| [ hash[:name], hash[:name] ] }
114
+ end
115
+
116
+ def find_by(name: nil, uid: nil)
117
+ fail ArgumentError, "Either `name` or `uid` must be provided" if [name, uid].all?(&:nil?)
118
+ return DB.select { |hash| hash[:name] == name }.first unless uid
119
+ return DB.select { |hash| hash[:uid] == uid }.first unless name
120
+ end
121
+
122
+ def names
123
+ DB.map { |hash| hash[:name] }
124
+ end
125
+
126
+ end
127
+
128
+ end
129
+ end
130
+ end
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: integral-video-embed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.12
5
+ platform: ruby
6
+ authors:
7
+ - Sergey Pedan
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bundler-audit
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: gemsmith
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: git-cop
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: guard-rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: pry
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: pry-byebug
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rake
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: reek
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: rspec
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ - !ruby/object:Gem::Dependency
139
+ name: rubocop
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ - !ruby/object:Gem::Dependency
153
+ name: rubocop-rspec
154
+ requirement: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ type: :development
160
+ prerelease: false
161
+ version_requirements: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ email:
167
+ - sergey.pedan@gmail.com
168
+ executables: []
169
+ extensions: []
170
+ extra_rdoc_files:
171
+ - LICENSE.md
172
+ - README.md
173
+ files:
174
+ - LICENSE.md
175
+ - README.md
176
+ - lib/integral/video/embed.rb
177
+ - lib/integral/video/embed/bootstrap.rb
178
+ - lib/integral/video/embed/generic.rb
179
+ - lib/integral/video/embed/identity.rb
180
+ - lib/integral/video/embed/instagram.rb
181
+ - lib/integral/video/embed/labnol.rb
182
+ - lib/integral/video/poster.rb
183
+ - lib/integral/video/provider.rb
184
+ homepage: https://github.com/sergeypedan/integral-video-embed
185
+ licenses:
186
+ - MIT
187
+ metadata:
188
+ source_code_uri: https://github.com/sergeypedan/integral-video-embed
189
+ changelog_uri: https://github.com/sergeypedan/integral-video-embed/blob/master/CHANGES.md
190
+ bug_tracker_uri: https://github.com/sergeypedan/integral-video-embed/issues
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '2.5'
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubygems_version: 3.7.1
206
+ specification_version: 4
207
+ summary: Helps embed video from known providers
208
+ test_files: []