<commit_before># Hanami::Shrine

This gem aims at providing support for [Shrine](https://github.com/janko-m/shrine) uploader in Hanami applications. It also tries to be as simple as possible, without polluting the world around.

[![Build Status](https://travis-ci.org/katafrakt/hanami-shrine.svg)](https://travis-ci.org/katafrakt/hanami-shrine)
[![Gem Version](https://badge.fury.io/rb/hanami-shrine.svg)](https://badge.fury.io/rb/hanami-shrine)
[![Code Climate](https://codeclimate.com/github/katafrakt/hanami-shrine/badges/gpa.svg)](https://codeclimate.com/github/katafrakt/hanami-shrine)

### Current compatibility status

* working with Hanami version 0.7.x
* working with Hanami version 0.8.x without validations (which have been extracted to separate gem)
* does not work work with Hanami 0.9.x (work in progress, see [#1](https://github.com/katafrakt/hanami-shrine/issues/1))

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'hanami-shrine'
```

And then execute:

    $ bundle

## Usage

Setup Shrine with `hanami` plugin enabled. Check [Shrine's repository](https://github.com/janko-m/shrine) for more detailed description of the process.

```ruby
class ImageAttachment < Shrine
  plugin :hanami
end
```

Then, in your repository add (assuming your attachment is `avatar`):

```ruby
prepend ImageAttachment.repository(:avatar)
```

And in your entity:

```ruby
include ImageAttachment[:avatar]
```

For inspiration read a [blog post](http://katafrakt.me/2016/02/04/shrine-hanami-uploads/), look at [the specs](https://github.com/katafrakt/hanami-shrine/tree/master/spec/hanami) or [example repo](https://github.com/katafrakt/hanami-shrine-example).

## Important changes since 0.1 version

As Hanami has been upgraded to 0.9, it started to use new engine for the entities in `hanami-model`. It required heavy changes in `hanami-shrine` to accomodate to new paradigm. Unfortunately, some of them are breaking. Here's a summary list:
* Validations are gone (for now, hopefully)
* You need to use `prepend` instead of `extend` in your repository
* Entities are now read-only. You need to initialize them with the attachment, not add it later: `MyEntity.new(avatar: File.open('my_avatar.png')`. This is a Hanami change, but it's worth mentioning here as well.<commit_msg>Update link to Shrine<commit_after># Hanami::Shrine

This gem aims at providing support for [Shrine](https://github.com/shrinerb/shrine) uploader in Hanami applications. It also tries to be as simple as possible, without polluting the world around.

[![Build Status](https://travis-ci.org/katafrakt/hanami-shrine.svg)](https://travis-ci.org/katafrakt/hanami-shrine)
[![Gem Version](https://badge.fury.io/rb/hanami-shrine.svg)](https://badge.fury.io/rb/hanami-shrine)
[![Code Climate](https://codeclimate.com/github/katafrakt/hanami-shrine/badges/gpa.svg)](https://codeclimate.com/github/katafrakt/hanami-shrine)

### Current compatibility status

* working with Hanami version 0.7.x
* working with Hanami version 0.8.x without validations (which have been extracted to separate gem)
* does not work work with Hanami 0.9.x (work in progress, see [#1](https://github.com/katafrakt/hanami-shrine/issues/1))

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'hanami-shrine'
```

And then execute:

    $ bundle

## Usage

Setup Shrine with `hanami` plugin enabled. Check [Shrine's repository](https://github.com/shrinerb/shrine) for more detailed description of the process.

```ruby
class ImageAttachment < Shrine
  plugin :hanami
end
```

Then, in your repository add (assuming your attachment is `avatar`):

```ruby
prepend ImageAttachment.repository(:avatar)
```

And in your entity:

```ruby
include ImageAttachment[:avatar]
```

For inspiration read a [blog post](http://katafrakt.me/2016/02/04/shrine-hanami-uploads/), look at [the specs](https://github.com/katafrakt/hanami-shrine/tree/master/spec/hanami) or [example repo](https://github.com/katafrakt/hanami-shrine-example).

## Important changes since 0.1 version

As Hanami has been upgraded to 0.9, it started to use new engine for the entities in `hanami-model`. It required heavy changes in `hanami-shrine` to accomodate to new paradigm. Unfortunately, some of them are breaking. Here's a summary list:
* Validations are gone (for now, hopefully)
* You need to use `prepend` instead of `extend` in your repository
* Entities are now read-only. You need to initialize them with the attachment, not add it later: `MyEntity.new(avatar: File.open('my_avatar.png')`. This is a Hanami change, but it's worth mentioning here as well.
{'fraction_non_alphanumeric': 0.12435008665511266, 'fraction_numerical': 0.008665511265164644, 'mean_word_length': 4.874045801526718, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5052549', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1455, 'n_words': 464}