render_turbo_stream 0.1.32 → 0.1.33

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: 7b206d8b440a99024e367f647d886ec496c58965d343dfc6a7652d4d1e92a296
4
- data.tar.gz: e4a1528314a586060ed43a425445eb0a72e5dd4266142455983d97dd70e4dffc
3
+ metadata.gz: e7bdbd86f6a632d14466afe180d2a6f75dbf7fa852cc49719deb13bfa740ac74
4
+ data.tar.gz: 0bfb9d97fa310d9e1694d1797666424ad74258cbafe1ce53d04007402f79f81b
5
5
  SHA512:
6
- metadata.gz: aa70109f94e3e5eb963c7e0c45846d8686ee683e6bb0b6df2dff17b27f9d932a1d95e5c08221e931d190cf65cc85ddb81529580e07ef6e6295b2252d2815361e
7
- data.tar.gz: c0ea50d8d082b7797c11f0b0e6b0d807aaf5ea736c60b11a079305ae02260eec216c08cdf71a499d419300982860ac0dca352b2166274381f5ea56ac73dede10
6
+ metadata.gz: c36293efee4cca99176fbd40806f5d1d945329f86ef9a068d98e8f23945764be5bafabe2ece128a2e4afb41a7c40075ec736030d61f2ac2bbea9eb3b57639972
7
+ data.tar.gz: 040f42b9a0eabacc7150872a885b0576c64642016b2a63160ae13278b9a28533f8aa74e97959c5982bcc42b85c7db0091f0e9613f91653aa781b295502ea3bcc
data/README.md CHANGED
@@ -111,6 +111,8 @@ RSpec.describe "Articles", type: :request do
111
111
 
112
112
  post articles_path(params: invalid_params)
113
113
 
114
+ # --- BASIC TEST ---
115
+
114
116
  # Which partials were rendered
115
117
  expect(partials_count).to eq(2)
116
118
  expect(partials).to include('layouts/flash', 'articles/form')
@@ -118,7 +120,7 @@ RSpec.describe "Articles", type: :request do
118
120
 
119
121
 
120
122
 
121
- # ----- MORE OPTIONS -----
123
+ # --- MORE OPTIONS ---
122
124
 
123
125
  # to which html-ids turbo-stream would point
124
126
  expect(partials_ids).to include('flash-box', 'form')
@@ -26,7 +26,7 @@ module RenderTurboStream
26
26
  else
27
27
  raise 'missing parameter'
28
28
  end
29
- res.map{|r| Nokogiri::HTML(r['html_response']) }
29
+ res.map { |r| Nokogiri::HTML(r['html_response']) }
30
30
  end
31
31
 
32
32
  def partials_ids_count
@@ -41,7 +41,7 @@ module RenderTurboStream
41
41
  def partials_ids
42
42
  ary = partials_attributes
43
43
  ids = []
44
- ary.each {|a| ids.push(a['id']) unless ids.include?(a['id']) }
44
+ ary.each { |a| ids.push(a['id']) unless ids.include?(a['id']) }
45
45
  ids
46
46
  end
47
47
 
@@ -49,10 +49,26 @@ module RenderTurboStream
49
49
  def partials
50
50
  ary = partials_attributes
51
51
  paths = []
52
- ary.each {|a| paths.push(a['partial']) unless paths.include?(a['partial']) }
52
+ ary.each { |a| paths.push(a['partial']) unless paths.include?(a['partial']) }
53
53
  paths
54
54
  end
55
55
 
56
+ # array of strings of paths by which partials that are exactly one time rendered, for example: ['articles/form'].
57
+ def partials_once
58
+ ary = partials_attributes
59
+ paths = []
60
+ paths_once = []
61
+ ary.each do |a|
62
+ if paths.include?(a['partial'])
63
+ paths_once.delete(a['partial'])
64
+ else
65
+ paths.push(a['partial'])
66
+ paths_once.push(a['partial'])
67
+ end
68
+ end
69
+ paths_once
70
+ end
71
+
56
72
  # returns an array of hashes with the attributes used to call partials and the response (html as string) from the partial.
57
73
  def partials_attributes
58
74
  e = Nokogiri::HTML(response.body).search('#rendered-partials').first
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.32"
2
+ VERSION = "0.1.33"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_turbo_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.32
4
+ version: 0.1.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian