blueprinter 1.1.1 → 1.2.1
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 +4 -4
- data/CHANGELOG.md +21 -5
- data/README.md +38 -0
- data/lib/blueprinter/base.rb +346 -420
- data/lib/blueprinter/blueprint_validator.rb +4 -8
- data/lib/blueprinter/configuration.rb +17 -7
- data/lib/blueprinter/errors/invalid_blueprint.rb +1 -1
- data/lib/blueprinter/errors/invalid_root.rb +13 -0
- data/lib/blueprinter/errors/meta_requires_root.rb +13 -0
- data/lib/blueprinter/extractors/association_extractor.rb +1 -1
- data/lib/blueprinter/field.rb +2 -6
- data/lib/blueprinter/reflection.rb +3 -3
- data/lib/blueprinter/rendering.rb +193 -0
- data/lib/blueprinter/version.rb +1 -1
- data/lib/blueprinter.rb +2 -2
- data/lib/generators/blueprinter/blueprint_generator.rb +1 -1
- metadata +10 -8
- data/lib/blueprinter/helpers/base_helpers.rb +0 -104
- /data/lib/generators/blueprinter/templates/{blueprint.rb → blueprint.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab333d70266550843309c395b9dcda6635dedf6e5e50fe7fa705a1b8f706d984
|
4
|
+
data.tar.gz: 4f290066a108b137897ba1e04507befeae3e6e79336955c73ba8217a4d60bb40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb8c065bcb12f262893bcbfce15bcfb3127eaf3d81d7fc153a6782ea77e48770a8f9d0468cef39c633ed9ca4edbaf27e9ae4ca0d7895d9940e932e6af4e3e38
|
7
|
+
data.tar.gz: 8b7c9a792d3b7a5d4cc00c439682b5a8c06c68fe158cfdf41732b9c0e2d4cb6a957afcd4d4b9ecd472d329af78ec50430f29a45410742eaa45989f1dc66d94a6
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
+
## Unreleased
|
2
|
+
--
|
3
|
+
|
4
|
+
## 1.2.1 - 2025/09/11
|
5
|
+
- 🐛 [BUGFIX] Adds back `Blueprinter.prepare` method with a deprecated warning. This method was previously public, but was removed as part of **1.2.0**.
|
6
|
+
|
7
|
+
## [REMOVED] 1.2.0 - 2025/09/10
|
8
|
+
- ‼️ [BREAKING] Drops support for Ruby 3.0. See [#496](https://github.com/procore-oss/blueprinter/pull/496)
|
9
|
+
- 💅 [ENHANCEMENT] Allows for the current view to be accessible from within the `options` hash provided to the `field` block. See [#503](https://github.com/procore-oss/blueprinter/pull/503). Thanks to [@neo87cs](https://github.com/neo87cs).
|
10
|
+
- 🐛 [BUGFIX] Fixes an issue where specifying fields using a mix of symbols and strings would cause an `ArgumentError` when rendering. See [#505](https://github.com/procore-oss/blueprinter/pull/505). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
11
|
+
- 🚜 [REFACTOR] Reorganizes rendering/serialization logic and removes `BaseHelper` module. See [#476](https://github.com/procore-oss/blueprinter/pull/476). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
12
|
+
|
13
|
+
## 1.1.2 - 2024/10/3
|
14
|
+
- 🐛 [BUGFIX] Fixes an issue where a `Blueprinter::BlueprinterError` would be raised on render when providing `view: nil`, instead of falling back on the `:default` view. See
|
15
|
+
[#472](https://github.com/procore-oss/blueprinter/pull/472). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
16
|
+
|
1
17
|
## 1.1.1 - 2024/10/2
|
2
18
|
* 🐛 [BUGFIX] Fixes an issue when when calling `.render` multiple times on a Blueprint using the same `options` hash, which would result in the `options` changing unexpectedly between calls. See [#453](https://github.com/procore-oss/blueprinter/pull/453). Thanks to [@ryanmccarthypdx](https://github.com/ryanmccarthypdx).
|
3
19
|
* 🐛 [BUGFIX] Fixes an issue when passing in a `Symbol` (representing a method) to the `if:` condition on an association. The provided `Symbol` would be erroneously sent to the association's Blueprint, instead of the Blueprint in which the association was defined within. See [#464](https://github.com/procore-oss/blueprinter/pull/464). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
4
20
|
|
5
21
|
## 1.1.0 - 2024/08/02
|
6
|
-
* [BREAKING] Drops support for Ruby 2.7. See [#402](https://github.com/procore-oss/blueprinter/pull/402). Thanks to [@jmeridth](https://github.com/jmeridth)
|
22
|
+
* ‼️ [BREAKING] Drops support for Ruby 2.7. See [#402](https://github.com/procore-oss/blueprinter/pull/402). Thanks to [@jmeridth](https://github.com/jmeridth)
|
7
23
|
* 🚜 [REFACTOR] Cleans up Blueprint validation logic and implements an `Association` class with a clearer interface. See [#414](https://github.com/procore-oss/blueprinter/pull/414). Thanks to [@lessthanjacob](https://github.com/lessthanjacob).
|
8
24
|
* 💅 [ENHANCEMENT] Updates **Transform Classes** documentation to provide a more understandable example. See [#415](https://github.com/procore-oss/blueprinter/pull/415). Thanks to [@SaxtonDrey](https://github.com/SaxtonDrey).
|
9
25
|
* 💅 [ENHANCEMENT] Implements field-level configuration option for excluding an attribute from the result of a render if its value is `nil`. See [#425](https://github.com/procore-oss/blueprinter/pull/425). Thanks to [jamesst20](https://github.com/jamesst20).
|
@@ -17,7 +33,7 @@
|
|
17
33
|
* 🐛 [BUGFIX] Fixes an issue where serialization performance would become degraded when using a Blueprint that leverages transformers. See [#381](https://github.com/procore-oss/blueprinter/pull/381). Thanks to [@Pritilender](https://github.com/Pritilender).
|
18
34
|
|
19
35
|
## 1.0.0 - 2024/01/17
|
20
|
-
*
|
36
|
+
* ‼️ [BREAKING] Allow transformers to be included across views. See [README](https://github.com/procore-oss/blueprinter#transform-across-views), PR [#372](https://github.com/procore-oss/blueprinter/pull/372) and issue [#225](https://github.com/procore-oss/blueprinter/issues/225) for details. Note this changes the behavior of transformers which were previously only applied to the view they were defined on. Thanks to [@njbbaer](https://github.com/njbbaer) and [@bhooshiek-narendiran](https://github.com/bhooshiek-narendiran).
|
21
37
|
* 🚀 [FEATURE] Introduce extension API, with initial support for pre_render hook. See [#358](https://github.com/procore-oss/blueprinter/pull/358) for details. Thanks to [@jhollinger](https://github.com/jhollinger).
|
22
38
|
* 💅 [ENHANCEMENT] Add reflection on views, fields, and associations. See PR [#357](https://github.com/procore-oss/blueprinter/pull/357), and issue [#341](https://github.com/procore-oss/blueprinter/issues/341) for details. Thanks to [@jhollinger](https://github.com/jhollinger).
|
23
39
|
|
@@ -27,7 +43,7 @@
|
|
27
43
|
* 💅 [ENHANCEMENT] Introduce rubocop
|
28
44
|
* 💅 [ENHANCEMENT] if/:unless procs with two arguments and invalid empty type deprecations are now removed
|
29
45
|
## 0.26.0 - 2023/08/17
|
30
|
-
*
|
46
|
+
* ‼️ [BREAKING] Transition to GitHub Actions from CircleCI and update to handle Ruby versions 2.7, 3.0, 3.1, 3.2. Drop support for any ruby version less than 2.7. See [#307](https://github.com/procore-oss/blueprinter/pull/307)
|
31
47
|
|
32
48
|
## 0.25.3 - 2021/03/03
|
33
49
|
* 🐛 [BUGFIX] Fixes issue where fields and associations that are redefined by later views were not properly overwritten. See [#201](https://github.com/procore-oss/blueprinter/pull/201) thanks to [@Berardpi](https://github.com/Berardpi).
|
@@ -168,7 +184,7 @@ a JSON String. See PR [#76](https://github.com/procore-oss/blueprinter/pull/76)
|
|
168
184
|
|
169
185
|
## 0.3.0 - 2018/04/05
|
170
186
|
|
171
|
-
|
187
|
+
‼️ [BREAKING] Sort of a breaking Change. Serializer classes has been renamed to Extractor. To upgrade, if you passed in a specific serializer to `field` or `identifier` such as:
|
172
188
|
|
173
189
|
```
|
174
190
|
field(:first_name, serializer: CustomSerializer)
|
@@ -185,7 +201,7 @@ field(:first_name, extractor: CustomExtractor)
|
|
185
201
|
|
186
202
|
## 0.2.0 - 2018/01/22
|
187
203
|
|
188
|
-
|
204
|
+
‼️ [BREAKING] Breaking Changes. To upgrade, ensure that any associated objects have a blueprint. For example:
|
189
205
|
```
|
190
206
|
association :comments, blueprint: CommentsBlueprint
|
191
207
|
```
|
data/README.md
CHANGED
@@ -561,6 +561,44 @@ Output:
|
|
561
561
|
|
562
562
|
</details>
|
563
563
|
|
564
|
+
<details>
|
565
|
+
<summary>Accessing the View Option</summary>
|
566
|
+
|
567
|
+
|
568
|
+
The `view` provided to the `render` call is implicitly available in the `options` hash within a `field` block, and can be referenced as needed. For example:
|
569
|
+
|
570
|
+
```ruby
|
571
|
+
class UserBlueprint < Blueprinter::Base
|
572
|
+
identifier :uuid
|
573
|
+
field :full_name do |user, options|
|
574
|
+
prefix = options[:view] == :admin ? '[Admin]' : options[:title_prefix]
|
575
|
+
"#{prefix} #{user.first_name} #{user.last_name}"
|
576
|
+
end
|
577
|
+
|
578
|
+
view :admin do
|
579
|
+
field :access_level
|
580
|
+
end
|
581
|
+
end
|
582
|
+
```
|
583
|
+
|
584
|
+
Usage:
|
585
|
+
|
586
|
+
```ruby
|
587
|
+
puts UserBlueprint.render(user, title_prefix: "Mr", view: :admin)
|
588
|
+
```
|
589
|
+
|
590
|
+
Output:
|
591
|
+
|
592
|
+
```json
|
593
|
+
{
|
594
|
+
"uuid": "733f0758-8f21-4719-875f-262c3ec743af",
|
595
|
+
"full_name": "[Admin] John Doe",
|
596
|
+
"access_level": "4"
|
597
|
+
}
|
598
|
+
```
|
599
|
+
|
600
|
+
</details>
|
601
|
+
|
564
602
|
<details>
|
565
603
|
<summary>Defining An Identifier Directly In The Blueprint</summary>
|
566
604
|
|