MtwtfssYamlDb::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.
Installation
Add this line to your application's Gemfile:
gem 'mtwtfss_yaml_db_anonymizer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mtwtfss_yaml_db_anonymizer
Usage
- Specify the database fields to anonymize, e.g. in
config/initializers/mtwtfss_yaml_db_anonymizer.rb
:
MtwtfssYamlDb::Anonymizer.define do
table :users do
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 in db/data.yml
-
Copy db/data.yml
to your local machine
-
Run 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.