Kovacs
Kovacs is one of the most common surnames in Eastern Europe from Slovakia to Hungary to Croatia. (This is the Hungarian form). It means blacksmith in English. With this gem we can smith names based on nationalities.
Kovacs is a simple gem that helps you generate fake data for a person entity based on real life names, nationalities and sex.
Installation
Add this line to your application's Gemfile:
gem 'kovacs'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kovacs
Usage
1. Simpliest
Just simply generate a person. It takes a nationality from the listed nationalities placed inside the resources
folder. (nationality has to be a folder as well.)
Then it generates a sex and based on these two, it generates names.
p Kovacs.generate
p Kovacs.generate.to_h
2. Generate just one of the attributes
p Kovacs.forename(['Jancsi', 'Julcsi'])
3. Generate via config
person = Kovacs.config do |config|
config.surname = :hungarian
config.forename = 'Elek'
config.middle_name = ['Karoly', 'Erno', 'Ervin']
config.sex = :male
config.nationality = [:hungarian, :slovak]
end.generate
p person
4. Acceptable arguments
- None: will be generated based on the nationalities, sex and list of names placed in
resources
.
Kovacs.forename
- Simple String: the value will be the string argument itself.
Kovacs.forename('Jancsi')
- Symbol: symbol represents the nationality. Value will be generated based on the specified nationality, and sex which is randomly generated.
Kovacs.forename(:hungarian)
- Nationality and sex: Value will be generated based on the spedified nationality and the specified sex.
Kovacs.forename(:hungarian, :male)
- Array of Strings: One of them will be taken randomly.
Kovacs.forename(['Jancsi', 'Julcsi'])
- Array of Symbols: One of them will be taken randomly, name is taken randomly based on that nationality.
Kovacs.forename([:hungarian, :slovak])
- Array of Symbols and sex: Nationality will be taken randomly, name is taken randomly based on that nationality and specified sex.
Kovacs.forename([:hungarian, :slovak], :female)
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. 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.
Plugin for names
- Create a folder inside the
resources
folder. (from this time, this is considered as nationality, whichever name you would pick for it) - Place the following files in the newly created folder:
male_forename.txt
female_forename.txt
surname.txt
- Content of these files is considered as forenames and surnames grouped as female and male names.
- You can refere to this nationality by using symbols.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/torokmark/kovacs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the Kovacs project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.