The big difference between this random name generator and others is that it allows you to create names in various custom styles such as Elven, and Roman. If you're looking for a quick name for a Goblin NPC, RandomNameGenerator is your gem.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install random_name_generator
RandomNameGenerator comes with several styles of syllable files: Elven, Fantasy, Goblin, and Roman. By default it uses Fantasy. Instantiate RandomNameGenerator and then call compose on the object to generate a random name. If you don't pass in the number of syllables you want for your name to compose, it will randomly pick between 3 and 6.
require 'random_name_generator' rng = . puts rng.compose(3)
Pass in a reference to specific syllable file to get different styles of random names:
rng = .(::) puts rng.compose(3)
Flip mode will create a RandomNameGenerator object, randomly assigning the syllable file for you.
flip = . puts flip.compose
You can also pass in your own syllable files. See RNGSyllable.rb for the required specification.
RandomNameGenerator also comes with a command line interface which will generate a first and last name for you:
Add the gem's bin directory to you path in order to have instant access to RandomNameGenerator.
Porting and Refactoring Notes
The big refactoring over the original Java version is the creation of the RNGSyllable class. It takes over most of the complexity of parsing each syllable, greatly simplifying the Random Name Generator code.
Part of the reason for working on this gem was to work on the following goals to improve my Ruby craft:
- Code confidently in the spirit of Advi Grimm's Confident Ruby.
- Use Travis-CI for build validation.
- Use Rubocop and Reek for code quality.
- Deploy it to RubyGems.org.
After checking out the repo, run
bin/setup to install dependencies. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
There are several other great name generator gems. They really aren't designed for fantasy style names.
Bug reports and pull requests are welcome on GitHub at https://github.com/folkengine/random_name_generator.