<commit_before># ActiveModel::Exporters
[![Build Status](https://travis-ci.org/alejandrogutierrez/active_model_exporters.png?branch=master)](https://travis-ci.org/alejandrogutierrez/active_model_exporters) [![Coverage Status](https://coveralls.io/repos/alejandrogutierrez/active_model_exporters/badge.png)](https://coveralls.io/r/alejandrogutierrez/active_model_exporters)

`ActiveModel::Exporters` aims to provide an easy way to export
collections of `ActiveModel` or `ActiveRecord` objects.
It's based on object-oriented development and inspired on
[active_model_serializers](https://github.com/rails-api/active_model_serializers).

## Installation

Add this line to your Gemfile:
```ruby
gem 'active_model_exporters'
```
Run the bundle command to install it.

## Usage

Generate an exporter in `app/exporters/post_exporter.rb`:
```ruby
class PostExporter < ActiveModel::Exporter
  attributes :id, :name, :email
end
```

In your controller:
```ruby
class PostsController < ApplicationController
  def index
    @posts = Post.all

    respond_to do |format|
      format.csv { render csv: @posts }
    end
  end
end
```

### Custom exporter
To specify a custom exporter for an object, you can do the next:
```ruby
render csv: @posts, exporter: OtherPostExporter
```

### Attributes
As `ActiveModel::Serializers` does, you can access the object being exported as `object`.
```ruby
class PostExporter < ActiveModel::Exporter
  attributes :id, :name, :full_name

  def full_name
    "#{object.name} #{object.last_name}"
  end
end
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request<commit_msg>Adding TO-DOs to README file<commit_after># ActiveModel::Exporters
[![Build Status](https://travis-ci.org/alejandrogutierrez/active_model_exporters.png?branch=master)](https://travis-ci.org/alejandrogutierrez/active_model_exporters) [![Coverage Status](https://coveralls.io/repos/alejandrogutierrez/active_model_exporters/badge.png)](https://coveralls.io/r/alejandrogutierrez/active_model_exporters)

`ActiveModel::Exporters` aims to provide an easy way to export
collections of `ActiveModel` or `ActiveRecord` objects.
It's based on object-oriented development and inspired on
[active_model_serializers](https://github.com/rails-api/active_model_serializers).

## Installation

Add this line to your Gemfile:
```ruby
gem 'active_model_exporters'
```
Run the bundle command to install it.

## Getting started

Generate an exporter in `app/exporters/post_exporter.rb`:
```ruby
class PostExporter < ActiveModel::Exporter
  attributes :id, :name, :email
end
```

In your controller:
```ruby
class PostsController < ApplicationController
  def index
    @posts = Post.all

    respond_to do |format|
      format.csv { render csv: @posts }
    end
  end
end
```

### Custom exporter
To specify a custom exporter for an object, you can do the next:
```ruby
render csv: @posts, exporter: OtherPostExporter
```

### Attributes
As `ActiveModel::Serializers` does, you can access the object being exported as `object`.
```ruby
class PostExporter < ActiveModel::Exporter
  attributes :id, :name, :full_name

  def full_name
    "#{object.name} #{object.last_name}"
  end
end
```

## TO-DO
* User scope
* Filter attributes

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
{'fraction_non_alphanumeric': 0.11674008810572688, 'fraction_numerical': 0.0027533039647577094, 'mean_word_length': 5.189097103918228, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 10, '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': '545941', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1129, 'n_words': 345}