<commit_before># Organizer

Organizer is a ruby gem that allows you to perform different actions like: filtering, ordering and default or custom operations over denormalized data, in order to produce a new data structure with the result.

## Installation

Add this line to your application's Gemfile:

```ruby
gem "organizer"
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install organizer
```

## Organizer Definition and Usage

First, you need to define an organizer like this:

```ruby
Organizer::Template.define("my_organizer") do
  # definition methods
end
```

To use it, you need to do:

```ruby
organizer = MyOrganizer.new
```

Inside define's method block, you can pass:

### A Collection

This method takes a block containing a denormalized collection. The block's content will be executed later. So, you can pass anything that produces a collection.

#### Definition Example

```ruby
Organizer::Template.define("my_organizer") do
  collection do
    [
      { age: 22, name: "<NAME>", site_id: 1, store_id: 1, gender: "M", savings: 20.50 },
      { age: 31, name: "Leandro", site_id: 1, store_id: 1, gender: "M", savings: 15.50 },
      { age: 64, name: "Susana", site_id: 2, store_id: 2, gender: "F", savings: 30.00 },
      { age: 65, name: "Rodolfo", site_id: 2, store_id: 2, gender: "M", savings: 50.20 },
      { age: 33, name: "Virginia", site_id: 2, store_id: 3, gender: "F", savings: 70.10 },
      { age: 8, name: "Francisco", site_id: 2, store_id: 3, gender: "M", savings: 2.50 },
      { age: 31, name: "Gustavo", site_id: 3, store_id: 4, gender: "M", savings: 40.50 },
      { age: 33, name: "Gabriela", site_id: 3, store_id: 4, gender: "F", savings: 45.50 },
      { age: 35, name: "Javier", site_id: 3, store_id: 5, gender: "M", savings: 25.50 }
    ]
  end
end
```

Also, you can pass options (filters usually) to get a desired raw collection: `organizer = MyOrganizer.new({attr1: 84})`.
These options will be present as the first param on collection definition like this:

```ruby
Organizer::Template.define("my_organizer") do
  collection do |collection_options|
    data = [
      { age: 22, name: "<NAME>", site_id: 1, store_id: 1, gender: "M", savings: 20.50 },
      { age: 31, name: "Leandro", site_id: 1, store_id: 1, gender: "M", savings: 15.50 },
      { age: 64, name: "Susana", site_id: 2, store_id: 2, gender: "F", savings: 30.00 },
      { age: 65, name: "Rodolfo", site_id: 2, store_id: 2, gender: "M", savings: 50.20 },
      { age: 33, name: "Virginia", site_id: 2, store_id: 3, gender: "F", savings: 70.10 },
      { age: 8, name: "Francisco", site_id: 2, store_id: 3, gender: "M", savings: 2.50 },
      { age: 31, name: "Gustavo", site_id: 3, store_id: 4, gender: "M", savings: 40.50 },
      { age: 33, name: "Gabriela", site_id: 3, store_id: 4, gender: "F", savings: 45.50 },
      { age: 35, name: "Javier", site_id: 3, store_id: 5, gender: "M", savings: 25.50 }
    ]
<commit_msg>docs(README): fix collection example<commit_after># Organizer

Organizer is a ruby gem that allows you to perform different actions like: filtering, ordering and default or custom operations over denormalized data, in order to produce a new data structure with the result.

## Installation

Add this line to your application's Gemfile:

```ruby
gem "organizer"
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install organizer
```

## Organizer Definition and Usage

First, you need to define an organizer like this:

```ruby
Organizer::Template.define("my_organizer") do
  # definition methods
end
```

To use it, you need to do:

```ruby
organizer = MyOrganizer.new
```

Inside define's method block, you can pass:

### A Collection

This method takes a block containing a denormalized collection. The block's content will be executed later. So, you can pass anything that produces a collection.

#### Definition Example

```ruby
Organizer::Template.define("my_organizer") do
  collection do
    [
      { age: 22, name: "<NAME>", site_id: 1, store_id: 1, gender: "M", savings: 20.50 },
      { age: 31, name: "Leandro", site_id: 1, store_id: 1, gender: "M", savings: 15.50 },
      { age: 64, name: "Susana", site_id: 2, store_id: 2, gender: "F", savings: 30.00 },
      { age: 65, name: "Rodolfo", site_id: 2, store_id: 2, gender: "M", savings: 50.20 },
      { age: 33, name: "Virginia", site_id: 2, store_id: 3, gender: "F", savings: 70.10 },
      { age: 8, name: "Francisco", site_id: 2, store_id: 3, gender: "M", savings: 2.50 },
      { age: 31, name: "Gustavo", site_id: 3, store_id: 4, gender: "M", savings: 40.50 },
      { age: 33, name: "Gabriela", site_id: 3, store_id: 4, gender: "F", savings: 45.50 },
      { age: 35, name: "Javier", site_id: 3, store_id: 5, gender: "M", savings: 25.50 }
    ]
  end
end
```

Also, you can pass options (filters usually) to get a desired raw collection: `organizer = MyOrganizer.new({ age: 33 })`.
These options will be present as the first param on collection definition like this:

```ruby
Organizer::Template.define("my_organizer") do
  collection do |collection_options|
    data = [
      { age: 22, name: "<NAME>", site_id: 1, store_id: 1, gender: "M", savings: 20.50 },
      { age: 31, name: "Leandro", site_id: 1, store_id: 1, gender: "M", savings: 15.50 },
      { age: 64, name: "Susana", site_id: 2, store_id: 2, gender: "F", savings: 30.00 },
      { age: 65, name: "Rodolfo", site_id: 2, store_id: 2, gender: "M", savings: 50.20 },
      { age: 33, name: "Virginia", site_id: 2, store_id: 3, gender: "F", savings: 70.10 },
      { age: 8, name: "Francisco", site_id: 2, store_id: 3, gender: "M", savings: 2.50 },
      { age: 31, name: "Gustavo", site_id: 3, store_id: 4, gender: "M", savings: 40.50 },
      { age: 33, name: "Gabriela", site_id: 3, store_id: 4, gender: "F", savings: 45.50 },
      { age: 35, name: "Javier", site_id: 3, store_id: 5, gender: "M", savings: 25.50 }
    ]

{'fraction_non_alphanumeric': 0.15736551030668677, 'fraction_numerical': 0.04776269482151835, 'mean_word_length': 3.7744, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3966034', 'n_tokens_mistral': 2381, 'n_tokens_neox': 2048, 'n_words': 776}