YamlDb::Anonymizer
Dumps anonymized database contents to a YAML file. This is useful if you want to develop Rails applications with near-live data from your server. Based on yaml_db.
(c) 2012 by Thomas Hollstegge
Installation
Add this line to your application's Gemfile:
gem 'yaml_db_anonymizer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install yaml_db_anonymizer
Usage
- Specify the database fields to anonymize, e.g. in
config/initializers/yaml_db_anonymizer.rb
:
YamlDb::Anonymizer.define do
table :users
remove :encrypted_password
replace :name, with: 'John Doe'
replace :phone, with: ->(phone) { phone.to_s[0..-3] + '***' }
end
table :logs do
truncate
end
end
Run
rake db:data:dump_anonymized
on your server. This creates an anonymized dump indb/data.yml
Copy
db/data.yml
to your local machineRun
rake db:data:load
on your local machine.
Todo
- Provide capistrano integration
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
MIT License. Copyright 2012 by Thomas Hollstegge