fjrodafo-slugify 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1c941d66924e42a1cd3da556c1e77658e73e7705ccf6ae43f18531c93653339
4
+ data.tar.gz: 954c58c1db7626347da1cdc2850a0c27de7f043c976d0b6c1af1fd293e1612fb
5
+ SHA512:
6
+ metadata.gz: 8c9ee1458512334876071eeb0834faed738455e9dc5f2d86d686412dc9e4b531edc607ad653947e80ba75651821de5696981afe4adb8bbe27e24048031bfae1a
7
+ data.tar.gz: 42bdcca08e19037a2e3196662480b4e5ce698dc0a59ef56796feb544e481e9013c6527a2e98a849021889ffd4da77a3072779ee466be0746c4a65b0dd9d32d65
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "fjrodafo/slugify"
4
+
5
+ puts FJrodafo::Slugify.to_slug("Hola, Mundo!")
@@ -0,0 +1,16 @@
1
+ module FJrodafo
2
+ module Slugify
3
+ module Transliteration
4
+ MAP = {
5
+ "ø" => "o",
6
+ "ß" => "ss",
7
+ "æ" => "ae",
8
+ "œ" => "oe",
9
+ "ł" => "l"
10
+ }.freeze
11
+
12
+ FROM = MAP.keys.join.freeze
13
+ TO = MAP.values.join.freeze
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "slugify/transliteration"
2
+
3
+ module FJrodafo
4
+ module Slugify
5
+ def self.to_slug(text)
6
+ return "" if text.nil?
7
+
8
+ text
9
+ .to_s
10
+ .downcase
11
+ .strip
12
+ .unicode_normalize(:nfd)
13
+ .tr(
14
+ Transliteration::FROM,
15
+ Transliteration::TO
16
+ )
17
+ .gsub(/\p{Mn}/, "")
18
+ .gsub(/[^a-z0-9\s-]/, "")
19
+ .gsub(/[\s_-]+/, "-")
20
+ .gsub(/^-+|-+$/, "")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require "minitest/autorun"
2
+ require "fjrodafo/slugify"
3
+
4
+ class FJrodafoSlugifyTest < Minitest::Test
5
+ def test_hello_world
6
+ assert_equal "hello-world",
7
+ FJrodafo::Slugify.to_slug("Hello, World!")
8
+ end
9
+
10
+ def test_hola_mundo
11
+ assert_equal "hola-mundo-1234-slugify-ruby",
12
+ FJrodafo::Slugify.to_slug(" ¡¡¡HólA--- MüñdØ 1234!!! ### Slugify--Ruby 💎 ")
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fjrodafo-slugify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Francisco José Rodríguez Afonso
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple slugify gem!
14
+ email: fjrodafo@gmail.com
15
+ executables:
16
+ - fjrodafo-slugify
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/fjrodafo-slugify
21
+ - lib/fjrodafo/slugify.rb
22
+ - lib/fjrodafo/slugify/transliteration.rb
23
+ - test/test_fjrodafo-slugify.rb
24
+ homepage: https://github.com/FJrodafo/Slugify
25
+ licenses:
26
+ - CC0-1.0
27
+ metadata:
28
+ github_repo: https://github.com/FJrodafo/Slugify
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.3.15
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Slugify!
48
+ test_files:
49
+ - test/test_fjrodafo-slugify.rb