memorable name generator gem for ruby

流过昼夜 提交于 2019-12-31 17:37:55

问题


Before I go roll my own and start pulling out the dictionary, does anyone know a rubygem to generate memorable names suitable for app keys. I need something pronounceable so that I can give users unique email addresses to submit content to. I like Heroku's naming for it's apps as an example.

floating-sky-58
simple-fog-45

回答1:


You can use randexp gem. It's use the dictionnary from your OS ( UNIX only )

with randexp gem you can do something like :

/[:word:]-[:word:]-\d+/.gen

and have like heroku naming.

If your server has no dict library install you can try faker or Lorem

but really much limitated.




回答2:


I just did an implementation of this for a project and my solution was to use the Forgery gem and something like this:

[Forgery::Basic.color, Forgery::Address.street_name.split(" ").first, rand(100)].join("-").downcase

This results in strings like this:

=> "orange-nobel-93"
=> "indigo-holmberg-41"
=> "khaki-sunfield-31"
=> "goldenrod-warrior-92"
=> "fuscia-manley-75"
=> "violet-village-17"
=> "violet-west-11"
=> "goldenrod-oak-74"
=> "yellow-hermina-74"
=> "red-shopko-36"
=> "purple-esch-43"
=> "teal-sutherland-44"
=> "blue-butterfield-56"
=> "yellow-mcbride-41"



回答3:


Take a look at my gem, does exactly this

gem 'bazaar'

Bazaar.heroku
=> "inquisitive-cavern-6617"
=> "jubilant-sunset-9301"
=> "frightened-geyser-4542"

https://rubygems.org/gems/bazaar




回答4:


The haikunator gem is a good choice.



来源:https://stackoverflow.com/questions/4104766/memorable-name-generator-gem-for-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!