turbo_power 0.6.1 → 0.7.0

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: 4e8ff8643127634682d934640147295a85a4c5d865299031b79eaca8d9e07a2a
4
- data.tar.gz: ce24c63c1e2bb9bdeca2bdbb30cb3515aed4b320f01659f65c089a3d1ae63e7c
3
+ metadata.gz: c66429633c48026fd0cbafa52235652ec88de59d8261300cd38d7e80b594f105
4
+ data.tar.gz: cabb958fac7894f6ce872671ef0891447ae447b748a64907fa8be03e65651b61
5
5
  SHA512:
6
- metadata.gz: d69f06b40f30aa9848182d26c59f5b46af9b9783d9bd21a194ea523266530f3dda316da634bf9a4b4096457f4746044a20e0e4b2defc64b2a79e2a4a7d5f75a2
7
- data.tar.gz: 260f22024b9ddeb9201434d366d463258c293d4b85fd981ad02c2d3f14b91e85fa35e7881f22cae53d412bb66f0d5a7bc70a912a00e2943bd80571fe15dd285b
6
+ metadata.gz: 8ac5d5ff43a5af8cfebae2302c63c5accbc547f34d8dd7f5b01103f9de342440ad106a53ca29f54390e315ebc61918b0b506b5cc40d414cb447a403c7da8958a
7
+ data.tar.gz: 7bf2cf417e1e764ea845c011603438818f89eb19ec1800e22dff1524d7da1827dfa5ff2204e6d5c8126fea44bd10beb5a430b46b3fbef081ca78037c61691494
data/Gemfile CHANGED
@@ -8,7 +8,8 @@ gem "rake", "~> 13.0"
8
8
  gem "rubocop", "~> 1.21"
9
9
 
10
10
  group :test do
11
- gem "sprockets-rails"
12
- gem "sqlite3"
11
+ gem "rails"
13
12
  gem "simplecov"
13
+ gem "sprockets-rails"
14
+ gem "sqlite3", "~> 1.3"
14
15
  end
data/Gemfile.lock CHANGED
@@ -1,75 +1,193 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_power (0.6.1)
4
+ turbo_power (0.7.0)
5
5
  turbo-rails (>= 1.3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (7.0.4.2)
11
- actionview (= 7.0.4.2)
12
- activesupport (= 7.0.4.2)
13
- rack (~> 2.0, >= 2.2.0)
10
+ actioncable (7.1.3.4)
11
+ actionpack (= 7.1.3.4)
12
+ activesupport (= 7.1.3.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.1.3.4)
17
+ actionpack (= 7.1.3.4)
18
+ activejob (= 7.1.3.4)
19
+ activerecord (= 7.1.3.4)
20
+ activestorage (= 7.1.3.4)
21
+ activesupport (= 7.1.3.4)
22
+ mail (>= 2.7.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.1.3.4)
27
+ actionpack (= 7.1.3.4)
28
+ actionview (= 7.1.3.4)
29
+ activejob (= 7.1.3.4)
30
+ activesupport (= 7.1.3.4)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
35
+ rails-dom-testing (~> 2.2)
36
+ actionpack (7.1.3.4)
37
+ actionview (= 7.1.3.4)
38
+ activesupport (= 7.1.3.4)
39
+ nokogiri (>= 1.8.5)
40
+ racc
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
14
43
  rack-test (>= 0.6.3)
15
- rails-dom-testing (~> 2.0)
16
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
- actionview (7.0.4.2)
18
- activesupport (= 7.0.4.2)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.3.4)
47
+ actionpack (= 7.1.3.4)
48
+ activerecord (= 7.1.3.4)
49
+ activestorage (= 7.1.3.4)
50
+ activesupport (= 7.1.3.4)
51
+ globalid (>= 0.6.0)
52
+ nokogiri (>= 1.8.5)
53
+ actionview (7.1.3.4)
54
+ activesupport (= 7.1.3.4)
19
55
  builder (~> 3.1)
20
- erubi (~> 1.4)
21
- rails-dom-testing (~> 2.0)
22
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
- activejob (7.0.4.2)
24
- activesupport (= 7.0.4.2)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.3.4)
60
+ activesupport (= 7.1.3.4)
25
61
  globalid (>= 0.3.6)
26
- activesupport (7.0.4.2)
62
+ activemodel (7.1.3.4)
63
+ activesupport (= 7.1.3.4)
64
+ activerecord (7.1.3.4)
65
+ activemodel (= 7.1.3.4)
66
+ activesupport (= 7.1.3.4)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.3.4)
69
+ actionpack (= 7.1.3.4)
70
+ activejob (= 7.1.3.4)
71
+ activerecord (= 7.1.3.4)
72
+ activesupport (= 7.1.3.4)
73
+ marcel (~> 1.0)
74
+ activesupport (7.1.3.4)
75
+ base64
76
+ bigdecimal
27
77
  concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ connection_pool (>= 2.2.5)
79
+ drb
28
80
  i18n (>= 1.6, < 2)
29
81
  minitest (>= 5.1)
82
+ mutex_m
30
83
  tzinfo (~> 2.0)
31
84
  ast (2.4.2)
32
- builder (3.2.4)
33
- concurrent-ruby (1.2.2)
85
+ base64 (0.2.0)
86
+ bigdecimal (3.1.8)
87
+ bigdecimal (3.1.8-java)
88
+ builder (3.3.0)
89
+ concurrent-ruby (1.3.1)
90
+ connection_pool (2.4.1)
34
91
  crass (1.0.6)
92
+ date (3.3.4)
93
+ date (3.3.4-java)
35
94
  docile (1.4.0)
95
+ drb (2.2.1)
36
96
  erubi (1.12.0)
37
- globalid (1.1.0)
38
- activesupport (>= 5.0)
39
- i18n (1.12.0)
97
+ globalid (1.2.1)
98
+ activesupport (>= 6.1)
99
+ i18n (1.14.5)
40
100
  concurrent-ruby (~> 1.0)
101
+ io-console (0.7.2)
102
+ io-console (0.7.2-java)
103
+ irb (1.13.1)
104
+ rdoc (>= 4.0.0)
105
+ reline (>= 0.4.2)
106
+ jar-dependencies (0.4.1)
41
107
  json (2.6.3)
42
- loofah (2.19.1)
108
+ json (2.6.3-java)
109
+ loofah (2.22.0)
43
110
  crass (~> 1.0.2)
44
- nokogiri (>= 1.5.9)
45
- method_source (1.0.0)
46
- mini_portile2 (2.8.5)
47
- minitest (5.17.0)
48
- nokogiri (1.14.2)
49
- mini_portile2 (~> 2.8.0)
111
+ nokogiri (>= 1.12.0)
112
+ mail (2.8.1)
113
+ mini_mime (>= 0.1.1)
114
+ net-imap
115
+ net-pop
116
+ net-smtp
117
+ marcel (1.0.4)
118
+ mini_mime (1.1.5)
119
+ mini_portile2 (2.8.8)
120
+ minitest (5.23.1)
121
+ mutex_m (0.2.0)
122
+ net-imap (0.4.12)
123
+ date
124
+ net-protocol
125
+ net-pop (0.1.2)
126
+ net-protocol
127
+ net-protocol (0.2.2)
128
+ timeout
129
+ net-smtp (0.5.0)
130
+ net-protocol
131
+ nio4r (2.7.3)
132
+ nio4r (2.7.3-java)
133
+ nokogiri (1.16.5)
134
+ mini_portile2 (~> 2.8.2)
135
+ racc (~> 1.4)
136
+ nokogiri (1.16.5-x86_64-darwin)
50
137
  racc (~> 1.4)
51
138
  parallel (1.22.1)
52
139
  parser (3.1.3.0)
53
140
  ast (~> 2.4.1)
54
- racc (1.6.2)
55
- rack (2.2.6.2)
56
- rack-test (2.0.2)
141
+ psych (5.1.2)
142
+ stringio
143
+ psych (5.1.2-java)
144
+ jar-dependencies (>= 0.1.7)
145
+ racc (1.8.0)
146
+ racc (1.8.0-java)
147
+ rack (3.0.11)
148
+ rack-session (2.0.0)
149
+ rack (>= 3.0.0)
150
+ rack-test (2.1.0)
57
151
  rack (>= 1.3)
58
- rails-dom-testing (2.0.3)
59
- activesupport (>= 4.2.0)
152
+ rackup (2.1.0)
153
+ rack (>= 3)
154
+ webrick (~> 1.8)
155
+ rails (7.1.3.4)
156
+ actioncable (= 7.1.3.4)
157
+ actionmailbox (= 7.1.3.4)
158
+ actionmailer (= 7.1.3.4)
159
+ actionpack (= 7.1.3.4)
160
+ actiontext (= 7.1.3.4)
161
+ actionview (= 7.1.3.4)
162
+ activejob (= 7.1.3.4)
163
+ activemodel (= 7.1.3.4)
164
+ activerecord (= 7.1.3.4)
165
+ activestorage (= 7.1.3.4)
166
+ activesupport (= 7.1.3.4)
167
+ bundler (>= 1.15.0)
168
+ railties (= 7.1.3.4)
169
+ rails-dom-testing (2.2.0)
170
+ activesupport (>= 5.0.0)
171
+ minitest
60
172
  nokogiri (>= 1.6)
61
- rails-html-sanitizer (1.5.0)
62
- loofah (~> 2.19, >= 2.19.1)
63
- railties (7.0.4.2)
64
- actionpack (= 7.0.4.2)
65
- activesupport (= 7.0.4.2)
66
- method_source
173
+ rails-html-sanitizer (1.6.0)
174
+ loofah (~> 2.21)
175
+ nokogiri (~> 1.14)
176
+ railties (7.1.3.4)
177
+ actionpack (= 7.1.3.4)
178
+ activesupport (= 7.1.3.4)
179
+ irb
180
+ rackup (>= 1.0.0)
67
181
  rake (>= 12.2)
68
- thor (~> 1.0)
69
- zeitwerk (~> 2.5)
182
+ thor (~> 1.0, >= 1.2.2)
183
+ zeitwerk (~> 2.6)
70
184
  rainbow (3.1.1)
71
- rake (13.0.6)
185
+ rake (13.2.1)
186
+ rdoc (6.7.0)
187
+ psych (>= 4.0.0)
72
188
  regexp_parser (2.6.1)
189
+ reline (0.5.8)
190
+ io-console (~> 0.5)
73
191
  rexml (3.2.5)
74
192
  rubocop (1.41.1)
75
193
  json (~> 2.3)
@@ -97,29 +215,42 @@ GEM
97
215
  actionpack (>= 5.2)
98
216
  activesupport (>= 5.2)
99
217
  sprockets (>= 3.0.0)
100
- sqlite3 (1.5.4)
218
+ sqlite3 (1.7.3)
101
219
  mini_portile2 (~> 2.8.0)
102
- thor (1.2.1)
103
- turbo-rails (1.3.3)
220
+ stringio (3.1.0)
221
+ thor (1.3.1)
222
+ timeout (0.4.1)
223
+ turbo-rails (2.0.5)
104
224
  actionpack (>= 6.0.0)
105
225
  activejob (>= 6.0.0)
106
226
  railties (>= 6.0.0)
107
227
  tzinfo (2.0.6)
108
228
  concurrent-ruby (~> 1.0)
109
229
  unicode-display_width (2.3.0)
110
- zeitwerk (2.6.7)
230
+ webrick (1.8.1)
231
+ websocket-driver (0.7.6)
232
+ websocket-extensions (>= 0.1.0)
233
+ websocket-driver (0.7.6-java)
234
+ websocket-extensions (>= 0.1.0)
235
+ websocket-extensions (0.1.5)
236
+ zeitwerk (2.6.15)
111
237
 
112
238
  PLATFORMS
239
+ java
240
+ x64-mingw32
241
+ x86-mingw32
242
+ x86-mswin32
113
243
  x86_64-darwin-19
114
244
  x86_64-darwin-22
115
245
  x86_64-darwin-23
116
246
 
117
247
  DEPENDENCIES
248
+ rails
118
249
  rake (~> 13.0)
119
250
  rubocop (~> 1.21)
120
251
  simplecov
121
252
  sprockets-rails
122
- sqlite3
253
+ sqlite3 (~> 1.3)
123
254
  turbo_power!
124
255
 
125
256
  BUNDLED WITH
@@ -17,7 +17,7 @@ module TurboPower
17
17
  def custom_broadcast_action_to(*streamables, action:, **attributes)
18
18
  broadcast_stream_to(
19
19
  *streamables,
20
- content: turbo_stream_action_tag(action, **attributes)
20
+ content: RenderHelper.public_send(action, **attributes)
21
21
  )
22
22
  end
23
23
 
@@ -0,0 +1,28 @@
1
+ module TurboPower
2
+ class RenderHelper
3
+ extend ActionView::Helpers::TagHelper
4
+ extend TurboPower::StreamHelper
5
+
6
+ def self.turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **attributes)
7
+ template = action.to_sym.in?(%i[ remove refresh ]) ? "" : tag.template(template.to_s.html_safe)
8
+
9
+ if target = convert_to_turbo_stream_dom_id(target)
10
+ tag.turbo_stream(template, **attributes, action: action, target: target)
11
+ elsif targets = convert_to_turbo_stream_dom_id(targets, include_selector: true)
12
+ tag.turbo_stream(template, **attributes, action: action, targets: targets)
13
+ else
14
+ tag.turbo_stream(template, **attributes, action: action)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def self.convert_to_turbo_stream_dom_id(target, include_selector: false)
21
+ if Array(target).any? { |value| value.respond_to?(:to_key) }
22
+ "#{"#" if include_selector}#{ActionView::RecordIdentifier.dom_id(*target)}"
23
+ else
24
+ target
25
+ end
26
+ end
27
+ end
28
+ end
@@ -113,6 +113,13 @@ module TurboPower
113
113
  custom_action_all :toggle_css_class, targets: targets, attributes: attributes.merge(classes: classes)
114
114
  end
115
115
 
116
+ def toggle_attribute(targets = nil, attribute = "", force = "false", **attributes)
117
+ attribute = attributes[:attribute] || attribute
118
+ force = attributes[:force] || force
119
+
120
+ custom_action_all :toggle_attribute, targets: targets, attributes: attributes.merge(attribute: attribute, force: force)
121
+ end
122
+
116
123
  def replace_css_class(targets = nil, from = "", to = "", **attributes)
117
124
  from = attributes[:from] || from
118
125
  to = attributes[:to] || to
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboPower
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/turbo_power.rb CHANGED
@@ -6,6 +6,7 @@ require_relative "turbo_power/version"
6
6
  require_relative "turbo_power/engine"
7
7
  require_relative "turbo_power/attribute_transformations"
8
8
  require_relative "turbo_power/stream_helper"
9
+ require_relative "turbo_power/render_helper"
9
10
  require_relative "turbo_power/broadcasts"
10
11
  require_relative "turbo_power/broadcastable"
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_power
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-07 00:00:00.000000000 Z
11
+ date: 2024-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turbo-rails
@@ -45,6 +45,7 @@ files:
45
45
  - lib/turbo_power/broadcastable.rb
46
46
  - lib/turbo_power/broadcasts.rb
47
47
  - lib/turbo_power/engine.rb
48
+ - lib/turbo_power/render_helper.rb
48
49
  - lib/turbo_power/stream_helper.rb
49
50
  - lib/turbo_power/version.rb
50
51
  - turbo_power.gemspec
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 3.5.3
75
+ rubygems_version: 3.5.9
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: Power-pack for Turbo Streams