props_template 0.36.0 → 0.37.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: '01825cc9ebfc4584469c98d5f8e9df4eb8461210b9eb7fce104ff9ed484c2fa0'
4
- data.tar.gz: 392c600764ec2c4de0a0d0035c2d7c573e7bc19f071f0e2efd2b6a66d3e862bc
3
+ metadata.gz: ecdcee486c14966bbb3259a5b213631b3cd29f14a31a7194a8e9aad1ade31398
4
+ data.tar.gz: c33d2129e1aa5ba580003c834f828bc48c820120e4ffa66f9eebfc1531fed7a0
5
5
  SHA512:
6
- metadata.gz: cb079a592e94c1d85ca7bed68d334e3c39939652473ae9779ca92bd4cf76311fcca9f3e5603da198b5274e55cd49a54120a554c8968a76bea01141228d0d6abc
7
- data.tar.gz: 6e3ada0a21fc1f1112bd5d0839d229b3bf673a79e96386af58d0ee6a4cbf5978081b9d1cc2ba84e98ad7a4f24430fa5eb1ecd11d54ae78fdc15e28ab68df23c0
6
+ metadata.gz: 6f11a45290e1c10aa7b526506f305b723928e8414117a6aac637dbdbd95d09ae414cb18ff5c8d74a249cf12bf85f55af5d2d9f83f7846c2c03690fde5d4990bc
7
+ data.tar.gz: bc476b0780f7448883bd7dfe8316ac837c851d7255420eeb8496730285d68404b64dcf94a45e856acbaefa9788c76d7f1b70722a61316129e9751a16250e8d7c
data/README.md CHANGED
@@ -72,7 +72,7 @@ gem 'props_template'
72
72
  and run `bundle`.
73
73
 
74
74
  Optionally add the [core ext](#array-core-extension) to an initializer if you
75
- want to [dig](#traversing) into your templates.
75
+ want to [dig](#digging) into your templates.
76
76
 
77
77
  ```ruby
78
78
  require 'props_template/core_ext'
@@ -152,7 +152,7 @@ The difference between the block form and inline form is
152
152
  1. The block form is an internal node. Functionality such as Partials,
153
153
  Deferment and other [options](#options) are only available on the
154
154
  block form.
155
- 2. The inline form is considered a leaf node, and you can only [search](#traversing)
155
+ 2. The inline form is considered a leaf node, and you can only [dig](#digging)
156
156
  for internal nodes.
157
157
 
158
158
  ### json.extract!
@@ -202,7 +202,7 @@ end
202
202
  | collection | A collection that responds to `member_at` and `member_by` |
203
203
  | options | Additional [options](#options)|
204
204
 
205
- To support [traversing nodes](#traversing), any list passed
205
+ To support [digging](#digging), any list passed
206
206
  to `array!` MUST implement `member_at(index)` and `member_by(attr, value)`.
207
207
 
208
208
  For example, if you were using a delegate:
@@ -276,7 +276,7 @@ end
276
276
  ```
277
277
 
278
278
  PropsTemplate does not know what the elements are in your collection. The
279
- example above will be fine for [traversing](#traversing)
279
+ example above will be fine for [digging](#digging)
280
280
  by index, but will raise a `NotImplementedError` if you query by attribute. You
281
281
  may still need to implement `member_by`.
282
282
 
@@ -447,7 +447,7 @@ entirely and replace the value with a placeholder. A common use case would be
447
447
  tabbed content that does not load until you click the tab.
448
448
 
449
449
  When your client receives the payload, you may issue a second request to the
450
- same endpoint to fetch any missing nodes. See [traversing nodes](#traversing)
450
+ same endpoint to fetch any missing nodes. See [digging](#digging)
451
451
 
452
452
  There is also an `defer: :auto` option that you can use with [SuperglueJS][1]. [SuperglueJS][1]
453
453
  will use the metadata from `json.deferred!` to issue a `remote` dispatch to fetch
@@ -502,7 +502,7 @@ your collection item, and is used for `defer: :auto` to generate a keypath for
502
502
  [SuperglueJS][1]. If you are NOT using SuperglueJS, you do not need to do this.
503
503
 
504
504
  2. Implement `member_at`, on the [collection](#jsonarray). This will be called
505
- by PropsTemplate to when [searching nodes](#traversing)
505
+ by PropsTemplate to when [digging](#digging)
506
506
 
507
507
  For example:
508
508
 
@@ -528,7 +528,7 @@ end
528
528
  If you are using [SuperglueJS][1], SuperglueJS will, it will automatically kick off
529
529
  `remote(?props_at=posts.some_id=1.contact)` and `remote(?props_at=posts.some_id=2.contact)`.
530
530
 
531
- ## Traversing
531
+ ## Digging
532
532
 
533
533
  PropsTemplate has the ability to walk the tree you build, skipping execution of
534
534
  untargeted nodes. This feature is useful for selectively updating your frontend
@@ -537,7 +537,7 @@ state.
537
537
  ```ruby
538
538
  traversal_path = ['data', 'details', 'personal']
539
539
 
540
- json.data(search: traversal_path) do
540
+ json.data(dig: traversal_path) do
541
541
  json.details do
542
542
  json.employment do
543
543
  ...more stuff
@@ -571,13 +571,13 @@ The above will output:
571
571
  }
572
572
  ```
573
573
 
574
- Searching only works with blocks, and will NOT work with Scalars
574
+ Digging only works with blocks, and will NOT work with Scalars
575
575
  ("leaf" values). For example:
576
576
 
577
577
  ```ruby
578
578
  traversal_path = ['data', 'details', 'personal', 'name'] <- not found
579
579
 
580
- json.data(search: traversal_path) do
580
+ json.data(dig: traversal_path) do
581
581
  json.details do
582
582
  json.personal do
583
583
  json.name 'james'
@@ -588,12 +588,12 @@ end
588
588
 
589
589
  ## Nodes that do not exist
590
590
 
591
- Nodes that are not found will remove the branch where search was enabled on.
591
+ Nodes that are not found will remove the branch where digging was enabled on.
592
592
 
593
593
  ```ruby
594
594
  traversal_path = ['data', 'details', 'does_not_exist']
595
595
 
596
- json.data(search: traversal_path) do
596
+ json.data(dig: traversal_path) do
597
597
  json.details do
598
598
  json.personal do
599
599
  json.name 'james'
@@ -642,7 +642,7 @@ will render Layout first, then the template when `yield json` is used.
642
642
 
643
643
  ## Change key format
644
644
  By default, keys are not formatted. This is intentional. By being explicity with your keys,
645
- it makes your views quicker and more easily searchable when working in Javascript land.
645
+ it makes your views quicker and more easily diggable when working in Javascript land.
646
646
 
647
647
  If you must change this behavior, override it in an initializer and cache the value:
648
648
 
@@ -1,3 +1,3 @@
1
1
  module Props
2
- VERSION = "0.36.0".freeze
2
+ VERSION = "0.37.0".freeze
3
3
  end
@@ -36,11 +36,15 @@ module Props
36
36
  end
37
37
 
38
38
  def set!(key, options = {}, &block)
39
- if block && options[:search] && !@builder.is_a?(Searcher)
39
+ if block && (options[:search] || options[:dig]) && !@builder.is_a?(Searcher)
40
+ search = options[:search] || options[:dig]
40
41
 
41
42
  prev_builder = @builder
42
- @builder = Searcher.new(self, options[:search], @context)
43
+ @builder = Searcher.new(self, search, @context)
44
+
43
45
  options.delete(:search)
46
+ options.delete(:dig)
47
+
44
48
  @builder.set!(key, options, &block)
45
49
  found_block, found_options = @builder.found!
46
50
  @builder = prev_builder
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: props_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.0
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johny Ho
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
10
+ date: 2024-12-31 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -16,40 +15,52 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 6.1.0
18
+ version: '7.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: 6.1.0
28
+ version: '7.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9.0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: actionview
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - ">="
32
37
  - !ruby/object:Gem::Version
33
- version: 6.1.0
38
+ version: '7.0'
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '9.0'
34
42
  type: :runtime
35
43
  prerelease: false
36
44
  version_requirements: !ruby/object:Gem::Requirement
37
45
  requirements:
38
46
  - - ">="
39
47
  - !ruby/object:Gem::Version
40
- version: 6.1.0
48
+ version: '7.0'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '9.0'
41
52
  - !ruby/object:Gem::Dependency
42
53
  name: oj
43
54
  requirement: !ruby/object:Gem::Requirement
44
55
  requirements:
45
- - - ">="
56
+ - - "~>"
46
57
  - !ruby/object:Gem::Version
47
58
  version: '3.9'
48
59
  type: :runtime
49
60
  prerelease: false
50
61
  version_requirements: !ruby/object:Gem::Requirement
51
62
  requirements:
52
- - - ">="
63
+ - - "~>"
53
64
  - !ruby/object:Gem::Version
54
65
  version: '3.9'
55
66
  description: PropsTemplate is a direct-to-Oj, JBuilder-like DSL for building JSON.
@@ -80,7 +91,6 @@ homepage: https://github.com/thoughtbot/props_template/
80
91
  licenses:
81
92
  - MIT
82
93
  metadata: {}
83
- post_install_message:
84
94
  rdoc_options: []
85
95
  require_paths:
86
96
  - lib
@@ -95,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
105
  - !ruby/object:Gem::Version
96
106
  version: '0'
97
107
  requirements: []
98
- rubygems_version: 3.1.6
99
- signing_key:
108
+ rubygems_version: 3.6.2
100
109
  specification_version: 4
101
110
  summary: A fast JSON builder
102
111
  test_files: []