Skip to content

Commit

Permalink
Released v1.0.0
Browse files Browse the repository at this point in the history
## Added

- Delegate missing presenter class methods to a model class.
- An optional `engine:` parameter for `Magic.eager_load`
  to be used by other engines to make their presenters visible for
  lookups.
- `Magic.each_engine` to iterate over all the engines attached.

### Tests

- `Magic::Presenter::TestCase` to test presenters.
- View context with routing helpers for presenter specs.

### Generators

- Generate presenters instead of helpers.

## Fixed

- `undefined method 'configure' for module RSpec`.
- Instance variables assignment in views.

## Documentation

- Added a section about testing.
  • Loading branch information
Alexander-Senko committed Nov 23, 2024
1 parent b4159f7 commit 297e2dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [1.0.0]UNRELEASED
## [1.0.0]2024-11-23

This release marks the gem to be stable enough.

Expand All @@ -8,8 +8,14 @@ This release marks the gem to be stable enough.
- An optional `engine:` parameter for `Magic.eager_load`
to be used by other engines to make their presenters visible for lookups.
- `Magic.each_engine` to iterate over all the engines attached.

#### Tests

- `Magic::Presenter::TestCase` to test presenters.
- View context with routing helpers for presenter specs.

#### Generators

- Generate presenters instead of helpers.

### Fixed
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

A bit of history: this gem was inspired by digging deeper into [Draper](https://github.com/drapergem/draper) with an eye on a refactoring.

Based on [Magic Decorator](https://github.com/Alexander-Senko/magic-decorator), it implements a presenter logic.
Based on [Magic Decorator](
https://github.com/Alexander-Senko/magic-decorator
), it implements a presenter logic.

## Installation

Expand Down Expand Up @@ -99,9 +101,10 @@ end
## 🧙 Magic

It’s based on [Magic Decorator](
https://github.com/Alexander-Senko/magic-decorator#magic
), so get familiar with that one as well.
> [!IMPORTANT]
> It’s based on [Magic Decorator](
> https://github.com/Alexander-Senko/magic-decorator#magic
> ), so get familiar with that one as well.
### Presentable scope

Expand All @@ -115,7 +118,7 @@ Presenters provide automatic class inference for any model based on its class na
).

For example, `MyNamespace::MyModel.new.decorate` looks for `MyNamespace::MyPresenter` first.
When missing, it further looks for decorators for its ancestor classes, up to `ObjectPresenter`.
When missing, it further looks for presenters for its ancestor classes, up to `ObjectPresenter`.

#### Mapping rules

Expand All @@ -136,7 +139,7 @@ Magic::Presenter.name_for Person # => "PersonPresenter"

> [!NOTE]
> Magic Lookup doesn’t try to autoload any classes, it searches among already loaded ones instead.
> Thus, presenters should be preloaded to be visible via lookups.
> Thus, presenters should be preloaded to be visible via [lookups](#presenter-class-inference).
This is done automatically in both _test_ and _production_ environments by Rails.
All the application’s presenters and models are eagerly loaded before normal and reverse lookups by Magic Presenter as well.
Expand All @@ -160,7 +163,7 @@ Missing class methods of a presenter are delegated to a matching model class if

### In views

> [!IMPORTANT]
> [!NOTE]
> Every object passed to views is decorated automagically.
> This involves both implicit instance variables and `locals` passed explicitly.
Expand Down
2 changes: 1 addition & 1 deletion lib/magic/presenter/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Magic
module Presenter
VERSION = '1.0.0.alpha'
VERSION = '1.0.0'
end
end
3 changes: 2 additions & 1 deletion magic-presenter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '~> 3.2'

spec.add_dependency 'rails', '>= 7.2', '< 9'
spec.add_dependency 'magic-decorator', '~> 0.3'
spec.add_dependency 'magic-decorator', '~> 1.0'
spec.add_dependency 'magic-lookup'
end

0 comments on commit 297e2dd

Please sign in to comment.