<commit_before># application_seeds

A library for managing a standardized set of seed data for applications
in a non-production environment.


## Requirements

* Postgresql - This library currently only works with the Postgresql
database.


## Usage

#### Include the gem in your Gemfile

    group :development, :test, :integration, :staging do
      gem 'application_seeds', :git => '<EMAIL>:centro/application_seeds.git'
    end


#### Create a rake task to create data model objects from the seed data

**The application** needs to create objects from the common seed data. To
do this, you will need to create a Rake task (such as the one
below) for your application that reads the seed data, and uses it to create the objects in
the application's own data model.

`ApplicationSeeds` provides an API to allow for the easy retrieveal of
seed data.  See below for more information about the API.

```ruby
namespace :application_seeds do
  desc 'Dump the development database and load it with standardized application seed data'
  task :load, [:dataset] => ['db:drop', 'db:create', 'db:migrate', :environment] do |t, args|
    ApplicationSeeds.dataset = args[:dataset]

    seed_campaigns
    seed_line_items
    seed_some_other_objects<commit_msg>Updates to README<commit_after># application_seeds

A library for managing a standardized set of seed data for applications
in a non-production environment.


## Requirements

* Rails
* Postgresql (This library currently only works with the Postgresql database)


## Usage

#### Include the gem in your Gemfile

    group :development do
      gem 'application_seeds', :git => '<EMAIL>:centro/application_seeds.git'
    end

You should add this gem to any environment group that would need access
to the seed data (like an "integration" environment, for example).


#### Create a shared data set

This library operates on a set of YAML files that represent your shared
data set.  The dataset can be provided two different ways.

##### Via a gem

In order to easily share the seed data between apps, you can package
the YAML files into a gem.  The gem should have the following directory
structure:

```
lib
 +-- seeds
      |-- seed_data_set_1
      |    |-- some_data.yml
      |    +-- some_other_data.yml
      +-- seed_data_set_2  
           |-- some_data.yml
           +-- some_other_data.yml
```

The gem may contain any number of datasets.  The above example has two datasets,
`seed_data_set_1` and `seed_data_set_2`.  The YAML files are located in the
dataset directories.

You will need to include the gem containing your seed data in your `Gemfile`.

Use the `data_gem_name` API method to specify where your seed data is located.

```ruby
ApplicationSeeds.data_gem_name = "my-seed-data-gem"
```

##### Via the filesystem

The dataset may also exist on the filesystem.  The directory structure should
be identical to what is described above in the "Via a gem" section, but the `lib`
diretory is not required.

```
seeds
 |-- seed_data_set_1
 |    |-- some_data.yml
 |    +-- some_other_data.yml
 +-- seed_data_set_2  
      |-- some_data.yml
      +-- some_other_data.yml
```

Use the `data_directory` API method to specify the path to your seed data on the filesystem.

```ruby
ApplicationSeeds.data_directory = "/path/to/seeds"
```

#### Create a rake task to create data model objects from the seed data

**The application** needs to create objects from the common seed data. To
do this, you will need to create a Rake task (such as the one
below) for your application that reads the seed data, and uses it to create the objects in
the application's own data model.

`ApplicationSeeds` provides an API to allow for the easy retrieveal of
seed data.  See below for more information about the API.

```ruby
namespace :application_seeds do
  desc 'Dump the development database and load it with standardized application seed data'
  task :load, [:dataset] => ['db:drop', 'db:create', 'db:migrate', :environment] do |t, args|
    ApplicationSeeds.data_gem_name = "my-seed-data-gem"
    ApplicationSeeds.dataset = args[:dataset]

    seed_campaigns
    seed_line_items
    seed_some_other_objects
{'fraction_non_alphanumeric': 0.07799711121810303, 'fraction_numerical': 0.0014443909484833895, 'mean_word_length': 3.8596491228070176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '5156658', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1160, 'n_words': 529}