Ruby wrapper library to call to Avataaars React component using NodeJS
Kudos to Pablo Stanley for creating the assets, Fang-Pen Lin for the React component and the Schmooze project for which the Ruby<->NodeJS integration was based on.
Add this line to your application's Gemfile:
gem 'avataaars'
npm install avataaars react react-dom
# Create an Avataaars SVG using the default attributes
avatar = Avataaars.new.create_avatar
# Create an Avataaars SVG using specific attributes
avatar = Avataaars.new(
avatar_style: 'Circle',
top_type: 'ShortHairShortFlat',
hair_color: 'BrownDark',
accessories_type: 'Round',
facial_hair_type: 'BeardMedium',
facial_hair_color: 'Auburn',
clothe_type: 'Hoodie',
clothe_color: 'PastelGreen',
eye_type: 'Surprised',
eyebrow_type: 'UpDown',
mouth_type: 'Disbelief',
skin_color: 'Brown'
).create_avatar
# When your node install is not in the PWD
avatar = Avataaars.new(root_path: 'some/other/path').create_avatar
😕 This was considered but was more of a maintenance issue. Given the assets/React component haven't seen much in the way of changes I may re-write the gem at some time to just implement the avatar creation. Upside would be a pretty massive speed boost as calling out to NodeJS like this isn't super performant.
The gem is available as open source under the terms of the MIT License.