<commit_before># Ruby Object Mapper

[![Gem Version](https://badge.fury.io/rb/rom.png)][gem]
[![Build Status](https://travis-ci.org/rom-rb/rom.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/rom-rb/rom.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/rom-rb/rom.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/rom-rb/rom/badge.png?branch=master)][coveralls]

[gem]: https://rubygems.org/gems/rom
[travis]: https://travis-ci.org/rom-rb/rom
[gemnasium]: https://gemnasium.com/rom-rb/rom
[codeclimate]: https://codeclimate.com/github/rom-rb/rom
[coveralls]: https://coveralls.io/r/rom-rb/rom

The mapper supports mapping data from any data source into Ruby objects
based on mapper definitions. It uses [axiom](https://github.com/dkubb/axiom),
a relational algebra library which will give us the ability to talk to
different data sources and even performing cross-database joins.

## Establishing Connection & Defining PORO with mappers

``` ruby
# Define a PORO
class User
  attr_reader :id, :name

  def initialize(attributes)
    @id, @name = attributes.values_at(:id, :name)
  end
end

# Create ROM environment
config = { :default => 'postgres://localhost/test' }
env    = ROM::Environment.coerce(config)

# Define a mapper
env.build(User, :postgres) do
  relation_name :users

  map :id,   Integer, :key => true<commit_msg>Fixed Gemnasium badge<commit_after># Ruby Object Mapper

[![Gem Version](https://badge.fury.io/rb/rom.png)][gem]
[![Build Status](https://travis-ci.org/rom-rb/rom.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/rom-rb/rom-relation.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/rom-rb/rom.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/rom-rb/rom/badge.png?branch=master)][coveralls]

[gem]: https://rubygems.org/gems/rom
[travis]: https://travis-ci.org/rom-rb/rom
[gemnasium]: https://gemnasium.com/rom-rb/rom-relation
[codeclimate]: https://codeclimate.com/github/rom-rb/rom
[coveralls]: https://coveralls.io/r/rom-rb/rom

The mapper supports mapping data from any data source into Ruby objects
based on mapper definitions. It uses [axiom](https://github.com/dkubb/axiom),
a relational algebra library which will give us the ability to talk to
different data sources and even performing cross-database joins.

## Establishing Connection & Defining PORO with mappers

``` ruby
# Define a PORO
class User
  attr_reader :id, :name

  def initialize(attributes)
    @id, @name = attributes.values_at(:id, :name)
  end
end

# Create ROM environment
config = { :default => 'postgres://localhost/test' }
env    = ROM::Environment.coerce(config)

# Define a mapper
env.build(User, :postgres) do
  relation_name :users

  map :id,   Integer, :key => true
{'fraction_non_alphanumeric': 0.15627240143369175, 'fraction_numerical': 0.0, 'mean_word_length': 4.925690021231422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 22, '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': '274907', 'n_tokens_mistral': 974, 'n_tokens_neox': 961, 'n_words': 217}