inertia_rails 1.4.0 → 1.4.1

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: ef2ef33ca24036a92d67ec557bab99829468a7f9546422b68a703624bd52489d
4
- data.tar.gz: 6beb16df6b7511813b62e42e91fbb7d0a251264b2e802e0e0345b04bd08700ac
3
+ metadata.gz: 9cd358fa9c397d7899a6d5856840c8a2d3f9d375ebfb080cc8255a7c8fdeb9e6
4
+ data.tar.gz: 7fbc5d37523fda2f27781b6d39765319d8bb5cba876fd0b5a02af7ea7ece80f5
5
5
  SHA512:
6
- metadata.gz: 5e2d7527c48047f950207b163fa539b6b4735655d501a573035a782cb623f5973a74789574be6722bbf7bd4088835c5a486d9a8962df02d17473c4c2d42a0012
7
- data.tar.gz: 96d8302e0fd851874d14ef2cee34c013278924c9e619d7302a2a66ae2a3c5dbd7c3a5e3a7ee2e01f8849adfbd0f54e65b1661cfeeb27320e8f94b415d8ca5567
6
+ metadata.gz: d22c0fa1f8ce6f8f069e9dc72705f46f9a4ea7cf02540967aed17dbd8f548e11e096ed85c8f0cd3dd1b0ff28071c18c1687f22b8ec7cc847be355fbbe588930b
7
+ data.tar.gz: a7bb964c860efa67cd9c3647a38eb981eba239facea5578c6250b3c611ccb727c1691baeefd7357392f81300166d2a475cbda21cf2fa955238ede06ee1bdaa06
@@ -4,6 +4,10 @@ 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
+ ## [1.4.1] - 2020-08-06
8
+
9
+ * Fixed a bug involving threadsafe versions and layouts
10
+
7
11
  ## [1.4.0] - 2020-07-09
8
12
 
9
13
  * Fixed Ruby 2.7 deprecation warnings
@@ -25,10 +25,11 @@ 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'
29
+
28
30
  spec.add_development_dependency "bundler", "~> 2.0"
29
31
  spec.add_development_dependency "rake", "~> 13.0"
30
32
  spec.add_development_dependency "rspec-rails", "~> 4.0"
31
- spec.add_development_dependency "rails"
32
33
  spec.add_development_dependency "rails-controller-testing"
33
34
  spec.add_development_dependency "sqlite3"
34
35
  end
@@ -1,3 +1,6 @@
1
+ # Needed for `thread_mattr_accessor`
2
+ require 'active_support/core_ext/module/attribute_accessors_per_thread'
3
+
1
4
  module InertiaRails
2
5
  thread_mattr_accessor :threadsafe_shared_plain_data
3
6
  thread_mattr_accessor :threadsafe_shared_blocks
@@ -36,28 +39,12 @@ module InertiaRails
36
39
  private
37
40
 
38
41
  module Configuration
39
- thread_mattr_accessor :threadsafe_layout
40
- thread_mattr_accessor :threadsafe_version
42
+ mattr_accessor(:layout) { 'application' }
43
+ mattr_accessor(:version) { nil }
41
44
 
42
45
  def self.evaluated_version
43
46
  self.version.respond_to?(:call) ? self.version.call : self.version
44
47
  end
45
-
46
- def self.layout
47
- self.threadsafe_layout || 'application'
48
- end
49
-
50
- def self.layout=(val)
51
- self.threadsafe_layout = val
52
- end
53
-
54
- def self.version
55
- self.threadsafe_version
56
- end
57
-
58
- def self.version=(val)
59
- self.threadsafe_version = val
60
- end
61
48
  end
62
49
 
63
50
  # Getters and setters to provide default values for the threadsafe attributes
@@ -1,3 +1,3 @@
1
1
  module InertiaRails
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -11,13 +11,7 @@ if defined?(ActionDispatch::DebugExceptions)
11
11
  require 'patches/debug_exceptions/patch-5-1'
12
12
  elsif ActionPack.version.to_s >= '5.0'
13
13
  require 'patches/debug_exceptions/patch-5-0'
14
- elsif ActionPack.version.to_s >= '4.2'
15
- require 'patches/debug_exceptions/patch-4-2'
16
- elsif ActionPack.version.to_s >= '4.1'
17
- require 'patches/debug_exceptions/patch-4-1'
18
14
  else
19
- # No patch required, because text rendering for
20
- # XHR requests was introduced with Rails 4.1:
21
- # https://github.com/rails/rails/pull/11960
15
+ # This gem supports Rails 5 or later
22
16
  end
23
17
  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: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Knoles
@@ -10,8 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-07-09 00:00:00.000000000 Z
13
+ date: 2020-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '5'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '5'
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: bundler
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -54,20 +68,6 @@ dependencies:
54
68
  - - "~>"
55
69
  - !ruby/object:Gem::Version
56
70
  version: '4.0'
57
- - !ruby/object:Gem::Dependency
58
- name: rails
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rails-controller-testing
73
73
  requirement: !ruby/object:Gem::Requirement
@@ -128,8 +128,6 @@ files:
128
128
  - lib/inertia_rails/version.rb
129
129
  - lib/patches/better_errors.rb
130
130
  - lib/patches/debug_exceptions.rb
131
- - lib/patches/debug_exceptions/patch-4-1.rb
132
- - lib/patches/debug_exceptions/patch-4-2.rb
133
131
  - lib/patches/debug_exceptions/patch-5-0.rb
134
132
  - lib/patches/debug_exceptions/patch-5-1.rb
135
133
  - lib/patches/request.rb
@@ -1,41 +0,0 @@
1
- # Patch ActionDispatch::DebugExceptions to render HTML for Inertia requests
2
- #
3
- # Original source:
4
- # https://github.com/rails/rails/blob/4-1-stable/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
5
- #
6
-
7
- ActionDispatch::DebugExceptions.class_eval do
8
- prepend(InertiaDebugExceptions = Module.new do
9
- def render_exception(env, exception)
10
- wrapper = ExceptionWrapper.new(env, exception)
11
- log_error(env, wrapper)
12
-
13
- if env['action_dispatch.show_detailed_exceptions']
14
- request = Request.new(env)
15
- template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
16
- request: request,
17
- exception: wrapper.exception,
18
- application_trace: wrapper.application_trace,
19
- framework_trace: wrapper.framework_trace,
20
- full_trace: wrapper.full_trace,
21
- routes_inspector: routes_inspector(exception),
22
- source_extract: wrapper.source_extract,
23
- line_number: wrapper.line_number,
24
- file: wrapper.file
25
- )
26
- file = "rescues/#{wrapper.rescue_template}"
27
-
28
- if request.xhr? && !request.headers['X-Inertia'] # <<<< this line is changed only
29
- body = template.render(template: file, layout: false, formats: [:text])
30
- format = "text/plain"
31
- else
32
- body = template.render(template: file, layout: 'rescues/layout')
33
- format = "text/html"
34
- end
35
- render(wrapper.status_code, body, format)
36
- else
37
- raise exception
38
- end
39
- end
40
- end)
41
- end
@@ -1,52 +0,0 @@
1
- # Patch ActionDispatch::DebugExceptions to render HTML for Inertia requests
2
- #
3
- # Original source:
4
- # https://github.com/rails/rails/blob/4-2-stable/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
5
- #
6
-
7
- ActionDispatch::DebugExceptions.class_eval do
8
- prepend(InertiaDebugExceptions = Module.new do
9
- def render_exception(env, exception)
10
- wrapper = ExceptionWrapper.new(env, exception)
11
- log_error(env, wrapper)
12
-
13
- if env['action_dispatch.show_detailed_exceptions']
14
- request = Request.new(env)
15
- traces = wrapper.traces
16
-
17
- trace_to_show = 'Application Trace'
18
- if traces[trace_to_show].empty? && wrapper.rescue_template != 'routing_error'
19
- trace_to_show = 'Full Trace'
20
- end
21
-
22
- if source_to_show = traces[trace_to_show].first
23
- source_to_show_id = source_to_show[:id]
24
- end
25
-
26
- template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
27
- request: request,
28
- exception: wrapper.exception,
29
- traces: traces,
30
- show_source_idx: source_to_show_id,
31
- trace_to_show: trace_to_show,
32
- routes_inspector: routes_inspector(exception),
33
- source_extracts: wrapper.source_extracts,
34
- line_number: wrapper.line_number,
35
- file: wrapper.file
36
- )
37
- file = "rescues/#{wrapper.rescue_template}"
38
-
39
- if request.xhr? && !request.headers['X-Inertia'] # <<<< this line is changed only
40
- body = template.render(template: file, layout: false, formats: [:text])
41
- format = "text/plain"
42
- else
43
- body = template.render(template: file, layout: 'rescues/layout')
44
- format = "text/html"
45
- end
46
- render(wrapper.status_code, body, format)
47
- else
48
- raise exception
49
- end
50
- end
51
- end)
52
- end