turbo_power 0.1.1 → 0.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: 4ec77740a41b50382edd8441dcb76a453fc60d57d5429e107398de38578e147b
4
- data.tar.gz: f4419c8721ffd08fdcc02b1f1449d2671af16cc34c7e2f73185777276236bc27
3
+ metadata.gz: 73bf4679bb4712b484fa9d001b22bfb2e57876cf017e0d35558861f876a89e11
4
+ data.tar.gz: f5bdffd12145b20b8af6082fcbf6a192a577bdb18f9398ec13462c14bb415443
5
5
  SHA512:
6
- metadata.gz: 8f1a90e7eae214a0f6d3d1bcb371f4c8a9f06e302f5a8135a68027be105a6c93f549ba860de1bdc9be7959309c277458295661d9dbd14e2158583017ee931101
7
- data.tar.gz: 0a8753c7d57f4865ca27641d8767723dc1d97bda6c5e6fb37aee54f6f1d2e58e64d3e79d2a9472abbce1664e7abb22793d0073ad4d1e999bcc125838424d2f3c
6
+ metadata.gz: 01474ffee50a0511a12b57f0c5e8447103a5b3d7970b50497091bd181c2e7427e251e2c3163f2456ce76cff01d7ba790a75babdb97f02c165233ee15a9159c42
7
+ data.tar.gz: 063b9f28b2996276dde7ce83faa87fabcc25ebcf6bf658987721e591df5572a9e5aa5656c0bcff94fcf2bbfe529266dca5524ee7c8b2715fc08a134b36c6ede9
data/Gemfile CHANGED
@@ -6,9 +6,9 @@ gemspec
6
6
 
7
7
  gem "rake", "~> 13.0"
8
8
 
9
- gem "minitest", "~> 5.0"
10
-
11
9
  gem "rubocop", "~> 1.21"
12
10
 
13
- gem "turbo-rails", github: "marcoroth/turbo-rails", branch: "custom-action-helpers"
14
- gem "turbo_ready", github: "marcoroth/turbo_ready", branch: "main"
11
+ group :test do
12
+ gem "sprockets-rails"
13
+ gem "sqlite3"
14
+ end
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.3)
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)
@@ -129,6 +110,8 @@ GEM
129
110
  nio4r (2.5.8)
130
111
  nokogiri (1.13.8-x86_64-darwin)
131
112
  racc (~> 1.4)
113
+ nokogiri (1.13.8-x86_64-linux)
114
+ racc (~> 1.4)
132
115
  parallel (1.22.1)
133
116
  parser (3.1.2.1)
134
117
  ast (~> 2.4.1)
@@ -136,28 +119,28 @@ GEM
136
119
  rack (2.2.4)
137
120
  rack-test (2.0.2)
138
121
  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)
122
+ rails (7.0.4)
123
+ actioncable (= 7.0.4)
124
+ actionmailbox (= 7.0.4)
125
+ actionmailer (= 7.0.4)
126
+ actionpack (= 7.0.4)
127
+ actiontext (= 7.0.4)
128
+ actionview (= 7.0.4)
129
+ activejob (= 7.0.4)
130
+ activemodel (= 7.0.4)
131
+ activerecord (= 7.0.4)
132
+ activestorage (= 7.0.4)
133
+ activesupport (= 7.0.4)
151
134
  bundler (>= 1.15.0)
152
- railties (= 7.0.3.1)
135
+ railties (= 7.0.4)
153
136
  rails-dom-testing (2.0.3)
154
137
  activesupport (>= 4.2.0)
155
138
  nokogiri (>= 1.6)
156
139
  rails-html-sanitizer (1.4.3)
157
140
  loofah (~> 2.3)
158
- railties (7.0.3.1)
159
- actionpack (= 7.0.3.1)
160
- activesupport (= 7.0.3.1)
141
+ railties (7.0.4)
142
+ actionpack (= 7.0.4)
143
+ activesupport (= 7.0.4)
161
144
  method_source
162
145
  rake (>= 12.2)
163
146
  thor (~> 1.0)
@@ -179,9 +162,25 @@ GEM
179
162
  rubocop-ast (1.21.0)
180
163
  parser (>= 3.1.1.0)
181
164
  ruby-progressbar (1.11.0)
165
+ sprockets (4.1.1)
166
+ concurrent-ruby (~> 1.0)
167
+ rack (> 1, < 3)
168
+ sprockets-rails (3.4.2)
169
+ actionpack (>= 5.2)
170
+ activesupport (>= 5.2)
171
+ sprockets (>= 3.0.0)
172
+ sqlite3 (1.5.0-x86_64-darwin)
173
+ sqlite3 (1.5.0-x86_64-linux)
182
174
  strscan (3.0.4)
183
175
  thor (1.2.1)
184
176
  timeout (0.3.0)
177
+ turbo-rails (1.3.0)
178
+ actionpack (>= 6.0.0)
179
+ activejob (>= 6.0.0)
180
+ railties (>= 6.0.0)
181
+ turbo_ready (0.1.0)
182
+ rails (>= 6.1)
183
+ turbo-rails (>= 1.1)
185
184
  tzinfo (2.0.5)
186
185
  concurrent-ruby (~> 1.0)
187
186
  unicode-display_width (2.2.0)
@@ -192,14 +191,14 @@ GEM
192
191
 
193
192
  PLATFORMS
194
193
  x86_64-darwin-19
194
+ x86_64-linux
195
195
 
196
196
  DEPENDENCIES
197
- minitest (~> 5.0)
198
197
  rake (~> 13.0)
199
198
  rubocop (~> 1.21)
200
- turbo-rails!
199
+ sprockets-rails
200
+ sqlite3
201
201
  turbo_power!
202
- turbo_ready!
203
202
 
204
203
  BUNDLED WITH
205
204
  2.3.19
data/README.md CHANGED
@@ -1,6 +1,34 @@
1
- # TurboPower Rails
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="assets/hero-dark.png">
4
+ <img src="assets/hero.png" height="340px">
5
+ </picture>
6
+ </p>
7
+
8
+ <h1 align="center">TurboPower for Rails</h1>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/marcoroth/turbo_power">
12
+ <img src="https://github.com/marcoroth/turbo_power-rails/actions/workflows/tests.yml/badge.svg">
13
+ </a>
14
+ <a href="https://rubygems.org/gems/turbo_power">
15
+ <img alt="GEM Version" src="https://img.shields.io/gem/v/turbo_power?color=38C160&logo=ruby&logoColor=FE1616">
16
+ </a>
17
+ <a href="https://rubygems.org/gems/turbo_power">
18
+ <img alt="Gem Downloads" src="https://img.shields.io/gem/dt/turbo_power?color=38C160&logo=ruby&logoColor=FE1616">
19
+ </a>
20
+ </p>
21
+
22
+ ## Getting Started
23
+
24
+ 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).
25
+
26
+ ## Important Note
27
+
28
+ 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`.
29
+
30
+ **Also:** I can't guarantee that the current API stays that way, there might be even more ways to improve it.
2
31
 
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).
4
32
 
5
33
  ## Installation
6
34
 
@@ -87,6 +115,7 @@ import * as Turbo from '@hotwired/turbo'
87
115
  * `turbo_stream.set_cookie(cookie, **attributes)`
88
116
  * `turbo_stream.set_cookie_item(key, value, **attributes)`
89
117
  * `turbo_stream.set_focus(target, **attributes)`
118
+ * `turbo_stream.set_title(title, **attributes)`
90
119
 
91
120
 
92
121
  ### Browser History Actions
@@ -105,6 +134,11 @@ import * as Turbo from '@hotwired/turbo'
105
134
 
106
135
  * `turbo_stream.notification(title, options, **attributes)`
107
136
 
137
+ ### Turbo Frame Actions
138
+
139
+ * `turbo_stream.reload_turbo_frame(frame_id, **attributes)`
140
+ * `turbo_stream.set_turbo_frame_src(frame_id, src, **attributes)`
141
+
108
142
  ## Development
109
143
 
110
144
  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
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bundler/setup"
3
4
  require "bundler/gem_tasks"
4
5
  require "rake/testtask"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << "test"
8
9
  t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ t.warning = false
10
12
  end
11
13
 
12
14
  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
- 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
32
+ def insert_adjacent_html(target, html = nil, position: "beforeend", **attributes, &block)
33
+ custom_action_all :insert_adjacent_html, targets: target, content: html, attributes: attributes.merge(position: position), &block
18
34
  end
19
35
 
20
- 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)
36
+ def insert_adjacent_text(target, text, position: "beforebegin", **attributes)
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), content: detail.to_json
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.3"
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/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"
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/marcoroth/turbo_power-rails"
19
19
  spec.metadata["changelog_uri"] = "https://github.com/marcoroth/turbo_power-rails/blob/main/CHANGELOG.md"
20
+ spec.metadata["rubygems_mfa_required"] = "true"
20
21
 
21
22
  spec.files = Dir[
22
23
  "lib/**/*.{rb,rake}",
@@ -26,8 +27,6 @@ Gem::Specification.new do |spec|
26
27
  "[A-Z]*"
27
28
  ]
28
29
 
29
- spec.test_files = Dir["test/**/*.rb"]
30
-
31
- spec.add_dependency "turbo-rails"
30
+ spec.add_dependency "turbo-rails", "~> 1.3.0"
32
31
  spec.add_dependency "turbo_ready"
33
32
  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.3
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-25 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,15 +52,12 @@ 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
59
58
  - lib/turbo_power/engine.rb
60
59
  - lib/turbo_power/stream_helper.rb
61
60
  - lib/turbo_power/version.rb
62
- - test/test_helper.rb
63
- - test/test_turbo_power.rb
64
61
  - turbo_power.gemspec
65
62
  homepage: https://github.com/marcoroth/turbo_power-rails
66
63
  licenses:
@@ -69,6 +66,7 @@ metadata:
69
66
  homepage_uri: https://github.com/marcoroth/turbo_power-rails
70
67
  source_code_uri: https://github.com/marcoroth/turbo_power-rails
71
68
  changelog_uri: https://github.com/marcoroth/turbo_power-rails/blob/main/CHANGELOG.md
69
+ rubygems_mfa_required: 'true'
72
70
  post_install_message:
73
71
  rdoc_options: []
74
72
  require_paths:
@@ -87,7 +85,5 @@ requirements: []
87
85
  rubygems_version: 3.3.3
88
86
  signing_key:
89
87
  specification_version: 4
90
- summary: Powerpack for Turbo
91
- test_files:
92
- - test/test_helper.rb
93
- - test/test_turbo_power.rb
88
+ summary: Power-pack for Turbo Streams
89
+ test_files: []
@@ -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)
data/test/test_helper.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
- require "turbo_power"
5
-
6
- require "minitest/autorun"
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- class TestTurboPower < Minitest::Test
6
- def test_that_it_has_a_version_number
7
- refute_nil ::TurboPower::VERSION
8
- end
9
- end