yaaf 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbd86cb443765e32aeb6af11e0808962cbc4e21686931e36430be97497a96b34
4
- data.tar.gz: ea8597893601325795fd2f754958d716e8b9fbc387eb3022d80f1426823aa968
3
+ metadata.gz: 01b00a0886f4e1e45793be7307f5b2229783efad994dd6be24a6ad281f3d980c
4
+ data.tar.gz: acd9551ecdbb4f34e4e6c310d387f1525b074de9508c33cdf6ee80cf027e2517
5
5
  SHA512:
6
- metadata.gz: 99e1eb0a6cf12be82c76d7f8da2c610ecbcf14b7ed2873b8eddb943f2716d4ed3d972163ff278df767588cc2f580083d331b26108474446571c5e32e82bc6301
7
- data.tar.gz: 418b22b8ca4a4cb6d1ba96d3700f245d70941cc204a4ba4d879e6c1a6183e6ef71bea2c5fcca976d490fe7170e4dc18b8b2083e37649a32e94bc4467924491d9
6
+ metadata.gz: b7d790cf629a31123f9af169687f023674d89df752f3e2cf0393cef4c52269c592669c6e6d42005a0aaa44293f61c891a815d9aa7fde34a0c5634b7405997984
7
+ data.tar.gz: 5eecb021810dcc1998db62e0107b44a086a7d9c834d3ade98727e2569a04f355c480813bb5d2dd6fa96a7600172d1ef8506baa66d608528fc6fd795b1815d6c1
data/README.md CHANGED
@@ -5,8 +5,6 @@ YAAF (Yet Another Active Form) is a gem that let you create form objects in an e
5
5
  We were going to name this gem `ActiveForm` to follow Rails naming conventions but given there are a lot of form object gems named like that we preferred to go with `YAAF`.
6
6
 
7
7
  ![CI](https://github.com/rootstrap/yaaf/workflows/CI/badge.svg)
8
- [![Maintainability](https://api.codeclimate.com/v1/badges/c3dea064e1003b700260/maintainability)](https://codeclimate.com/github/rootstrap/yaaf/maintainability)
9
- [![Test Coverage](https://api.codeclimate.com/v1/badges/c3dea064e1003b700260/test_coverage)](https://codeclimate.com/github/rootstrap/yaaf/test_coverage)
10
8
 
11
9
  ## Table of Contents
12
10
 
@@ -23,6 +21,7 @@ We were going to name this gem `ActiveForm` to follow Rails naming conventions b
23
21
  - [#save!](#save!)
24
22
  - [Validations](#validations)
25
23
  - [Callbacks](#callbacks)
24
+ - [Normalizes](#normalizes)
26
25
  - [Sample app](#sample-app)
27
26
  - [Links](#links)
28
27
  - [Development](#development)
@@ -249,6 +248,19 @@ Available callbacks are (listed in execution order):
249
248
  - `after_save`
250
249
  - `after_commit/after_rollback`
251
250
 
251
+ ### Normalizes (Rails 8.1+)
252
+
253
+ `YAAF` form objects support `normalizes` the same way as `ActiveModel` models. For example:
254
+
255
+ ```ruby
256
+ class RegistrationForm < YAAF::Form
257
+ normalizes :email, with: ->(email) { email.strip.downcase }
258
+ normalizes :name, with: ->(name) { name.strip.titleize }
259
+
260
+ # ...
261
+ end
262
+ ```
263
+
252
264
  ## Sample app
253
265
 
254
266
  You can find a sample app making use of the gem [here](https://yaaf-examples.herokuapp.com). Its code is also open source, and you can find it [here](https://github.com/rootstrap/yaaf-examples).
data/lib/yaaf/form.rb CHANGED
@@ -6,6 +6,12 @@ module YAAF
6
6
  include ::ActiveModel::Model
7
7
  include ::ActiveModel::Validations::Callbacks
8
8
  include ::ActiveRecord::Transactions
9
+
10
+ if defined?(::ActiveModel::Attributes::Normalization)
11
+ include ::ActiveModel::Attributes
12
+ include ::ActiveModel::Attributes::Normalization
13
+ end
14
+
9
15
  define_model_callbacks :save
10
16
 
11
17
  delegate :transaction, to: ::ActiveRecord::Base
data/lib/yaaf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YAAF
4
- VERSION = '3.0.2'
4
+ VERSION = '3.1.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Manuel Ramallo
8
8
  - Santiago Bartesaghi
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-10-08 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activemodel
@@ -67,20 +66,6 @@ dependencies:
67
66
  - - "~>"
68
67
  - !ruby/object:Gem::Version
69
68
  version: 13.0.1
70
- - !ruby/object:Gem::Dependency
71
- name: reek
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: 5.6.0
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: 5.6.0
84
69
  - !ruby/object:Gem::Dependency
85
70
  name: rspec
86
71
  requirement: !ruby/object:Gem::Requirement
@@ -127,17 +112,16 @@ dependencies:
127
112
  name: sqlite3
128
113
  requirement: !ruby/object:Gem::Requirement
129
114
  requirements:
130
- - - "~>"
115
+ - - ">="
131
116
  - !ruby/object:Gem::Version
132
- version: 1.5.0
117
+ version: '0'
133
118
  type: :development
134
119
  prerelease: false
135
120
  version_requirements: !ruby/object:Gem::Requirement
136
121
  requirements:
137
- - - "~>"
122
+ - - ">="
138
123
  - !ruby/object:Gem::Version
139
- version: 1.5.0
140
- description:
124
+ version: '0'
141
125
  email:
142
126
  - juanmanuelramallo@hey.com
143
127
  - santib@hey.com
@@ -158,7 +142,6 @@ metadata:
158
142
  source_code_uri: https://github.com/rootstrap/yaaf
159
143
  bug_tracker_uri: https://github.com/rootstrap/yaaf/issues
160
144
  changelog_uri: https://github.com/rootstrap/yaaf/releases
161
- post_install_message:
162
145
  rdoc_options: []
163
146
  require_paths:
164
147
  - lib
@@ -173,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
156
  - !ruby/object:Gem::Version
174
157
  version: '0'
175
158
  requirements: []
176
- rubygems_version: 3.5.9
177
- signing_key:
159
+ rubygems_version: 4.0.3
178
160
  specification_version: 4
179
161
  summary: Easing the form object pattern in Rails applications.
180
162
  test_files: []