From 297e2dd8b7c64abd09da673dbe87b1d8459a3adf Mon Sep 17 00:00:00 2001 From: Alexander Senko Date: Sat, 9 Nov 2024 00:14:50 +0700 Subject: [PATCH] Released v1.0.0 ## 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. --- CHANGELOG.md | 8 +++++++- README.md | 17 ++++++++++------- lib/magic/presenter/version.rb | 2 +- magic-presenter.gemspec | 3 ++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cfb66e..1125654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.0.0] — UNRELEASED +## [1.0.0] — 2024-11-23 This release marks the gem to be stable enough. @@ -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 diff --git a/README.md b/README.md index 972543e..9eff744 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 @@ -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. @@ -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. diff --git a/lib/magic/presenter/version.rb b/lib/magic/presenter/version.rb index 57a7f89..573d1fb 100644 --- a/lib/magic/presenter/version.rb +++ b/lib/magic/presenter/version.rb @@ -2,6 +2,6 @@ module Magic module Presenter - VERSION = '1.0.0.alpha' + VERSION = '1.0.0' end end diff --git a/magic-presenter.gemspec b/magic-presenter.gemspec index a22fc52..c9fefa8 100644 --- a/magic-presenter.gemspec +++ b/magic-presenter.gemspec @@ -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