https://github.com/norman/babosa
A library for creating slugs. Babosa is an extraction and improvement of the string code from FriendlyId, intended to help developers create similar libraries or plugins.
https://github.com/norman/babosa
Keywords from Contributors
activerecord ruby-gem activejob mvc nokogiri friendly-url slug rubygems
Last synced: about 2 hours ago
JSON representation
Repository metadata
A library for creating slugs. Babosa is an extraction and improvement of the string code from FriendlyId, intended to help developers create similar libraries or plugins.
- Host: GitHub
- URL: https://github.com/norman/babosa
- Owner: norman
- License: mit
- Created: 2010-06-28T20:55:05.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2023-07-24T08:32:12.000Z (over 2 years ago)
- Last Synced: 2026-02-11T16:50:30.484Z (20 days ago)
- Language: Ruby
- Homepage:
- Size: 546 KB
- Stars: 536
- Watchers: 6
- Forks: 56
- Open Issues: 3
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: MIT-LICENSE
README.md
Babosa
Babosa is a library for creating human-friendly identifiers, aka "slugs". It can
also be useful for normalizing and sanitizing data.
It is an extraction and improvement of the string code from
FriendlyId. I have released this as a
separate library to help developers who want to create libraries similar to
FriendlyId.
Features / Usage
Transliterate UTF-8 characters to ASCII
"Gölcük, Turkey".to_slug.transliterate.to_s #=> "Golcuk, Turkey"
Locale sensitive transliteration, with support for many languages
"Jürgen Müller".to_slug.transliterate.to_s #=> "Jurgen Muller"
"Jürgen Müller".to_slug.transliterate(:german).to_s #=> "Juergen Mueller"
Currently supported languages include:
- Bulgarian
- Danish
- German
- Greek
- Hindi
- Macedonian
- Norwegian
- Romanian
- Russian
- Serbian
- Spanish
- Swedish
- Turkish
- Ukrainian
- Vietnamese
Additionally there are generic transliterators for transliterating from the
Cyrillic alphabet and Latin alphabet with diacritics. The Latin transliterator
can be used, for example, with Czech. There is also a transliterator named
"Hindi" which may be sufficient for other Indic languages using Devanagari, but
I do not know enough to say whether the transliterations would make sense.
I'll gladly accept contributions from fluent speakers to support more languages.
Strip non-ASCII characters
"Gölcük, Turkey".to_slug.to_ascii.to_s #=> "Glck, Turkey"
Truncate by characters
"üüü".to_slug.truncate(2).to_s #=> "üü"
Truncate by bytes
This can be useful to ensure the generated slug will fit in a database column
whose length is limited by bytes rather than UTF-8 characters.
"üüü".to_slug.truncate_bytes(2).to_s #=> "ü"
Remove punctuation chars
"this is, um, **really** cool, huh?".to_slug.word_chars.to_s #=> "this is um really cool huh"
All-in-one
"Gölcük, Turkey".to_slug.normalize.to_s #=> "golcuk-turkey"
Other stuff
Using Babosa With FriendlyId 4+
require "babosa"
class Person < ActiveRecord::Base
friendly_id :name, use: :slugged
def normalize_friendly_id(input)
input.to_s.to_slug.normalize(transliterations: :russian).to_s
end
end
UTF-8 support
Babosa normalizes all input strings to NFC.
Ruby Method Names
Babosa can generate strings for Ruby method names. (Yes, Ruby 1.9+ can use
UTF-8 chars in method names, but you may not want to):
"this is a method".to_slug.to_ruby_method! #=> this_is_a_method
"über cool stuff!".to_slug.to_ruby_method! #=> uber_cool_stuff!
# You can also disallow trailing punctuation chars
"über cool stuff!".to_slug.to_ruby_method(allow_bangs: false) #=> uber_cool_stuff
Easy to Extend
You can add custom transliterators for your language with very little code. For
example here's the transliterator for German:
module Babosa
module Transliterator
class German < Latin
APPROXIMATIONS = {
"ä" => "ae",
"ö" => "oe",
"ü" => "ue",
"Ä" => "Ae",
"Ö" => "Oe",
"Ü" => "Ue"
}
end
end
end
And a spec (you can use this as a template):
require "spec_helper"
describe Babosa::Transliterator::German do
let(:t) { described_class.instance }
it_behaves_like "a latin transliterator"
it "should transliterate Eszett" do
t.transliterate("ß").should eql("ss")
end
it "should transliterate vowels with umlauts" do
t.transliterate("üöä").should eql("ueoeae")
end
end
Rails 3.x and higher
Some of Babosa's functionality was added to Active Support 3.0.0.
Babosa now differs from ActiveSupport primarily in that it supports non-Latin
strings by default, and has per-locale ASCII transliterations already baked-in.
If you are considering using Babosa with Rails, you may want to first take a
look at Active Support's
transliterate
and
parameterize
to see if they suit your needs.
Please see the API docs and source code for
more info.
Getting it
Babosa can be installed via Rubygems:
gem install babosa
You can get the source code from its Github repository.
Reporting bugs
Please use Babosa's Github issue
tracker.
Misc
"Babosa" means "slug" in Spanish.
Maintainers
Contributors
Many thanks to the following people for their help:
- Dmitry A. Ilyashevich - Deprecation fixes
- anhkind - Vietnamese support
- Martins Zakis - Bug fixes
- Vassilis Rodokanakis - Greek support
- Peco Danajlovski - Macedonian support
- Philip Arndt - Bug fixes
- Jonas Forsberg - Swedish support
- Jaroslav Kalistsuk - Greek support
- Steven Heidel - Bug fixes
- Edgars Beigarts - Support for multiple transliterators
- Tiberiu C. Turbureanu - Romanian support
- Kim Joar Bekkelund - Norwegian support
- Alexey Shkolnikov - Russian support
- Martin Petrov - Bulgarian support
- Molte Emil Strange Andersen - Danish support
- Milan Dobrota - Serbian support
- Norman Clarke - Original author
Copyright
Copyright (c) 2010-2021 Norman Clarke and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Owner metadata
- Name: Norman Clarke
- Login: norman
- Email:
- Kind: user
- Description: Upstate New Yorker transplanted to Buenos Aires. Developer and amateur musician.
- Website:
- Location: Buenos Aires, Argentina
- Twitter: compay
- Company: @bentohq
- Icon url: https://avatars.githubusercontent.com/u/5042?u=8dac771545311e86c62eee4ed1319767d8b4a86c&v=4
- Repositories: 71
- Last ynced at: 2023-04-10T08:56:55.634Z
- Profile URL: https://github.com/norman
GitHub Events
Total
- Watch event: 10
Last Year
- Watch event: 6
Committers metadata
Last synced: 1 day ago
Total Commits: 250
Total Committers: 30
Avg Commits per committer: 8.333
Development Distribution Score (DDS): 0.272
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Norman Clarke | n****n@n****m | 182 |
| Philip Arndt | g****t@p****o | 20 |
| Aaditya Taparia | a****a@c****m | 6 |
| Dmitry A. Ilyashevich | d****h@g****m | 4 |
| Vassilis Rodokanakis | v****s@g****r | 4 |
| Denys Kurets | d****1@g****m | 3 |
| Peco Danajlovski | p****o@i****m | 2 |
| Edward Tippett | e****t@g****m | 2 |
| Jaroslav Kalistsuk | j****k@g****m | 2 |
| Jonas Forsberg | h****s@g****m | 2 |
| Peco Danajlovski | v****k@g****m | 2 |
| Tiberiu C. Turbureanu | t****t@c****g | 2 |
| Tomasz Wielgocki | w****i@g****m | 2 |
| burningTyger | b****r | 1 |
| Stephen Rushe | s****e | 1 |
| Martins Zakis | m****s@t****m | 1 |
| Milan Dobrota | e****g@g****m | 1 |
| Steven Heidel | s****n@l****a | 1 |
| anguyen | a****n@e****m | 1 |
| Robert Reiz | r****1@g****m | 1 |
| Kim Joar Bekkelund | k****d@g****m | 1 |
| Jan Lelis | m****l@j****e | 1 |
| Igor Victor | g****a@y****u | 1 |
| Hu Chen | h****3@g****m | 1 |
| Hamdi Akoğuz | h****z@p****m | 1 |
| Filipe Goncalves | l****e@g****m | 1 |
| Edgars Beigarts | e****s@m****v | 1 |
| Balasankar "Balu" C | b****c@a****g | 1 |
| Anton Rieder | 1****r | 1 |
| Andrey Melnik | a****k@i****m | 1 |
Committer domains:
- autistici.org: 1
- makit.lv: 1
- phonoclick.com: 1
- yandex.ru: 1
- janlelis.de: 1
- elctech.com: 1
- livingskyweb.ca: 1
- tieto.com: 1
- ceata.org: 1
- invideous.com: 1
- generation-y.gr: 1
- cookpad.com: 1
- p.arndt.io: 1
- njclarke.com: 1
Issue and Pull Request metadata
Last synced: 3 days ago
Total issues: 22
Total pull requests: 51
Average time to close issues: over 1 year
Average time to close pull requests: 5 months
Total issue authors: 18
Total pull request authors: 35
Average comments per issue: 1.68
Average comments per pull request: 1.14
Merged pull request: 39
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- norman (3)
- parndt (2)
- Smackstrider007 (2)
- molte (1)
- nazarok (1)
- Hamdiakoguz (1)
- basex (1)
- pskarlas (1)
- maia (1)
- jonleighton (1)
- balasankarc (1)
- Ericzhiluo (1)
- dbackeus (1)
- faizalzakaria (1)
- blutorange (1)
Top Pull Request Authors
- parndt (12)
- Vortex (3)
- vrodokanakis (2)
- bogdanvlviv (2)
- michalvalasek (2)
- stevenheidel (1)
- Hamdiakoguz (1)
- jarosan (1)
- martins (1)
- alexshk (1)
- cattekin (1)
- balasankarc (1)
- tiwi (1)
- aried3r (1)
- kimjoar (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 12
-
Total downloads:
- rubygems: 307,473,252 total
- Total docker downloads: 906,757,236
- Total dependent packages: 45 (may contain duplicates)
- Total dependent repositories: 23,397 (may contain duplicates)
- Total versions: 56
- Total maintainers: 2
gem.coop: babosa
A library for creating slugs. Babosa an extraction and improvement of the string code from FriendlyId, intended to help developers create similar libraries or plugins.
- Homepage: http://github.com/norman/babosa
- Documentation: http://www.rubydoc.info/gems/babosa/
- Licenses: MIT
- Latest release: 2.0.0 (published over 4 years ago)
- Last Synced: 2026-03-02T21:02:24.958Z (1 day ago)
- Versions: 23
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 153,788,384 Total
- Docker Downloads: 453,378,618
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.082%
- Docker downloads count: 0.163%
- Downloads: 0.165%
- Maintainers (2)
ubuntu-22.04: ruby-babosa
- Homepage: https://github.com/norman/babosa
- Licenses: mit
- Latest release: 1.0.4-2 (published 18 days ago)
- Last Synced: 2026-02-13T13:13:16.317Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.416%
- Stargazers count: 0.729%
- Forks count: 0.933%
rubygems.org: babosa
A library for creating slugs. Babosa an extraction and improvement of the string code from FriendlyId, intended to help developers create similar libraries or plugins.
- Homepage: http://github.com/norman/babosa
- Documentation: http://www.rubydoc.info/gems/babosa/
- Licenses: MIT
- Latest release: 2.0.0 (published over 4 years ago)
- Last Synced: 2026-03-02T00:02:03.629Z (2 days ago)
- Versions: 23
- Dependent Packages: 45
- Dependent Repositories: 23,397
- Downloads: 153,684,868 Total
- Docker Downloads: 453,378,618
-
Rankings:
- Downloads: 0.184%
- Dependent repos count: 0.232%
- Docker downloads count: 0.311%
- Dependent packages count: 0.585%
- Average: 1.215%
- Stargazers count: 2.471%
- Forks count: 3.508%
- Maintainers (2)
debian-11: ruby-babosa
- Homepage: https://github.com/norman/babosa
- Documentation: https://packages.debian.org/bullseye/ruby-babosa
- Licenses:
- Latest release: 1.0.4-1 (published 21 days ago)
- Last Synced: 2026-02-13T08:18:44.633Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-10: ruby-babosa
- Homepage: http://github.com/norman/babosa
- Documentation: https://packages.debian.org/buster/ruby-babosa
- Licenses:
- Latest release: 1.0.2-2 (published 20 days ago)
- Last Synced: 2026-02-13T04:19:21.957Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-babosa
- Homepage: https://github.com/norman/babosa
- Documentation: https://packages.debian.org/bookworm/ruby-babosa
- Licenses:
- Latest release: 1.0.4-2 (published 19 days ago)
- Last Synced: 2026-02-12T23:25:45.478Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-babosa
- Homepage: https://github.com/norman/babosa
- Documentation: https://packages.debian.org/trixie/ruby-babosa
- Licenses:
- Latest release: 2.0.0-1 (published 19 days ago)
- Last Synced: 2026-02-13T13:13:35.094Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- racc >= 0
- rake >= 0 development
- rspec >= 3.7.0 development
- simplecov >= 0 development
- standard >= 1.1.7 development
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
Score: 30.60830957540499