Thursday, I wrote the following code into my text editor:
##
# Life is more fun with spots.
class Dalmatian < Base
flexible :dalmatian
class << self
# .. much code ..
end
end
Well, I’m not sure how flexible I am feeling, but let’s try it out:
spotcheck(dev):007> require 'faker/creature/dog/dalmatian'
=> true
spotcheck(dev):008> Faker::Creature::Dog::Dalmatian
=> Faker::Creature::Dog::Dalmatian
spotcheck(dev):009> Faker::Creature::Dog::Dalmatian.name
=> "Darien"
spotcheck(dev):010> Faker::Creature::Dog::Dalmatian.classic_name
=> "Cadpig"
spotcheck(dev):011> Faker::Creature::Dog::Dalmatian.series_episode
=> "The Artist Formerly Known as Spot"
spotcheck(dev):012> Faker::Creature::Dog::Dalmatian.street_episode
=> "Girls' Day Out"
spotcheck(dev):013> 10.times { print Faker::Creature::Dog::Dalmatian.name + "\n" }
Darcy
DJ
Dinga
Dinlo
Denzel
Pongo
Darby
Donny
Da Vinci
Lucky
=> 10
spotcheck(dev):014>
Cool.
I kind of didn’t intend to invent a Ruby module that could give you a random Dalmatian name and/or episode title, but you know. Life finds a way.
And in the process of doing this, I ended up doing an absurd amount of research on what all of Pongo and Perdita’s puppies are named. As a quasi-librarian, it is my duty to be as accurate as possible and consult primary sources. And it was so easy to find Delilah and Doug’s puppies! And catchy to boot!
So, only 65 of the Original 99 have canonical names. But hey. It looks like they had a second litter considering their canonically-biological named puppies number 21! I’m sure it was a relief to Perdita that this second litter was only six puppies.
And because the universe is weird, this research all ended up in a single, easy-to-reference YAML file. Because, you know, why not? Why the dog not. And I wrote a faker plugin around it, so you can now use Dalmatian puppies as your example customer names in your Ruby on Rails e-commerce site’s test code. Because, you know, also why the dog not?
Next up: writing an API service around it, so we can have IRC and Discord bots use it, I guess. Until then, stay spotty, everyone!