no_embed 0.1.1 → 0.1.2
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/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/Rakefile +8 -0
- data/lib/no_embed/version.rb +5 -0
- data/lib/no_embed.rb +31 -0
- data/sig/no_embed.rbs +4 -0
- metadata +10 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 777374db86246138085d8592570dc84b717e251c541a5ea149f31204e9f4549f
|
|
4
|
+
data.tar.gz: 04eed2bbb5aa713678c78296a0fb20c467db52b2d73d6eaa8cd899a864288ee1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b457a217ebfff3b1589cbca617397a924d51a594c0d37cca0cc629b14f3a093dd77d81150461b7e61b426bdd0ae0b3eb9c94445786437763c755403c94ca3dd1
|
|
7
|
+
data.tar.gz: a41a178a46f6ffed164cee5f51d27b4e3c3094abcbb0b23300cdcf8793fbd0aa3c0a1a22af36e83ef90ccca95fa5b3f4c2a27a2dd20851876b1798a797508748
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 mykbren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# NoEmbed Gem
|
|
2
|
+
|
|
3
|
+
A lightweight Ruby wrapper for the [NoEmbed API](https://noembed.com/). Quickly fetch rich embed data for URLs with a simple method call.
|
|
4
|
+
Noembed little bit outdated, and lot's of endpoints already not supported. This gem was created for getting YouTube embeds, which works fine.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
- Fetch embed data for any URL supported by NoEmbed (some of them outdated and doesn't work).
|
|
8
|
+
- Pass optional parameters like `maxwidth` and `maxheight` for responsive embeds.
|
|
9
|
+
- Simple error handling for invalid or unsupported URLs.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Add this line to your application's Gemfile:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'no_embed'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bundle install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or install it manually:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
gem install no_embed
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Basic Example
|
|
38
|
+
Fetch embed data for a URL:
|
|
39
|
+
```ruby
|
|
40
|
+
require 'no_embed'
|
|
41
|
+
|
|
42
|
+
url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
|
|
43
|
+
embed_data = NoEmbed.get_embed_for_url(url)
|
|
44
|
+
|
|
45
|
+
puts embed_data['title'] # => "Rick Astley - Never Gonna Give You Up"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Additional Parameters
|
|
49
|
+
Pass optional parameters like `maxwidth` to resize the embed content:
|
|
50
|
+
```ruby
|
|
51
|
+
embed_data = NoEmbed.get_embed_for_url(url, maxwidth: 300)
|
|
52
|
+
puts embed_data['html']
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Error Handling
|
|
56
|
+
Handle cases where the API returns an error:
|
|
57
|
+
```ruby
|
|
58
|
+
begin
|
|
59
|
+
embed_data = NoEmbed.get_embed_for_url('https://invalid.url')
|
|
60
|
+
rescue StandardError => e
|
|
61
|
+
puts "Error: #{e.message}"
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Parameters
|
|
68
|
+
|
|
69
|
+
The `get_embed_for_url` method supports the following parameters:
|
|
70
|
+
|
|
71
|
+
| Parameter | Description |
|
|
72
|
+
|-------------|--------------------------------------------------------|
|
|
73
|
+
| `maxwidth` | Maximum width (in pixels) for the embed content. |
|
|
74
|
+
| `maxheight` | Maximum height (in pixels) for the embed content. |
|
|
75
|
+
| Other | Any other query parameters supported by NoEmbed API. |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Return Value
|
|
80
|
+
|
|
81
|
+
The method returns a Ruby `Hash` containing the following fields (if available):
|
|
82
|
+
|
|
83
|
+
- `title`: Title of the embed content.
|
|
84
|
+
- `author_name`: Author of the content.
|
|
85
|
+
- `provider_name`: Name of the embed provider.
|
|
86
|
+
- `html`: HTML embed code (iframe or other rich content).
|
|
87
|
+
- `width`, `height`: Dimensions of the embed.
|
|
88
|
+
|
|
89
|
+
For a full list of fields, refer to the [NoEmbed API Documentation](https://noembed.com/).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
To contribute or test locally:
|
|
96
|
+
|
|
97
|
+
1. Clone the repository:
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/mykbren/no_embed.git
|
|
100
|
+
cd no_embed
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Install dependencies:
|
|
104
|
+
```bash
|
|
105
|
+
bundle install
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
3. Run tests:
|
|
109
|
+
```bash
|
|
110
|
+
bundle exec rspec
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Testing the Gem Locally
|
|
116
|
+
|
|
117
|
+
To test the gem without publishing it:
|
|
118
|
+
|
|
119
|
+
1. Build the gem:
|
|
120
|
+
```bash
|
|
121
|
+
gem build no_embed.gemspec
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2. Install it locally:
|
|
125
|
+
```bash
|
|
126
|
+
gem install ./no_embed-0.1.2.gem
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
3. Use it in a Ruby script or add it to a project via `Gemfile`:
|
|
130
|
+
```ruby
|
|
131
|
+
gem 'no_embed', path: '/path/to/local/no_embed'
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
This gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
139
|
+
|
|
140
|
+
---
|
data/Rakefile
ADDED
data/lib/no_embed.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
require_relative 'no_embed/version'
|
|
5
|
+
|
|
6
|
+
module NoEmbed
|
|
7
|
+
API_ENDPOINT = 'https://noembed.com/embed'
|
|
8
|
+
|
|
9
|
+
class << self
|
|
10
|
+
def get_embed_for_url(url, **params)
|
|
11
|
+
raise ArgumentError, 'URL is required' if url.nil? || url.empty?
|
|
12
|
+
|
|
13
|
+
uri = URI(API_ENDPOINT)
|
|
14
|
+
uri.query = URI.encode_www_form({ url: url }.merge(params))
|
|
15
|
+
|
|
16
|
+
response = Net::HTTP.get_response(uri)
|
|
17
|
+
parse_response(response)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def parse_response(response)
|
|
23
|
+
case response
|
|
24
|
+
when Net::HTTPSuccess
|
|
25
|
+
JSON.parse(response.body)
|
|
26
|
+
else
|
|
27
|
+
raise StandardError, "NoEmbed API Error: #{response.message}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/sig/no_embed.rbs
ADDED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: no_embed
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mykbren
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Use Noembed to get oEmbed data from supported resources
|
|
14
14
|
email:
|
|
@@ -16,7 +16,13 @@ email:
|
|
|
16
16
|
executables: []
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
|
-
files:
|
|
19
|
+
files:
|
|
20
|
+
- LICENSE.txt
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- lib/no_embed.rb
|
|
24
|
+
- lib/no_embed/version.rb
|
|
25
|
+
- sig/no_embed.rbs
|
|
20
26
|
homepage:
|
|
21
27
|
licenses:
|
|
22
28
|
- MIT
|
|
@@ -37,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
37
43
|
- !ruby/object:Gem::Version
|
|
38
44
|
version: '0'
|
|
39
45
|
requirements: []
|
|
40
|
-
rubygems_version: 3.
|
|
46
|
+
rubygems_version: 3.4.6
|
|
41
47
|
signing_key:
|
|
42
48
|
specification_version: 4
|
|
43
49
|
summary: Noembed API ruby wrapper
|