<commit_before># dm-is-voteable
[![Build
Status](https://travis-ci.org/brianp/dm-is-voteable.png?branch=master)](https://travis-ci.org/brianp/dm-is-voteable)
[![Code
Climate](https://codeclimate.com/github/brianp/dm-is-voteable.png)](https://codeclimate.com/github/brianp/dm-is-voteable)

A DataMapper compatible voting gem. Can track votes by identifier so a user may only submit a single vote.

## Requirments
* Ruby 1.9

## Installation
To install as a gem add the following line to your gem file.
`gem 'dm-is-voteable'`

Then:
`bundle install`

And build the required DB tables:
`rake db:auto_update`
 
## Example

Add `is_voteable` To any model and gain the power of the vote method.

```ruby
class Movie
  include DataMapper::Resource

  property :id, Serial
  
  is_voteable
  
  property :title, String, required: true
end
```

Vote for the Model by calling `model.vote`

## Voting Restrictions

Allow only a single vote per user within a certain time frame by setting a time frame in the model:

```ruby
class Movie
  include DataMapper::Resource

  property :id, Serial
  
  is_voteable(time_between_votes: ->{ 3.days.ago })
  
  property :title, String, required: true
end
```

Then send an identifier along with the vote:
<commit_msg>update readme.<commit_after># dm-is-voteable
[![Build
Status](https://travis-ci.org/brianp/dm-is-voteable.png?branch=master)](https://travis-ci.org/brianp/dm-is-voteable)
[![Code
Climate](https://codeclimate.com/github/brianp/dm-is-voteable.png)](https://codeclimate.com/github/brianp/dm-is-voteable)

A DataMapper compatible voting gem. Can track votes by identifier so a user may only submit a single vote.

## Requirments
* Ruby 1.9

## Installation
To install as a gem add the following line to your gem file.
`gem 'dm-is-voteable'`

Then:
`bundle install`

And build the required DB tables:
`rake db:auto_update`
 
## Example

Add `is_voteable` To any model and gain the power of the vote method.

```ruby
class Movie
  include DataMapper::Resource

  property :id, Serial
  
  is_voteable
  
  property :title, String, required: true
end
```

Vote for the Model by calling `model.vote`

## Voting Restrictions

Allow only a single vote per user within a certain time frame by setting a time frame in the model:

```ruby
class Movie
  include DataMapper::Resource

  property :id, Serial
  
  is_voteable(last_vote_time: ->{ 3.days.ago })
  
  property :title, String, required: true
end
```

Then send an identifier along with the vote:

{'fraction_non_alphanumeric': 0.10887906789875453, 'fraction_numerical': 0.0024106066693451184, 'mean_word_length': 4.220125786163522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, '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': '3536034', 'n_tokens_mistral': 840, 'n_tokens_neox': 817, 'n_words': 275}