Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD Faker::Games:DnD #1966

Merged
merged 2 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/games/dnd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Faker::Games::DnD

```ruby
Faker::Games::DnD.race #=> "Dwarf"

Faker::Games::DnD.klass #=> "Warlock"

Faker::Games::DnD.background #=> "Urchin"

Faker::Games::DnD.alignment #=> "Lawful Neutral"
```
61 changes: 61 additions & 0 deletions lib/faker/games/dnd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

module Faker
class Games
class DnD < Base
class << self
##
# Produces the name of a race from Dungeons and Dragons (PHB).
#
# @return [String]
#
# @example
# Faker::Games::DnD.race #=> "Dwarf"
#
# @faker.version next
def species
fetch('dnd.species')
end

##
# Produces the name of a class from Dungeons and Dragons (PHB).
#
# @return [String]
#
# @example
# Faker::Games::DnD.klass #=> "Warlock"
#
# @faker.version next
def klass
fetch('dnd.klasses')
end

##
# Produces the name of a background from Dungeons and Dragons (PHB).
#
# @return [String]
#
# @example
# Faker::Games::DnD.background #=> "Urchin"
#
# @faker.version next
def background
fetch('dnd.backgrounds')
end

##
# Produces the name of an alignment from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.alignment #=> "Lawful Neutral"
#
# @faker.version next
def alignment
fetch('dnd.alignments')
end
end
end
end
end
54 changes: 54 additions & 0 deletions lib/locales/en/dnd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
en:
faker:
dnd:
species:
- Dragonborn
- Dwarf
- Elf
- Gnome
- Half-Elf
- Halfling
- Half-Orc
- Human
- Tielfing
klasses:
- Barbarian
- Bard
- Cleric
- Druid
- Fighter
- Monk
- Paladin
- Ranger
- Rogue
- Sorcerer
- Warlock
- Wizard
backgrounds:
- Acolyte
- Charlatan
- Criminal
- Entertainer
- Folk Hero
- Gladiator
- Guild Artisan
- Guild Merchant
- Hermit
- Noble
- Outlander
- Pirate
- Sage
- Sailor
- Soldier
- Spy
- Urchin
alignments:
- Lawful Good
- Neutral Good
- Chaotic Good
- Lafwul Neutral
- Neutral
- Chaotic Neutral
- Lawful Evil
- Neutral Evil
- Chaotic Evil
25 changes: 25 additions & 0 deletions test/faker/games/test_dnd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require_relative '../../test_helper'

class TestFakerDnD < Test::Unit::TestCase
def setup
@tester = Faker::Games::DnD
end

def test_species
assert @tester.species.match(/\w+/)
end

def test_klass
assert @tester.klass.match(/\w+/)
end

def test_background
assert @tester.background.match(/\w+/)
end

def test_alignment
assert @tester.alignment.match(/\w+/)
end
end