RandomNameGenerator

Gem Version Build Status Code Climate Dependency Status Coverage Status Inline docs

Ruby port of java-random-name-generator, which in turn is a gradle enabled version of Sinipull's GPL'd post on codecall.net.

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.


Installation

Add this line to your application's Gemfile:

gem 'random_name_generator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install random_name_generator

Usage

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 = RandomNameGenerator.new
puts rng.compose(3)

Pass in a reference to specific syllable file to get different styles of random names:

rng = RandomNameGenerator.new(RandomNameGenerator::GOBLIN)
puts rng.compose(3)

Flip mode will create a RandomNameGenerator object, randomly assigning the syllable file for you.

flip = RandomNameGenerator.flip_mode
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:

bin/random_name_generator [-efgr?]

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:

Development

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.

Dependencies

Alternatives

There are several other great name generator gems. They really aren't designed for fantasy style names.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/folkengine/random_name_generator.