<commit_before># Obfuscator

Working from a production database dump can often be helpful for
debugging strange errors and edge cases, but having potentially
sensitive user data on a development machine is a dangerous liability.

Obfuscator provides a clean, friendly API for obfuscating sensitive
columns in your Ruby on Rails application's models.

## Installation

Add this line to your application's Gemfile:

    gem 'obfuscator'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install obfuscator

## Usage

As a Ruby program:

```ruby
# Without a format, Obfuscator will fill all of the given columns
# with dummy data based on the column's SQL type
Obfuscator.scrub! "Message" do
  # Would generate dummy sentences, paragraphs, and timestamps accordingly
  overwrite :title, :body, :created_at
end

# Currently any format from Faker::Internet
# (https://github.com/stympy/faker/blob/master/lib/faker/internet.rb)
# should work for when the generated data needs to be in a specific format
Obfuscator.scrub! "User" do
  overwrite :login do
    format :user_name
  end
end

Obfuscator.scrub! "Subscriber" do
  overwrite :email_address do
    format :email
  end
end
```

Or as a Rake task (TODO: Not finished yet):

    rake obfuscator:scrub["User", ["login","email"]]

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## TODO

* Get Rake task fully working
* Move away from iterating through all records and calling
  update_attributes. Better: finding in batches. Best: Generating a
  giant update_all.
* Definite jankiness with the Dsl (especially that you can't pass
  multiple overwrite/format blocks in one parent block currently)<commit_msg>Updates to todos in readme<commit_after># Obfuscator

Working from a production database dump can often be helpful for
debugging strange errors and edge cases, but having potentially
sensitive user data on a development machine is a dangerous liability.

Obfuscator provides a clean, friendly API for obfuscating sensitive
columns in your Ruby on Rails application's models.

## Installation

Add this line to your application's Gemfile:

    gem 'obfuscator'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install obfuscator

## Usage

As a Ruby program:

```ruby
# Without a format, Obfuscator will fill all of the given columns
# with dummy data based on the column's SQL type
Obfuscator.scrub! "Message" do
  # Would generate dummy sentences, paragraphs, and timestamps accordingly
  overwrite :title, :body, :created_at
end

# Currently any format from Faker::Internet
# (https://github.com/stympy/faker/blob/master/lib/faker/internet.rb)
# should work for when the generated data needs to be in a specific format
Obfuscator.scrub! "User" do
  overwrite :login do
    format :user_name
  end
end

Obfuscator.scrub! "Subscriber" do
  overwrite :email_address do
    format :email
  end
end
```

Or as a Rake task (TODO: Not finished yet):

    rake obfuscator:scrub["User", ["login","email"]]

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## TODO

* Get Rake task fully working
* Move away from iterating through all records and calling
  update_attributes. Better: finding in batches. Best: Generating a
  giant update_all.
* Fix jankiness with the Dsl (especially that you can't pass
  multiple overwrite/format blocks in one parent block currently)
* Reflect on model validations to ensure generated data is valid
{'fraction_non_alphanumeric': 0.07009713835652402, 'fraction_numerical': 0.002625360987135731, 'mean_word_length': 4.262430939226519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2030961', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1086, 'n_words': 505}