Magic Data is a lean and un-opinionated data generator where you provide the generation techniques! Generators can be set as a block or as a static value. Data generation is handled by requesting a specifc key or modifying a passed in hash. Most importantly, Magic Data supports retrieving the most recently generated value of any key!
Add this line to your application's Gemfile:
gem 'magic_data'
Input keys can be strings or symbols, you decide!
MagicData.set('~username') {rand(36**10).to_s(36) << '.51d281ef@mailosaur.io'}
MagicData.set(:password) {rand(36**10).to_s(36)}
Input values will be converted to a string for retrieval.
MagicData.set('~existing_username', 'tk8817@test.com')
MagicData.set('~existing_username', FigNewton.existing_password) #example uses Cheezy's FigNewton lib
This will return a value generated from the block provided during creation
MagicData.get('~username')
# => ch3jdb68sjhnss21.51d281ef@mailosaur.io
MagicData.get(:password)
# => h4dnsah28s2hs27hd3
Non existent values will return as nil
MagicData.get_latest(:password)
# => h4dnsah28s2hs27hd3
MagicData.get_latest('not_real')
# => nil
input = {user_login: '~username', :user_password => :password, user_phone: '555-555-5555'}
MagicData.process(input)
# => {user_login: 'vb39hsb2s.51d281ef@mailosaur.io', user_password: '9fj4h3hnssoqlks', user_phone: '555-555-5555'}
input = {user_login: '~username', user_password: '~password', user_phone: '555-555-5555'}
MagicData.process(input, true)
# => {user_login: 'dh2nsh17ahs.51d281ef@mailosaur.io', user_password: 'k4jn60d2ja'}
This will return the static value set during creation
MagicData.get('~existing_username')
# => tk8817@test.com
There is not much value in this, but you can do it.
MagicData.get__latest('~existing_username')
# => tk8817@test.com
The gem is available as open source under the terms of the MIT License.