<commit_before># Has face
An Active model validator to validate that images contain faces by
using the face.com API. The validator works by uploading images to
face.com and then checking to see if any faces were tagged in the photo.
It has been tested with carrierwave attachments but will work with any
attachment type that correctly responds to a `path` method.

## Requirements
- Rails 3.0 or greater
- An account for accessing the face.com API (They are free at the moment)

## Installation
Add has_face to your Gemfile and then bundle

``` ruby
gem 'has_face'
```

Once installed run the generator to create an initializer

``` ruby
rails g has_face:install
```

Then open up `config/initializers/has_face.rb` and enter your face.com
API details.

``` ruby
# config/initializers/has_face.rb
HasFace.configure do |config|
  config.api_key    = 'your face.com API key'
  config.api_secret = 'your face.com API secret'
end
```

## Usage

Simply add a validation to the image you want to ensure has faces:

``` ruby
class User < ActiveRecord::Base
  validates :avatar, :has_face => true
end
```

## i18n

Error messages generated are i18n safe. To alter the error message shown
add this to your `config/locale/en.yml`

``` ruby
en:
  activerecord:
    errors:
      messages:
        no_face: "We couldn't see a face in your photo, try taking another one."
```

## Skipping face validations for testing

Face validations can be turned off for testing by setting the
`enable_validation` config value to false, this is usally best done in
your test config.

``` ruby
HasFace.enable_validation = false
```

### Contributing

Fork on GitHub and after you’ve committed tested patches, send a pull request.

To get tests running simply run `bundle install` and then `rspec spec`

For the tests to pass you'll need to enter a valid API key and
secret into the spec helper.<commit_msg>readme formatting.<commit_after># Has face
An Active model validator to validate that images contain faces by
using the face.com API. The validator works by uploading images to
face.com and then checking to see if any faces were tagged in the photo.
It has been tested with carrierwave attachments but will work with any
attachment type that correctly responds to a `path` method.

## Requirements
- Rails 3.0 or greater
- An account for accessing the face.com API (They are free at the moment)

## Installation
Add has_face to your Gemfile and then bundle

``` ruby
  gem 'has_face'
```

Once installed run the generator to create an initializer

``` ruby
  rails g has_face:install
```

Then open up `config/initializers/has_face.rb` and enter your face.com
API details.

``` ruby
# config/initializers/has_face.rb
  HasFace.configure do |config|
    config.api_key    = 'your face.com API key'
    config.api_secret = 'your face.com API secret'
  end
```

## Usage

Simply add a validation to the image you want to ensure has faces:

``` ruby
  class User < ActiveRecord::Base
    validates :avatar, :has_face => true
  end
```

## i18n

Error messages generated are i18n safe. To alter the error message shown
add this to your `config/locale/en.yml`

``` ruby
  en:
    activerecord:
      errors:
        messages:
          no_face: "We couldn't see a face in your photo, try taking another one."
```

## Skipping face validations for testing

Face validations can be turned off for testing by setting the
`enable_validation` config value to false, this is usally best done in
your test config.

``` ruby
  HasFace.enable_validation = false
```

### Contributing

Fork on GitHub and after you’ve committed tested patches, send a pull request.

To get tests running simply run `bundle install` and then `rspec spec`

For the tests to pass you'll need to enter a valid API key and
secret into the spec helper.
{'fraction_non_alphanumeric': 0.0704299657082564, 'fraction_numerical': 0.0031653917172250064, 'mean_word_length': 3.8929032258064518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '159148', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1059, 'n_words': 532}