<commit_before># Shrine::Imgix

Provides [Imgix] integration for [Shrine].

## Installation

```ruby
gem "shrine-imgix"
```

## Usage

Imgix doesn't upload files directly, but instead it transfers images from
various sources (S3, Web Folder or Web Proxy), so you first need to set that up
(see the [Imgix documentation]). After this is set up, the Imgix Shrine
"storage" is used as a wrapper around the main storage of the source:

```rb
require "shrine/storage/imgix"
require "shrine/storage/s3"

s3 = Shrine::Storage::S3.new(**s3_options)
imgix = Shrine::Storage::Imgix.new(
  storage: s3,
  host: "my-subdomain.imgix.net",
  token: "abc<PASSWORD>",
)

Shrine.storages[:store] = imgix
```

All options other than `:storage` are used for instantiating an `Imgix::Client`,
so see the [imgix] gem for information about all possible options.

All storage actions are forwarded to the main storage, and deleted files are
automatically purged from Imgix. The only method that the Imgix storage
overrides is, of course, `#url`:

```rb
post.image.url(w: 150, h: 200, fit: "crop")
#=> "http://my-subdomain.imgix.net/943kdfs0gkfg.jpg?w=150&h=200&fit=crop"
```

## Development

The tests for shrine-imgix uses S3, so you'll have to create an `.env` file with
appropriate credentials:

```sh
# .env
IMGIX_API_KEY="..."
IMGIX_HOST="..."
S3_ACCESS_KEY_ID="..."
S3_SECRET_ACCESS_KEY="..."
S3_REGION="..."
S3_BUCKET="..."
```

Afterwards you can run the tests:

```rb
bundle exec rake test
```<commit_msg>Add link to Imgix docs' URL options<commit_after># Shrine::Imgix

Provides [Imgix] integration for [Shrine].

## Installation

```ruby
gem "shrine-imgix"
```

## Usage

Imgix doesn't upload files directly, but instead it transfers images from
various sources (S3, Web Folder or Web Proxy), so you first need to set that up
(see the [Imgix documentation]). After this is set up, the Imgix Shrine
"storage" is used as a wrapper around the main storage of the source:

```rb
require "shrine/storage/imgix"
require "shrine/storage/s3"

s3 = Shrine::Storage::S3.new(**s3_options)
imgix = Shrine::Storage::Imgix.new(
  storage: s3,
  host: "my-subdomain.imgix.net",
  token: "abc<PASSWORD>",
)

Shrine.storages[:store] = imgix
```

All options other than `:storage` are used for instantiating an `Imgix::Client`,
so see the [imgix] gem for information about all possible options.

All storage actions are forwarded to the main storage, and deleted files are
automatically purged from Imgix. The only method that the Imgix storage
overrides is, of course, `#url`:

```rb
post.image.url(w: 150, h: 200, fit: "crop")
#=> "http://my-subdomain.imgix.net/943kdfs0gkfg.jpg?w=150&h=200&fit=crop"
```

See the [Imgix docs](https://www.imgix.com/docs/reference) for all available
URL options.

## Development

The tests for shrine-imgix uses S3, so you'll have to create an `.env` file with
appropriate credentials:

```sh
# .env
IMGIX_API_KEY="..."
IMGIX_HOST="..."
S3_ACCESS_KEY_ID="..."
S3_SECRET_ACCESS_KEY="..."
S3_REGION="..."
S3_BUCKET="..."
```

Afterwards you can run the tests:

```sh
$ bundle exec rake test
```
{'fraction_non_alphanumeric': 0.13755247013238617, 'fraction_numerical': 0.01743622860833064, 'mean_word_length': 4.747680890538033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '5052847', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1077, 'n_words': 369}