GithubHelp home page GithubHelp logo

kevinburkeomg / acts_as_scrubbable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from onemedical/acts_as_scrubbable

0.0 0.0 0.0 29 KB

Scrub sensitive data from your non-production environments

Ruby 100.00%

acts_as_scrubbable's Introduction

ActsAsScrubbable

Scrubbing made easy

Acts as scrubbable give you model level access to scrub your data per object.

It runs using the parallel gem for faster processing which is dependent on the amount of cores available on the box. More cores == faster scrubbing

Installation

gem 'acts_as_scrubbable'

Usage

Simple add the configuration for your fields that map directly to your columns

class User < ActiveRecord::Base
  ...

  acts_as_scrubbable :first_name, :last_name


  # optionally you can add a scope to limit the rows to update
  scope :scrubbable_scope, -> { where(some_value: true) }

  ...
end

Incase the mapping is not straight forward

class Address
  acts_as_scrubbable :lng => :longitude, :lat => :latitude
end

To run

The confirmation message will be the db host

rake scrub

....
2015-11-19 10:52:51 -0800: [WARN] - Please verify the information below to continue
2015-11-19 10:52:51 -0800: [WARN] - Host:  127.0.0.1
2015-11-19 10:52:51 -0800: [WARN] - Database: blog_development
Type '127.0.0.1' to continue.
-> 127.0.0.1
2015-11-19 10:52:51 -0800: [WARN] -- : Scrubbing classes
2015-11-19 10:52:51 -0800: [WARN] -- : Scrubbing ClassToScrub
...
2015-11-19 10:52:51 -0800: [WARN] -- : Scrub Complete!

In the case you are automating the rake task and want to skip the confirmation

rake scrub SKIP_CONFIRM=true

If you want to limit the classes you to be scrubbed you can set the SCRUB_CLASSES variable

rake scrub SCRUB_CLASSES=Blog,Post

If you want to skip the afterhook

rake scrub SKIP_AFTERHOOK=true

Extending

You may find the need to extend or add additional generators or an after_hook

ActsAsScrubbable.configure do |c|
  c.add :email_with_prefix, -> { "prefix-#{Faker::Internet.email}" }

  c.after_hook do
    puts "Running after commit"
    ActiveRecord::Base.connection.execute("TRUNCATE some_table")
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.