inertia_rails 3.1.1 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 782c220b920be30740f826d2dbf34f61de80219947bda32a6e01b94991be2952
4
- data.tar.gz: fd5e8f3dbf11347a14074132fbf8035f03b87bb23981ce4de80f88ba4c5bdbf6
3
+ metadata.gz: 73c0eee6bb3d9b70f170fe1af57d20043c907a28f6e37bb2987eecc39d2aecc8
4
+ data.tar.gz: f91e31fdd2b74126315d6c2ee92fa6e7ff2ec3bb7074e9dca72a51e53c3a325a
5
5
  SHA512:
6
- metadata.gz: 05eacfc4a2cd7b84e49759765285ba33925851709d7ce4f7fc1322346b7c98b9978e63c9cf43f9e8eb1147272ef8a718c6c3d7919caafe94cf56ba4521f46bbb
7
- data.tar.gz: ed94a885cfa3acb5133b81b30037c2e5f1a9fdc01ad4ebc6ac2457dfd1f5802bda2cef190825e184b5056b10794deae6da175c76fd44c69e21dd3d8134d36418
6
+ metadata.gz: bc7fe92ee4b773d360af5887bdf7ea0b445d0a7da3efa316000a5550795eecb587c76c0f36b62d4b98c74ec138fd6aab21367e9d8b7cca444cb44c37c4450460
7
+ data.tar.gz: e3ded5b185819a1913ed7f4468dafcc0bc19db26778972932886084fc8a199ce85dd910ad2b1853f670c3a644f928d647ffe2f015411a8b9e52adc67ae03ffea
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.1.3] - 2023-11-03
8
+
9
+ * Depend on railties instead of rails so that applications which only use pieces of Rails can avoid a full Rails installation. Thanks @BenMorganMY!
10
+
11
+ ## [3.1.2] - 2023-09-26
12
+
13
+ * Fix `have_exact_props` RSpec matcher in the situation where shared props are defined in a lambda that outputs a hash with symbolized keys
14
+
7
15
  ## [3.1.1] - 2023-08-21
8
16
 
9
17
  * Fix broken partial reloads caused by comparing a list of symbolized keys with string keys from HashWithIndifferentAccess
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_runtime_dependency "rails", '>= 5'
28
+ spec.add_runtime_dependency "railties", '>= 5'
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 2.0"
31
31
  spec.add_development_dependency "rake", "~> 13.0"
@@ -14,8 +14,7 @@ module InertiaRails
14
14
  # "Getters"
15
15
  def self.shared_data(controller)
16
16
  shared_plain_data.
17
- merge!(evaluated_blocks(controller, shared_blocks)).
18
- with_indifferent_access
17
+ merge!(evaluated_blocks(controller, shared_blocks))
19
18
  end
20
19
 
21
20
  def self.version
@@ -12,7 +12,7 @@ module InertiaRails
12
12
  @request = request
13
13
  @response = response
14
14
  @render_method = render_method
15
- @props = props ? props.with_indifferent_access : controller.inertia_view_assigns.with_indifferent_access
15
+ @props = props ? props : controller.inertia_view_assigns
16
16
  @view_data = view_data || {}
17
17
  @deep_merge = !deep_merge.nil? ? deep_merge : InertiaRails.deep_merge_shared_data?
18
18
  end
@@ -43,15 +43,25 @@ module InertiaRails
43
43
  end
44
44
 
45
45
  def computed_props
46
- _props = ::InertiaRails.shared_data(@controller).send(prop_merge_method, @props).select do |key, prop|
46
+ # Cast props to symbol keyed hash before merging so that we have a consistent data structure and
47
+ # avoid duplicate keys after merging.
48
+ #
49
+ # Functionally, this permits using either string or symbol keys in the controller. Since the results
50
+ # is cast to json, we should treat string/symbol keys as identical.
51
+ _props = ::InertiaRails.shared_data(@controller).deep_symbolize_keys.send(prop_merge_method, @props.deep_symbolize_keys).select do |key, prop|
47
52
  if rendering_partial_component?
48
- key.to_sym.in? partial_keys
53
+ key.in? partial_keys
49
54
  else
50
55
  !prop.is_a?(InertiaRails::Lazy)
51
56
  end
52
57
  end
53
58
 
54
- deep_transform_values(_props, lambda {|prop| prop.respond_to?(:call) ? @controller.instance_exec(&prop) : prop }).with_indifferent_access
59
+ deep_transform_values(
60
+ _props,
61
+ lambda do |prop|
62
+ prop.respond_to?(:call) ? @controller.instance_exec(&prop) : prop
63
+ end
64
+ )
55
65
  end
56
66
 
57
67
  def page
@@ -74,7 +74,8 @@ end
74
74
 
75
75
  RSpec::Matchers.define :have_exact_props do |expected_props|
76
76
  match do |inertia|
77
- expect(inertia.props).to eq expected_props.with_indifferent_access
77
+ # Computed props have symbolized keys.
78
+ expect(inertia.props).to eq expected_props.deep_symbolize_keys
78
79
  end
79
80
 
80
81
  failure_message do |inertia|
@@ -84,7 +85,8 @@ end
84
85
 
85
86
  RSpec::Matchers.define :include_props do |expected_props|
86
87
  match do |inertia|
87
- expect(inertia.props).to include expected_props.with_indifferent_access
88
+ # Computed props have symbolized keys.
89
+ expect(inertia.props).to include expected_props.deep_symbolize_keys
88
90
  end
89
91
 
90
92
  failure_message do |inertia|
@@ -1,3 +1,3 @@
1
1
  module InertiaRails
2
- VERSION = "3.1.1"
2
+ VERSION = "3.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inertia_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Knoles
@@ -10,10 +10,10 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-08-22 00:00:00.000000000 Z
13
+ date: 2023-11-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rails
16
+ name: railties
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="