slug-utils 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 +7 -0
- data/README.md +16 -0
- data/Rakefile +4 -0
- data/lib/slug_utils/version.rb +5 -0
- data/lib/slug_utils.rb +19 -0
- data/sig/slug_utils.rbs +4 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3130cd1462c388b5770dd40d8746afffed54321250d6ee56260eb5fef042c1d9
|
|
4
|
+
data.tar.gz: 6fc250be6ff97bff0486ed11f0a8b162116ce5573537bad12adf92c71467163c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 78eaa3f609d7c93aa00e48abe7794959b7eec8c598ad8ec539866d7ce86659623e99acdd41912712feffeb6b05d7c1a3fc4bfc29b59b6214c05a6079cd28778a
|
|
7
|
+
data.tar.gz: f841f4d4af61f3bbd61e0825c78a379dcc21767b33bb791304e1f2c7aac1b299ff9cf2792fda594fa66430b47c6994f587371f9bea874325f529168335d787df
|
data/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# SlugUtils
|
|
2
|
+
|
|
3
|
+
Generate clean, SEO-friendly slugs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
gem "slug-utils", git: "https://github.com/tvthanh-2007/slug-utils.git", tag: "v0.1.0"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
SlugUtils.generate("Học Ruby on Rails 2025!")
|
|
15
|
+
# => "hoc-ruby-on-rails-2025"
|
|
16
|
+
```
|
data/Rakefile
ADDED
data/lib/slug_utils.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "slug_utils/version"
|
|
4
|
+
|
|
5
|
+
module SlugUtils
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
class InvalidText < Error; end
|
|
8
|
+
|
|
9
|
+
# Your code goes here...
|
|
10
|
+
def self.generate(text)
|
|
11
|
+
raise InvalidText, "Text cannot be blank" if text.nil? || text.strip.empty?
|
|
12
|
+
|
|
13
|
+
text.unicode_normalize(:nfkd)
|
|
14
|
+
.encode("ASCII", replace: "")
|
|
15
|
+
.downcase
|
|
16
|
+
.gsub(/[^a-z0-9]+/, "-")
|
|
17
|
+
.gsub(/^-|-$/, "")
|
|
18
|
+
end
|
|
19
|
+
end
|
data/sig/slug_utils.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: slug-utils
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Truong Van Thanh
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Generate URL-friendly slugs from text
|
|
13
|
+
email:
|
|
14
|
+
- truong.van.thanh@vareal.vn
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- Rakefile
|
|
21
|
+
- lib/slug_utils.rb
|
|
22
|
+
- lib/slug_utils/version.rb
|
|
23
|
+
- sig/slug_utils.rbs
|
|
24
|
+
homepage: https://github.com/tvthanh-2007/slug-ultis
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata: {}
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '3.0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.7.1
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Simple and clean slug generator
|
|
45
|
+
test_files: []
|