<commit_before># Vigilion Rails
Rails engine for Vigilion - Virus Scanning Service

## Getting started

You can add Vigilion Rails to your Gemfile with:

```ruby
gem 'vigilion-rails'
```

Run the bundle command to install it.

After you install vigilion-rails and add it to your Gemfile, you need to run the generator:

```console
rails generate vigilion:install
```

The generator will install an initializer which describes Vigilion configuration options.
You need to set the api key with the value you obtained in http://vigilion.com/

To add a new file to be scanned simply specify the name of the column in your model:

```ruby
  scan_file :attachment
```

and run

```console
rails generate vigilion:scan Model attachment
```

Replace `Model` with the class name which contains the attachment. And replace `attachment` with your particular file column.

## Manually triggered scans

Supposing you have an attribute called `attachment` in your model:
To scan a file, just call `model.scan_attachment!`.
When the scan finishes, `model.attachment_scan_results` will be updated.

## Integrations

**vigilion-rails** provides **paperclip**, **carrierwave** and
**dragonfly** integration out-of-the-box. That means that
simply adding the `scan_file` command to your model, each time
a new file is uploaded, a scanning process will be
automatically scheduled.

Independently of the gem you use to upload files, there are two
integration strategies:

### URL integration

It sends `model.attachment.url` to the Vigilion's server. The
server uses this URL to download the file and perform the
scanning process. `attachment.url` must be an absolute path.
Use this integration with S3 and other storage services.

This is the default integration, so no additional configuration
is needed, but you can also explicitly configure it adding the
following option:

```ruby
  scan_file :attachment, integration: :url
```

### Local integration

This integration takes a local file path, reads the content of
the file and post it to the Vigilion's servers. The server
creates a temporary file with the content which will be deleted
after the scanning process is performed.

To configure local integration add the option to the scan_file
method:<commit_msg>improved readme<commit_after># Vigilion Rails
Rails engine for Vigilion - Virus Scanning Service

## Getting started

You can add Vigilion Rails to your Gemfile with:

```ruby
gem 'vigilion-rails'
```

Run the bundle command to install it.

After you install vigilion-rails and add it to your Gemfile, you need to run the generator:

```console
rails generate vigilion:install
```

The generator will install an initializer which describes Vigilion configuration options.
You need to set the api key with the value you obtained in http://vigilion.com/

To add a new file to be scanned simply specify the name of the column in your model:

```ruby
  scan_file :attachment
```

and run

```console
rails generate vigilion:scan Model attachment
```

Replace `Model` with the class name which contains the attachment. And replace `attachment` with your particular file column.

## Manually triggered scans

Supposing you have an attribute called `attachment` in your model:
To scan a file, just call `model.scan_attachment!`.
When the scan finishes, `model.attachment_scan_results` will be updated.

## Integrations

**vigilion-rails** provides **paperclip**, **carrierwave** and
**dragonfly** integration out-of-the-box. That means that
simply adding the `scan_file` command to your model, each time
a new file is uploaded, a scanning process will be
automatically scheduled.

Independently of the gem you use to upload files, there are two
integration strategies:

### URL integration

It sends `model.attachment.url` to the Vigilion's server. The
server uses this URL to download the file and perform the
scanning process. `attachment.url` must be an absolute path.
Use this integration with S3 and other storage services.

This is the default integration, so no additional configuration
is needed, but you can also explicitly configure it adding the
following option:

```ruby
  scan_file :attachment, integration: :url
```

### Local integration

This integration takes a local file path, reads the content of
the file and post it to the Vigilion's servers. The server
creates a temporary file with the content which will be deleted
after the scanning process is performed.

To configure local integration, add the following option to the scan_file
method:
{'fraction_non_alphanumeric': 0.061541879582315044, 'fraction_numerical': 0.00044434570095534326, 'mean_word_length': 4.839169909208819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '275853', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1137, 'n_words': 633}