turbo_power 0.1.1 → 0.1.2

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: 4ec77740a41b50382edd8441dcb76a453fc60d57d5429e107398de38578e147b
4
- data.tar.gz: f4419c8721ffd08fdcc02b1f1449d2671af16cc34c7e2f73185777276236bc27
3
+ metadata.gz: 3c9df9b4805eb75df7767c66ca573d21ef4bcd94203f19cc7be3982aa2a55e5f
4
+ data.tar.gz: d343c3de805f702633fe5dfc8935bee4117e935bb2d604ff651fe5cf46736fb6
5
5
  SHA512:
6
- metadata.gz: 8f1a90e7eae214a0f6d3d1bcb371f4c8a9f06e302f5a8135a68027be105a6c93f549ba860de1bdc9be7959309c277458295661d9dbd14e2158583017ee931101
7
- data.tar.gz: 0a8753c7d57f4865ca27641d8767723dc1d97bda6c5e6fb37aee54f6f1d2e58e64d3e79d2a9472abbce1664e7abb22793d0073ad4d1e999bcc125838424d2f3c
6
+ metadata.gz: fd57269d083dda4a54dc1aba8dea27fd967c98a8c7aae31661178645cd97bc89a3a86b15b4140a73057a2181e77e53db2d21a236a88047990bb109515bf3ae87
7
+ data.tar.gz: eb2d9e17097ceb48da7f11caf084073c062787f198d38d04994124c245ed2466ceacc5ca377db584539993ba10829e7481835190ba7037a9177d6a4e42b9a426
data/Gemfile CHANGED
@@ -9,6 +9,3 @@ gem "rake", "~> 13.0"
9
9
  gem "minitest", "~> 5.0"
10
10
 
11
11
  gem "rubocop", "~> 1.21"
12
-
13
- gem "turbo-rails", github: "marcoroth/turbo-rails", branch: "custom-action-helpers"
14
- gem "turbo_ready", github: "marcoroth/turbo_ready", branch: "main"
data/Gemfile.lock CHANGED
@@ -1,93 +1,74 @@
1
- GIT
2
- remote: https://github.com/marcoroth/turbo-rails.git
3
- revision: ba0c355b74441778f35b58608e2baafc6c0b3c46
4
- branch: custom-action-helpers
5
- specs:
6
- turbo-rails (1.1.1)
7
- actionpack (>= 6.0.0)
8
- activejob (>= 6.0.0)
9
- railties (>= 6.0.0)
10
-
11
- GIT
12
- remote: https://github.com/marcoroth/turbo_ready.git
13
- revision: ccd0ceb7a1209501f60591c833aba2a150d46066
14
- branch: main
15
- specs:
16
- turbo_ready (0.0.5)
17
- rails (>= 6.1)
18
- turbo-rails (>= 1.1)
19
-
20
1
  PATH
21
2
  remote: .
22
3
  specs:
23
- turbo_power (0.1.1)
24
- turbo-rails
4
+ turbo_power (0.1.2)
5
+ turbo-rails (~> 1.3.0)
25
6
  turbo_ready
26
7
 
27
8
  GEM
28
9
  remote: https://rubygems.org/
29
10
  specs:
30
- actioncable (7.0.3.1)
31
- actionpack (= 7.0.3.1)
32
- activesupport (= 7.0.3.1)
11
+ actioncable (7.0.4)
12
+ actionpack (= 7.0.4)
13
+ activesupport (= 7.0.4)
33
14
  nio4r (~> 2.0)
34
15
  websocket-driver (>= 0.6.1)
35
- actionmailbox (7.0.3.1)
36
- actionpack (= 7.0.3.1)
37
- activejob (= 7.0.3.1)
38
- activerecord (= 7.0.3.1)
39
- activestorage (= 7.0.3.1)
40
- activesupport (= 7.0.3.1)
16
+ actionmailbox (7.0.4)
17
+ actionpack (= 7.0.4)
18
+ activejob (= 7.0.4)
19
+ activerecord (= 7.0.4)
20
+ activestorage (= 7.0.4)
21
+ activesupport (= 7.0.4)
41
22
  mail (>= 2.7.1)
42
23
  net-imap
43
24
  net-pop
44
25
  net-smtp
45
- actionmailer (7.0.3.1)
46
- actionpack (= 7.0.3.1)
47
- actionview (= 7.0.3.1)
48
- activejob (= 7.0.3.1)
49
- activesupport (= 7.0.3.1)
26
+ actionmailer (7.0.4)
27
+ actionpack (= 7.0.4)
28
+ actionview (= 7.0.4)
29
+ activejob (= 7.0.4)
30
+ activesupport (= 7.0.4)
50
31
  mail (~> 2.5, >= 2.5.4)
51
32
  net-imap
52
33
  net-pop
53
34
  net-smtp
54
35
  rails-dom-testing (~> 2.0)
55
- actionpack (7.0.3.1)
56
- actionview (= 7.0.3.1)
57
- activesupport (= 7.0.3.1)
36
+ actionpack (7.0.4)
37
+ actionview (= 7.0.4)
38
+ activesupport (= 7.0.4)
58
39
  rack (~> 2.0, >= 2.2.0)
59
40
  rack-test (>= 0.6.3)
60
41
  rails-dom-testing (~> 2.0)
61
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
62
- actiontext (7.0.3.1)
63
- actionpack (= 7.0.3.1)
64
- activerecord (= 7.0.3.1)
65
- activestorage (= 7.0.3.1)
66
- activesupport (= 7.0.3.1)
43
+ actiontext (7.0.4)
44
+ actionpack (= 7.0.4)
45
+ activerecord (= 7.0.4)
46
+ activestorage (= 7.0.4)
47
+ activesupport (= 7.0.4)
67
48
  globalid (>= 0.6.0)
68
49
  nokogiri (>= 1.8.5)
69
- actionview (7.0.3.1)
70
- activesupport (= 7.0.3.1)
50
+ actionview (7.0.4)
51
+ activesupport (= 7.0.4)
71
52
  builder (~> 3.1)
72
53
  erubi (~> 1.4)
73
54
  rails-dom-testing (~> 2.0)
74
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
75
- activejob (7.0.3.1)
76
- activesupport (= 7.0.3.1)
56
+ activejob (7.0.4)
57
+ activesupport (= 7.0.4)
77
58
  globalid (>= 0.3.6)
78
- activemodel (7.0.3.1)
79
- activesupport (= 7.0.3.1)
80
- activerecord (7.0.3.1)
81
- activemodel (= 7.0.3.1)
82
- activesupport (= 7.0.3.1)
83
- activestorage (7.0.3.1)
84
- actionpack (= 7.0.3.1)
85
- activejob (= 7.0.3.1)
86
- activerecord (= 7.0.3.1)
87
- activesupport (= 7.0.3.1)
59
+ activemodel (7.0.4)
60
+ activesupport (= 7.0.4)
61
+ activerecord (7.0.4)
62
+ activemodel (= 7.0.4)
63
+ activesupport (= 7.0.4)
64
+ activestorage (7.0.4)
65
+ actionpack (= 7.0.4)
66
+ activejob (= 7.0.4)
67
+ activerecord (= 7.0.4)
68
+ activesupport (= 7.0.4)
88
69
  marcel (~> 1.0)
89
70
  mini_mime (>= 1.1.0)
90
- activesupport (7.0.3.1)
71
+ activesupport (7.0.4)
91
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
92
73
  i18n (>= 1.6, < 2)
93
74
  minitest (>= 5.1)
@@ -103,7 +84,7 @@ GEM
103
84
  i18n (1.12.0)
104
85
  concurrent-ruby (~> 1.0)
105
86
  json (2.6.2)
106
- loofah (2.18.0)
87
+ loofah (2.19.0)
107
88
  crass (~> 1.0.2)
108
89
  nokogiri (>= 1.5.9)
109
90
  mail (2.7.1)
@@ -136,28 +117,28 @@ GEM
136
117
  rack (2.2.4)
137
118
  rack-test (2.0.2)
138
119
  rack (>= 1.3)
139
- rails (7.0.3.1)
140
- actioncable (= 7.0.3.1)
141
- actionmailbox (= 7.0.3.1)
142
- actionmailer (= 7.0.3.1)
143
- actionpack (= 7.0.3.1)
144
- actiontext (= 7.0.3.1)
145
- actionview (= 7.0.3.1)
146
- activejob (= 7.0.3.1)
147
- activemodel (= 7.0.3.1)
148
- activerecord (= 7.0.3.1)
149
- activestorage (= 7.0.3.1)
150
- activesupport (= 7.0.3.1)
120
+ rails (7.0.4)
121
+ actioncable (= 7.0.4)
122
+ actionmailbox (= 7.0.4)
123
+ actionmailer (= 7.0.4)
124
+ actionpack (= 7.0.4)
125
+ actiontext (= 7.0.4)
126
+ actionview (= 7.0.4)
127
+ activejob (= 7.0.4)
128
+ activemodel (= 7.0.4)
129
+ activerecord (= 7.0.4)
130
+ activestorage (= 7.0.4)
131
+ activesupport (= 7.0.4)
151
132
  bundler (>= 1.15.0)
152
- railties (= 7.0.3.1)
133
+ railties (= 7.0.4)
153
134
  rails-dom-testing (2.0.3)
154
135
  activesupport (>= 4.2.0)
155
136
  nokogiri (>= 1.6)
156
137
  rails-html-sanitizer (1.4.3)
157
138
  loofah (~> 2.3)
158
- railties (7.0.3.1)
159
- actionpack (= 7.0.3.1)
160
- activesupport (= 7.0.3.1)
139
+ railties (7.0.4)
140
+ actionpack (= 7.0.4)
141
+ activesupport (= 7.0.4)
161
142
  method_source
162
143
  rake (>= 12.2)
163
144
  thor (~> 1.0)
@@ -182,6 +163,13 @@ GEM
182
163
  strscan (3.0.4)
183
164
  thor (1.2.1)
184
165
  timeout (0.3.0)
166
+ turbo-rails (1.3.0)
167
+ actionpack (>= 6.0.0)
168
+ activejob (>= 6.0.0)
169
+ railties (>= 6.0.0)
170
+ turbo_ready (0.1.0)
171
+ rails (>= 6.1)
172
+ turbo-rails (>= 1.1)
185
173
  tzinfo (2.0.5)
186
174
  concurrent-ruby (~> 1.0)
187
175
  unicode-display_width (2.2.0)
@@ -197,9 +185,7 @@ DEPENDENCIES
197
185
  minitest (~> 5.0)
198
186
  rake (~> 13.0)
199
187
  rubocop (~> 1.21)
200
- turbo-rails!
201
188
  turbo_power!
202
- turbo_ready!
203
189
 
204
190
  BUNDLED WITH
205
191
  2.3.19
data/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # TurboPower Rails
2
2
 
3
- `turbo_power` is a power-pack for Turbo Streams. This gem provides server-side Ruby helpers for the NPM package [`turbo_power`](https://github.com/marcoroth/turbo_power).
3
+ TurboPower Rails is a power-pack for Turbo Streams. This gem provides server-side Ruby helpers for the NPM package [`turbo_power`](https://github.com/marcoroth/turbo_power).
4
+
5
+ ## Important Note
6
+
7
+ This is very much a work in progress right now. This requires the NPM package `@hotwired/turbo >= 7.2.0` or `@hotwired/turbo-rails >= 7.2.0` and the gem `turbo-rails >= 1.3.0`.
8
+
9
+ **Also:** I can't guarantee that the current API stays that way, there might be even more ways to improve it.
10
+
4
11
 
5
12
  ## Installation
6
13
 
@@ -87,6 +94,7 @@ import * as Turbo from '@hotwired/turbo'
87
94
  * `turbo_stream.set_cookie(cookie, **attributes)`
88
95
  * `turbo_stream.set_cookie_item(key, value, **attributes)`
89
96
  * `turbo_stream.set_focus(target, **attributes)`
97
+ * `turbo_stream.set_title(title, **attributes)`
90
98
 
91
99
 
92
100
  ### Browser History Actions
@@ -105,6 +113,11 @@ import * as Turbo from '@hotwired/turbo'
105
113
 
106
114
  * `turbo_stream.notification(title, options, **attributes)`
107
115
 
116
+ ### Turbo Frame Actions
117
+
118
+ * `turbo_stream.reload_turbo_frame(frame_id, **attributes)`
119
+ * `turbo_stream.set_turbo_frame_src(frame_id, src, **attributes)`
120
+
108
121
  ## Development
109
122
 
110
123
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require "rake/testtask"
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
8
8
  t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
12
  require "rubocop/rake_task"
@@ -1,6 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rails/engine"
2
4
 
3
5
  module TurboPower
4
6
  class Engine < Rails::Engine
7
+ initializer "turbo_power.helpers", after: :initialize do
8
+ Turbo::Streams::TagBuilder.include(TurboPower::StreamHelper)
9
+ end
5
10
  end
6
11
  end
@@ -1,93 +1,106 @@
1
- require "turbo-rails"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module TurboPower
4
4
  module StreamHelper
5
+ # Custom Action Helpers
6
+
7
+ ## Also see:
8
+ ## => https://github.com/hotwired/turbo-rails/pull/374
9
+
10
+ def custom_action(name, target: nil, content: nil, allow_inferred_rendering: true, attributes: {}, **rendering, &block)
11
+ template = render_template(target, content, allow_inferred_rendering: allow_inferred_rendering, **rendering, &block)
12
+
13
+ turbo_stream_action_tag name, target: target, template: template, **attributes
14
+ end
15
+
16
+ def custom_action_all(name, targets: nil, content: nil, allow_inferred_rendering: true, attributes: {}, **rendering, &block)
17
+ template = render_template(targets, content, allow_inferred_rendering: allow_inferred_rendering, **rendering, &block)
18
+
19
+ turbo_stream_action_tag name, targets: targets, template: template, **attributes
20
+ end
5
21
 
6
22
  # DOM Actions
7
23
 
8
24
  def graft(target, parent, **attributes)
9
- action_all :graft, targets: target, attributes: attributes.merge(parent: parent)
25
+ custom_action_all :graft, targets: target, attributes: attributes.merge(parent: parent)
10
26
  end
11
27
 
12
28
  def inner_html(target, html = nil, **attributes, &block)
13
- action_all :inner_html, targets: target, content: html, attributes: attributes, &block
29
+ custom_action_all :inner_html, targets: target, content: html, attributes: attributes, &block
14
30
  end
15
31
 
16
32
  def insert_adjacent_html(target, html = nil, position: 'beforeend', **attributes, &block)
17
- action_all :insert_adjacent_html, targets: target, content: html, attributes: attributes.merge(position: position), &block
33
+ custom_action_all :insert_adjacent_html, targets: target, content: html, attributes: attributes.merge(position: position), &block
18
34
  end
19
35
 
20
36
  def insert_adjacent_text(target, text, position: 'beforebegin', **attributes)
21
- action_all :insert_adjacent_text, targets: target, content: "", attributes: attributes.merge(text: text, position: position)
37
+ custom_action_all :insert_adjacent_text, targets: target, content: "", attributes: attributes.merge(text: text, position: position)
22
38
  end
23
39
 
24
- def morph(target, html = nil, **attribtues, &block)
25
- action_all :morph, targets: target, content: html, attributes: attributes, &block
40
+ def morph(target, html = nil, **attributes, &block)
41
+ custom_action_all :morph, targets: target, content: html, attributes: attributes, &block
26
42
  end
27
43
 
28
44
  def outer_html(target, html = nil, **attributes, &block)
29
- action_all :outer_html, targets: target, content: html, attributes: attributes, &block
45
+ custom_action_all :outer_html, targets: target, content: html, attributes: attributes, &block
30
46
  end
31
47
 
32
48
  def text_content(target, text, **attributes)
33
- action_all :text_content, targets: target, attributes: attributes.merge(text: text)
49
+ custom_action_all :text_content, targets: target, attributes: attributes.merge(text: text)
34
50
  end
35
51
 
36
52
  def set_meta(name, content, **attributes)
37
- action :set_meta, attributes: attributes.merge(name: name, content: content)
53
+ custom_action :set_meta, attributes: attributes.merge(name: name, content: content)
38
54
  end
39
55
 
40
-
41
56
  # Attribute Actions
42
57
 
43
58
  def add_css_class(target, classes, **attributes)
44
- action_all :add_css_class, targets: target, attributes: attributes.merge(classes: classes)
59
+ custom_action_all :add_css_class, targets: target, attributes: attributes.merge(classes: classes)
45
60
  end
46
61
 
47
62
  def remove_attribute(target, attribute, **attributes)
48
- action_all :remove_attribute, targets: target, attributes: attributes.merge(attribute: attribute)
63
+ custom_action_all :remove_attribute, targets: target, attributes: attributes.merge(attribute: attribute)
49
64
  end
50
65
 
51
66
  def remove_css_class(target, classes, **attributes)
52
- action_all :remove_css_class, targets: target, attributes: attributes.merge(classes: classes)
67
+ custom_action_all :remove_css_class, targets: target, attributes: attributes.merge(classes: classes)
53
68
  end
54
69
 
55
70
  def set_attribute(target, attribute, value, **attributes)
56
- action_all :set_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
71
+ custom_action_all :set_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
57
72
  end
58
73
 
59
74
  def set_dataset_attribute(target, attribute, value, **attributes)
60
- action_all :set_dataset_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
75
+ custom_action_all :set_dataset_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
61
76
  end
62
77
 
63
78
  def set_property(target, property, value, **attributes)
64
- action_all :set_property, targets: target, attributes: attributes.merge(property: property, value: value)
79
+ custom_action_all :set_property, targets: target, attributes: attributes.merge(property: property, value: value)
65
80
  end
66
81
 
67
82
  def set_style(target, name, value, **attributes)
68
- action_all :set_style, targets: target, attributes: attributes.merge(name: name, value: value)
83
+ custom_action_all :set_style, targets: target, attributes: attributes.merge(name: name, value: value)
69
84
  end
70
85
 
71
86
  def set_styles(target, styles, **attributes)
72
- action_all :set_styles, targets: target, attributes: attributes.merge(styles: styles)
87
+ custom_action_all :set_styles, targets: target, attributes: attributes.merge(styles: styles)
73
88
  end
74
89
 
75
90
  def set_value(target, value, **attributes)
76
- action_all :set_value, targets: target, attribtues: attributes.merge(value: value)
91
+ custom_action_all :set_value, targets: target, attribtues: attributes.merge(value: value)
77
92
  end
78
93
 
79
-
80
94
  # Event Actions
81
95
 
82
96
  def dispatch_event(target, name, detail: {}, **attributes)
83
- action_all :dispatch_event, targets: target, attributes: attributes.merge(detail: detail)
97
+ custom_action_all :dispatch_event, targets: target, attributes: attributes.merge(name: name, detail: detail)
84
98
  end
85
99
 
86
-
87
100
  # Storage Actions
88
101
 
89
102
  def clear_storage(type, **attributes)
90
- action :clear_storage, attributes: attributes.merge(type: type)
103
+ custom_action :clear_storage, attributes: attributes.merge(type: type)
91
104
  end
92
105
 
93
106
  def clear_local_storage(**attributes)
@@ -99,7 +112,7 @@ module TurboPower
99
112
  end
100
113
 
101
114
  def remove_storage_item(key, type, **attributes)
102
- action :remove_storage_item, attributes: attributes.merge(key: key, type: type)
115
+ custom_action :remove_storage_item, attributes: attributes.merge(key: key, type: type)
103
116
  end
104
117
 
105
118
  def remove_local_storage_item(key, **attributes)
@@ -110,9 +123,8 @@ module TurboPower
110
123
  remove_storage_item(key, "session", **attributes)
111
124
  end
112
125
 
113
-
114
126
  def set_storage_item(key, value, type, **attributes)
115
- action :set_storage_item, attributes: attributes.merge(key: key, type: type, value: value)
127
+ custom_action :set_storage_item, attributes: attributes.merge(key: key, type: type, value: value)
116
128
  end
117
129
 
118
130
  def set_local_storage_item(key, value, **attributes)
@@ -123,66 +135,74 @@ module TurboPower
123
135
  set_storage_item(key, value, "session", **attributes)
124
136
  end
125
137
 
126
-
127
138
  # Browser Actions
128
139
 
129
140
  def redirect_to(url, action_name = nil, **attributes)
130
- action :redirect_to, attributes: attributes.merge(url: url, action: action_name)
141
+ custom_action :redirect_to, attributes: attributes.merge(url: url, action: action_name)
131
142
  end
132
143
 
133
144
  def reload(**attributes)
134
- action :reload, attributes: attributes
145
+ custom_action :reload, attributes: attributes
135
146
  end
136
147
 
137
148
  def scroll_into_view(target, inline = "nearest", **attributes)
138
- action_all :scroll_into_view, targets: target, attributes: attributes.merge(inline: inline)
149
+ custom_action_all :scroll_into_view, targets: target, attributes: attributes.merge(inline: inline)
139
150
  end
140
151
 
141
152
  def set_cookie(cookie, **attributes)
142
- action :set_cookie, attributes: attributes.merge(cookie: cookie)
153
+ custom_action :set_cookie, attributes: attributes.merge(cookie: cookie)
143
154
  end
144
155
 
145
156
  def set_cookie_item(key, value, **attributes)
146
- action :set_cookie_item, attributes: attributes.merge(key: key, value: value)
157
+ custom_action :set_cookie_item, attributes: attributes.merge(key: key, value: value)
147
158
  end
148
159
 
149
160
  def set_focus(target, **attributes)
150
- action_all :set_focus, targets: target, attributes: attributes
161
+ custom_action_all :set_focus, targets: target, attributes: attributes
151
162
  end
152
163
 
164
+ def set_title(title, **attributes)
165
+ custom_action :set_title, attributes: attributes.merge(title: title)
166
+ end
153
167
 
154
168
  # Browser History Actions
155
169
 
156
170
  def history_go(delta, **attributes)
157
- action :history_go, attributes: attributes.merge(delta: delta)
171
+ custom_action :history_go, attributes: attributes.merge(delta: delta)
158
172
  end
159
173
 
160
174
  def push_state(url, title = nil, state = nil, **attributes)
161
- action :push_state, attributes: attributes.merge(url: url, title: title, state: state)
175
+ custom_action :push_state, attributes: attributes.merge(url: url, title: title, state: state)
162
176
  end
163
177
 
164
178
  def replace_state(url, title = nil, state = nil, **attributes)
165
- action :replace_state, attributes: attributes.merge(url: url, title: title, state: state)
179
+ custom_action :replace_state, attributes: attributes.merge(url: url, title: title, state: state)
166
180
  end
167
181
 
168
-
169
182
  # Debug Actions
170
183
 
171
184
  def console_log(message, level = :log, **attributes)
172
- action :console_log, attributes: attributes.merge(message: message, level: level)
185
+ custom_action :console_log, attributes: attributes.merge(message: message, level: level)
173
186
  end
174
187
 
175
188
  def console_table(data, columns, **attributes)
176
- action :console_table, attributes: attributes.merge(data: data, columns: columns)
189
+ custom_action :console_table, attributes: attributes.merge(data: data, columns: columns)
177
190
  end
178
191
 
179
192
  # Notification Actions
180
193
 
181
194
  def notification(title, options, **attributes)
182
- action :notification, attributes: attributes.merge(title: title, options: options)
195
+ custom_action :notification, attributes: attributes.merge(title: title, options: options)
183
196
  end
184
197
 
198
+ # Turbo Frame Actions
199
+
200
+ def reload_turbo_frame(frame_id, **attributes)
201
+ custom_action :reload_turbo_frame, target: frame_id, attributes: attributes
202
+ end
203
+
204
+ def set_turbo_frame_src(frame_id, src, **attributes)
205
+ custom_action :reload_turbo_frame, target: frame_id, attributes: attributes.merge(src: src)
206
+ end
185
207
  end
186
208
  end
187
-
188
- Turbo::Streams::TagBuilder.prepend(TurboPower::StreamHelper)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboPower
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/turbo_power.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "turbo-rails"
3
4
  require "turbo_ready"
5
+
4
6
  require_relative "turbo_power/version"
7
+ require_relative "turbo_power/engine"
5
8
  require_relative "turbo_power/stream_helper"
6
9
 
7
- TurboReady.patch!
8
-
9
10
  module TurboPower
10
11
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
- require "turbo_power"
5
4
 
5
+ require "turbo_power"
6
6
  require "minitest/autorun"
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ module TurboPower
6
+ class StreamHelperTest < Minitest::Test
7
+ def test_that_it_has_a_version_number
8
+ refute_nil ::TurboPower::VERSION
9
+ end
10
+ end
11
+ end
File without changes
data/turbo_power.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Marco Roth"]
9
9
  spec.email = ["marco.roth@hey.com"]
10
10
 
11
- spec.summary = "Powerpack for Turbo"
11
+ spec.summary = "Power-pack for Turbo Streams"
12
12
  spec.description = spec.summary
13
13
  spec.homepage = "https://github.com/marcoroth/turbo_power-rails"
14
14
  spec.license = "MIT"
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.test_files = Dir["test/**/*.rb"]
30
30
 
31
- spec.add_dependency "turbo-rails"
31
+ spec.add_dependency "turbo-rails", "~> 1.3.0"
32
32
  spec.add_dependency "turbo_ready"
33
33
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_power
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-27 00:00:00.000000000 Z
11
+ date: 2022-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turbo-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: turbo_ready
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Powerpack for Turbo
41
+ description: Power-pack for Turbo Streams
42
42
  email:
43
43
  - marco.roth@hey.com
44
44
  executables: []
@@ -52,7 +52,6 @@ files:
52
52
  - LICENSE.txt
53
53
  - README.md
54
54
  - Rakefile
55
- - app/helpers/turbo_power/streams/action_helper.rb
56
55
  - bin/console
57
56
  - bin/setup
58
57
  - lib/turbo_power.rb
@@ -60,7 +59,8 @@ files:
60
59
  - lib/turbo_power/stream_helper.rb
61
60
  - lib/turbo_power/version.rb
62
61
  - test/test_helper.rb
63
- - test/test_turbo_power.rb
62
+ - test/turbo_power/stream_helper_test.rb
63
+ - test/turbo_power_test.rb
64
64
  - turbo_power.gemspec
65
65
  homepage: https://github.com/marcoroth/turbo_power-rails
66
66
  licenses:
@@ -87,7 +87,8 @@ requirements: []
87
87
  rubygems_version: 3.3.3
88
88
  signing_key:
89
89
  specification_version: 4
90
- summary: Powerpack for Turbo
90
+ summary: Power-pack for Turbo Streams
91
91
  test_files:
92
92
  - test/test_helper.rb
93
- - test/test_turbo_power.rb
93
+ - test/turbo_power/stream_helper_test.rb
94
+ - test/turbo_power_test.rb
@@ -1,11 +0,0 @@
1
- require "turbo-rails"
2
-
3
- module TurboPower
4
- module Streams
5
- module ActionHelper
6
- include TurboPower::StreamHelper
7
- end
8
- end
9
- end
10
-
11
- Turbo::Streams::TagBuilder.prepend(TurboPower::StreamHelper)