turbo_power 0.3.0 → 0.4.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: 9d0cf2328b31e22e539408a960588cbd9ce68297ed1ac36f74dce79c1be8d121
4
- data.tar.gz: 314ea1dd8efaae21dde0b4b0e7a6e8654d744ec31e01920d87cb5fc862c4175a
3
+ metadata.gz: 169485f07b14d287277676057c5fbc40f0d2a3f99ea935ac68205e19005dca7a
4
+ data.tar.gz: ece7bbaabd4b88f0c4eafe98bd1f9e107f593369c121de4e3b153208fea7bff9
5
5
  SHA512:
6
- metadata.gz: d1195a4d9057abdf92df80452176ad592b5966e35e567fe57e38ac135240c1c6053397c041788a7ead9478e39bc3eee9cc2c7373c9ed2851dbf886d34de6731e
7
- data.tar.gz: 95a088485d9674e56a123f6c5a67da38b6d748e058ce8a0bb7c730568bb6c58001d8b385dc4f38fed8dba80ac62087f729aeb95777bbecfe0d7b7227aa119dd5
6
+ metadata.gz: 0c6f701b207610e647f4c820ce3a2d0b4abd02e3ca41f152d62782f37122a034645a59e9ca0571d621d610730206ae0b231a63b4af10753458f01d313bb4fa04
7
+ data.tar.gz: c9fa746cfb4337ac4ee7786dad0caeb67f5e42283d77b8fc05345d2165224a8bc1ed549aec00edf8c450a575aa8d1d4bb48a33e7ef6e74e9fe204e728a4b7ae5
data/Gemfile CHANGED
@@ -5,10 +5,10 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  gem "rake", "~> 13.0"
8
-
9
8
  gem "rubocop", "~> 1.21"
10
9
 
11
10
  group :test do
12
11
  gem "sprockets-rails"
13
12
  gem "sqlite3"
13
+ gem "simplecov"
14
14
  end
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_power (0.2.0)
5
- turbo-rails (~> 1.3.0)
4
+ turbo_power (0.4.0)
5
+ turbo-rails (~> 1.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -30,8 +30,9 @@ GEM
30
30
  tzinfo (~> 2.0)
31
31
  ast (2.4.2)
32
32
  builder (3.2.4)
33
- concurrent-ruby (1.2.0)
33
+ concurrent-ruby (1.2.2)
34
34
  crass (1.0.6)
35
+ docile (1.4.0)
35
36
  erubi (1.12.0)
36
37
  globalid (1.1.0)
37
38
  activesupport (>= 5.0)
@@ -42,9 +43,8 @@ GEM
42
43
  crass (~> 1.0.2)
43
44
  nokogiri (>= 1.5.9)
44
45
  method_source (1.0.0)
45
- mini_portile2 (2.8.1)
46
46
  minitest (5.17.0)
47
- nokogiri (1.14.1-x86_64-darwin)
47
+ nokogiri (1.14.2-x86_64-darwin)
48
48
  racc (~> 1.4)
49
49
  parallel (1.22.1)
50
50
  parser (3.1.3.0)
@@ -82,6 +82,12 @@ GEM
82
82
  rubocop-ast (1.24.0)
83
83
  parser (>= 3.1.1.0)
84
84
  ruby-progressbar (1.11.0)
85
+ simplecov (0.22.0)
86
+ docile (~> 1.1)
87
+ simplecov-html (~> 0.11)
88
+ simplecov_json_formatter (~> 0.1)
89
+ simplecov-html (0.12.3)
90
+ simplecov_json_formatter (0.1.4)
85
91
  sprockets (4.2.0)
86
92
  concurrent-ruby (~> 1.0)
87
93
  rack (>= 2.2.4, < 4)
@@ -89,8 +95,7 @@ GEM
89
95
  actionpack (>= 5.2)
90
96
  activesupport (>= 5.2)
91
97
  sprockets (>= 3.0.0)
92
- sqlite3 (1.5.4)
93
- mini_portile2 (~> 2.8.0)
98
+ sqlite3 (1.5.4-x86_64-darwin)
94
99
  thor (1.2.1)
95
100
  turbo-rails (1.3.3)
96
101
  actionpack (>= 6.0.0)
@@ -103,10 +108,12 @@ GEM
103
108
 
104
109
  PLATFORMS
105
110
  x86_64-darwin-19
111
+ x86_64-darwin-22
106
112
 
107
113
  DEPENDENCIES
108
114
  rake (~> 13.0)
109
115
  rubocop (~> 1.21)
116
+ simplecov
110
117
  sprockets-rails
111
118
  sqlite3
112
119
  turbo_power!
data/README.md CHANGED
@@ -87,37 +87,37 @@ import 'controllers'
87
87
 
88
88
  ### DOM Actions
89
89
 
90
- * `turbo_stream.graft(target, parent, **attributes)`
91
- * [`turbo_stream.morph(target, html = nil, **attributes, &block)`](https://github.com/marcoroth/turbo-morph)
92
- * `turbo_stream.inner_html(target, html = nil, **attributes, &block)`
93
- * `turbo_stream.insert_adjacent_html(target, html = nil, position: 'beforeend', **attributes, &block)`
94
- * `turbo_stream.insert_adjacent_text(target, text, position: 'beforebegin', **attributes)`
95
- * `turbo_stream.outer_html(target, html = nil, **attributes, &block)`
96
- * `turbo_stream.text_content(target, text, **attributes)`
97
- * `turbo_stream.set_meta(name, content)`
90
+ * `turbo_stream.graft(targets, parent, **attributes)`
91
+ * [`turbo_stream.morph(targets, html = nil, **attributes, &block)`](https://github.com/marcoroth/turbo-morph)
92
+ * `turbo_stream.inner_html(targets, html = nil, **attributes, &block)`
93
+ * `turbo_stream.insert_adjacent_html(targets, html = nil, position: 'beforeend', **attributes, &block)`
94
+ * `turbo_stream.insert_adjacent_text(targets, text, position: 'beforebegin', **attributes)`
95
+ * `turbo_stream.outer_html(targets, html = nil, **attributes, &block)`
96
+ * `turbo_stream.text_content(targets, text, **attributes)`
97
+ * `turbo_stream.set_meta(name, content, **attributes)`
98
98
 
99
99
 
100
100
  ### Attribute Actions
101
101
 
102
- * `turbo_stream.add_css_class(target, classes, **attributes)`
103
- * `turbo_stream.remove_attribute(target, attribute, **attributes)`
104
- * `turbo_stream.remove_css_class(target, classes, **attributes)`
105
- * `turbo_stream.set_attribute(target, attribute, value, **attributes)`
106
- * `turbo_stream.set_dataset_attribute(target, attribute, value, **attributes)`
107
- * `turbo_stream.set_property(target, property, value, **attributes)`
108
- * `turbo_stream.set_style(target, name, value, **attributes)`
109
- * `turbo_stream.set_styles(target, styles, **attributes)`
110
- * `turbo_stream.set_value(target, value, **attributes)`
102
+ * `turbo_stream.add_css_class(targets, classes, **attributes)`
103
+ * `turbo_stream.remove_attribute(targets, attribute, **attributes)`
104
+ * `turbo_stream.remove_css_class(targets, classes, **attributes)`
105
+ * `turbo_stream.set_attribute(targets, attribute, value, **attributes)`
106
+ * `turbo_stream.set_dataset_attribute(targets, attribute, value, **attributes)`
107
+ * `turbo_stream.set_property(targets, name, value, **attributes)`
108
+ * `turbo_stream.set_style(targets, name, value, **attributes)`
109
+ * `turbo_stream.set_styles(targets, styles, **attributes)`
110
+ * `turbo_stream.set_value(targets, value, **attributes)`
111
111
 
112
112
 
113
113
  ### Event Actions
114
114
 
115
- * `turbo_stream.dispatch_event(target, name, detail: {}, **attributes)`
115
+ * `turbo_stream.dispatch_event(targets, name, detail: {}, **attributes)`
116
116
 
117
117
 
118
118
  ### Form Actions
119
119
 
120
- * `turbo_stream.reset_form(target, **attributes)`
120
+ * `turbo_stream.reset_form(targets, **attributes)`
121
121
 
122
122
 
123
123
  ### Storage Actions
@@ -136,8 +136,8 @@ import 'controllers'
136
136
  ### Browser Actions
137
137
 
138
138
  * `turbo_stream.reload(**attributes)`
139
- * `turbo_stream.scroll_into_view(target, inline = "nearest")`
140
- * `turbo_stream.set_focus(target, **attributes)`
139
+ * `turbo_stream.scroll_into_view(targets, **attributes)`
140
+ * `turbo_stream.set_focus(targets, **attributes)`
141
141
  * `turbo_stream.set_title(title, **attributes)`
142
142
 
143
143
 
@@ -149,15 +149,17 @@ import 'controllers'
149
149
 
150
150
  ### Browser History Actions
151
151
 
152
- * `turbo_stream.history_go(delta, **attributes)`
153
- * `turbo_stream.push_state(url, title = nil, state = nil, **attributes)`
154
- * `turbo_stream.replace_state(url, title = nil, state = nil, **attributes)`
152
+ * `turbo_stream.history_back(**attributes)`
153
+ * `turbo_stream.history_forward(**attributes)`
154
+ * `turbo_stream.history_go(delta = 0, **attributes)`
155
+ * `turbo_stream.push_state(url, title = "", state = {}, **attributes)`
156
+ * `turbo_stream.replace_state(url, title = "", state = {}, **attributes)`
155
157
 
156
158
 
157
159
  ### Debug Actions
158
160
 
159
- * `turbo_stream.console_log(message, level = :log)`
160
- * `turbo_stream.console_table(data, columns)`
161
+ * `turbo_stream.console_log(message, level = :log, **attributes)`
162
+ * `turbo_stream.console_table(data, columns, **attributes)`
161
163
 
162
164
 
163
165
  ### Notification Actions
@@ -167,21 +169,21 @@ import 'controllers'
167
169
 
168
170
  ### Turbo Actions
169
171
 
170
- * `turbo_stream.redirect_to(url, turbo_action = nil, **attributes)`
172
+ * `turbo_stream.redirect_to(url, turbo_action = nil, turbo_frame = nil, **attributes)`
171
173
  * `turbo_stream.turbo_clear_cache()`
172
174
 
173
175
 
174
176
  ### Turbo Progress Bar Actions
175
177
 
176
- * `turbo_stream.turbo_progress_bar_show()`
177
- * `turbo_stream.turbo_progress_bar_hide()`
178
- * `turbo_stream.turbo_progress_bar_set_value(value)`
178
+ * `turbo_stream.turbo_progress_bar_show(**attributes)`
179
+ * `turbo_stream.turbo_progress_bar_hide(**attributes)`
180
+ * `turbo_stream.turbo_progress_bar_set_value(value, **attributes)`
179
181
 
180
182
 
181
183
  ### Turbo Frame Actions
182
184
 
183
- * `turbo_stream.turbo_frame_reload(frame_id)`
184
- * `turbo_stream.turbo_frame_set_src(frame_id, src)`
185
+ * `turbo_stream.turbo_frame_reload(frame_id, **attributes)`
186
+ * `turbo_stream.turbo_frame_set_src(frame_id, src, **attributes)`
185
187
 
186
188
 
187
189
  ## Development
@@ -18,6 +18,8 @@ module TurboPower
18
18
  case value
19
19
  when String
20
20
  value
21
+ when Symbol
22
+ value.to_s
21
23
  when NilClass
22
24
  ""
23
25
  else
@@ -19,92 +19,109 @@ module TurboPower
19
19
 
20
20
  # DOM Actions
21
21
 
22
- def graft(target, parent, **attributes)
23
- custom_action_all :graft, targets: target, attributes: attributes.merge(parent: parent)
22
+ def graft(targets = nil, parent = nil, **attributes)
23
+ custom_action_all :graft, targets: targets, attributes: attributes.reverse_merge(parent: parent)
24
24
  end
25
25
 
26
- def inner_html(target, html = nil, **attributes, &block)
27
- custom_action_all :inner_html, targets: target, content: html, attributes: attributes, &block
26
+ def inner_html(targets = nil, html = nil, **attributes, &block)
27
+ html = attributes[:html] || html
28
+
29
+ custom_action_all :inner_html, targets: targets, content: html, attributes: attributes.except(:html), &block
28
30
  end
29
31
 
30
- def insert_adjacent_html(target, html = nil, position: "beforeend", **attributes, &block)
31
- custom_action_all :insert_adjacent_html, targets: target, content: html, attributes: attributes.merge(position: position), &block
32
+ def insert_adjacent_html(targets = nil, html = nil, position: "beforeend", **attributes, &block)
33
+ html = attributes[:html] || html
34
+
35
+ custom_action_all :insert_adjacent_html, targets: targets, content: html, attributes: attributes.merge(position: position).except(:html), &block
32
36
  end
33
37
 
34
- def insert_adjacent_text(target, text, position: "beforebegin", **attributes)
35
- custom_action_all :insert_adjacent_text, targets: target, content: "", attributes: attributes.merge(text: text, position: position)
38
+ def insert_adjacent_text(targets = nil, text = nil, position: "beforebegin", **attributes)
39
+ custom_action_all :insert_adjacent_text, targets: targets, attributes: attributes.reverse_merge(text: text, position: position)
36
40
  end
37
41
 
38
- def morph(target, html = nil, **attributes, &block)
39
- custom_action_all :morph, targets: target, content: html, attributes: attributes, &block
42
+ def morph(targets = nil, html = nil, **attributes, &block)
43
+ html = attributes[:html] || html
44
+
45
+ custom_action_all :morph, targets: targets, content: html, attributes: attributes.except(:html), &block
40
46
  end
41
47
 
42
- def outer_html(target, html = nil, **attributes, &block)
43
- custom_action_all :outer_html, targets: target, content: html, attributes: attributes, &block
48
+ def outer_html(targets = nil, html = nil, **attributes, &block)
49
+ html = attributes[:html] || html
50
+
51
+ custom_action_all :outer_html, targets: targets, content: html, attributes: attributes.except(:html), &block
44
52
  end
45
53
 
46
- def text_content(target, text, **attributes)
47
- custom_action_all :text_content, targets: target, attributes: attributes.merge(text: text)
54
+ def text_content(targets = nil, text = nil, **attributes)
55
+ custom_action_all :text_content, targets: targets, attributes: attributes.reverse_merge(text: text)
48
56
  end
49
57
 
50
- def set_meta(name, content, **attributes)
51
- custom_action :set_meta, attributes: attributes.merge(name: name, content: content)
58
+ def set_meta(name = nil, content = nil, **attributes)
59
+ custom_action :set_meta, attributes: attributes.reverse_merge(name: name, content: content)
52
60
  end
53
61
 
54
62
  # Attribute Actions
55
63
 
56
- def add_css_class(target, classes, **attributes)
57
- custom_action_all :add_css_class, targets: target, attributes: attributes.merge(classes: classes)
64
+ def add_css_class(targets = nil, classes = "", **attributes)
65
+ classes = attributes[:classes] || classes
66
+ classes = classes.join(" ") if classes.is_a?(Array)
67
+
68
+ custom_action_all :add_css_class, targets: targets, attributes: attributes.merge(classes: classes)
58
69
  end
59
70
 
60
- def remove_attribute(target, attribute, **attributes)
61
- custom_action_all :remove_attribute, targets: target, attributes: attributes.merge(attribute: attribute)
71
+ def remove_attribute(targets = nil, attribute = nil, **attributes)
72
+ custom_action_all :remove_attribute, targets: targets, attributes: attributes.reverse_merge(attribute: attribute)
62
73
  end
63
74
 
64
- def remove_css_class(target, classes, **attributes)
65
- custom_action_all :remove_css_class, targets: target, attributes: attributes.merge(classes: classes)
75
+ def remove_css_class(targets = nil, classes = "", **attributes)
76
+ classes = attributes[:classes] || classes
77
+ classes = classes.join(" ") if classes.is_a?(Array)
78
+
79
+ custom_action_all :remove_css_class, targets: targets, attributes: attributes.merge(classes: classes)
66
80
  end
67
81
 
68
- def set_attribute(target, attribute, value, **attributes)
69
- custom_action_all :set_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
82
+ def set_attribute(targets = nil, attribute = nil, value = nil, **attributes)
83
+ custom_action_all :set_attribute, targets: targets, attributes: attributes.reverse_merge(attribute: attribute, value: value)
70
84
  end
71
85
 
72
- def set_dataset_attribute(target, attribute, value, **attributes)
73
- custom_action_all :set_dataset_attribute, targets: target, attributes: attributes.merge(attribute: attribute, value: value)
86
+ def set_dataset_attribute(targets = nil, attribute = nil, value = nil, **attributes)
87
+ custom_action_all :set_dataset_attribute, targets: targets, attributes: attributes.reverse_merge(attribute: attribute, value: value)
74
88
  end
75
89
 
76
- def set_property(target, name, value, **attributes)
77
- custom_action_all :set_property, targets: target, attributes: attributes.merge(name: name, value: value)
90
+ def set_property(targets = nil, name = nil, value = nil, **attributes)
91
+ custom_action_all :set_property, targets: targets, attributes: attributes.reverse_merge(name: name, value: value)
78
92
  end
79
93
 
80
- def set_style(target, name, value, **attributes)
81
- custom_action_all :set_style, targets: target, attributes: attributes.merge(name: name, value: value)
94
+ def set_style(targets = nil, name = nil, value = nil, **attributes)
95
+ custom_action_all :set_style, targets: targets, attributes: attributes.reverse_merge(name: name, value: value)
82
96
  end
83
97
 
84
- def set_styles(target, styles, **attributes)
85
- custom_action_all :set_styles, targets: target, attributes: attributes.merge(styles: styles)
98
+ def set_styles(targets = nil, styles = nil, **attributes)
99
+ styles = attributes[:styles] || styles
100
+ styles = styles.map { |k, v| "#{k}: #{v}" }.join("; ") if styles.is_a?(Hash)
101
+
102
+ custom_action_all :set_styles, targets: targets, attributes: attributes.merge(styles: styles)
86
103
  end
87
104
 
88
- def set_value(target, value, **attributes)
89
- custom_action_all :set_value, targets: target, attributes: attributes.merge(value: value)
105
+ def set_value(targets = nil, value = nil, **attributes)
106
+ custom_action_all :set_value, targets: targets, attributes: attributes.reverse_merge(value: value)
90
107
  end
91
108
 
92
109
  # Event Actions
93
110
 
94
- def dispatch_event(target, name, detail: {}, **attributes)
95
- custom_action_all :dispatch_event, targets: target, attributes: attributes.merge(name: name), content: detail.to_json
111
+ def dispatch_event(targets = nil, name = nil, detail: {}, **attributes)
112
+ custom_action_all :dispatch_event, targets: targets, content: detail.to_json, attributes: attributes.reverse_merge(name: name)
96
113
  end
97
114
 
98
115
  # Form Actions
99
116
 
100
- def reset_form(target, **attributes)
101
- custom_action_all :reset_form, targets: target, attributes: attributes
117
+ def reset_form(targets = nil, **attributes)
118
+ custom_action_all :reset_form, targets: targets, attributes: attributes
102
119
  end
103
120
 
104
121
  # Storage Actions
105
122
 
106
- def clear_storage(type, **attributes)
107
- custom_action :clear_storage, attributes: attributes.merge(type: type)
123
+ def clear_storage(type = nil, **attributes)
124
+ custom_action :clear_storage, attributes: attributes.reverse_merge(type: type)
108
125
  end
109
126
 
110
127
  def clear_local_storage(**attributes)
@@ -115,27 +132,27 @@ module TurboPower
115
132
  clear_storage("session", **attributes)
116
133
  end
117
134
 
118
- def remove_storage_item(key, type, **attributes)
119
- custom_action :remove_storage_item, attributes: attributes.merge(key: key, type: type)
135
+ def remove_storage_item(key = nil, type = nil, **attributes)
136
+ custom_action :remove_storage_item, attributes: attributes.reverse_merge(key: key, type: type)
120
137
  end
121
138
 
122
- def remove_local_storage_item(key, **attributes)
139
+ def remove_local_storage_item(key = nil, **attributes)
123
140
  remove_storage_item(key, "local", **attributes)
124
141
  end
125
142
 
126
- def remove_session_storage_item(key, **attributes)
143
+ def remove_session_storage_item(key = nil, **attributes)
127
144
  remove_storage_item(key, "session", **attributes)
128
145
  end
129
146
 
130
- def set_storage_item(key, value, type, **attributes)
131
- custom_action :set_storage_item, attributes: attributes.merge(key: key, type: type, value: value)
147
+ def set_storage_item(key = nil, value = nil, type = nil, **attributes)
148
+ custom_action :set_storage_item, attributes: attributes.reverse_merge(key: key, type: type, value: value)
132
149
  end
133
150
 
134
- def set_local_storage_item(key, value, **attributes)
151
+ def set_local_storage_item(key = nil, value = nil, **attributes)
135
152
  set_storage_item(key, value, "local", **attributes)
136
153
  end
137
154
 
138
- def set_session_storage_item(key, value, **attributes)
155
+ def set_session_storage_item(key = nil, value = nil, **attributes)
139
156
  set_storage_item(key, value, "session", **attributes)
140
157
  end
141
158
 
@@ -145,60 +162,68 @@ module TurboPower
145
162
  custom_action :reload, attributes: attributes
146
163
  end
147
164
 
148
- def scroll_into_view(target, inline = "nearest", **attributes)
149
- custom_action_all :scroll_into_view, targets: target, attributes: attributes.merge(inline: inline)
165
+ def scroll_into_view(targets = nil, **attributes)
166
+ custom_action_all :scroll_into_view, targets: targets, attributes: attributes
150
167
  end
151
168
 
152
- def set_cookie(cookie, **attributes)
153
- custom_action :set_cookie, attributes: attributes.merge(cookie: cookie)
169
+ def set_cookie(cookie = nil, **attributes)
170
+ custom_action :set_cookie, attributes: attributes.reverse_merge(cookie: cookie)
154
171
  end
155
172
 
156
173
  def set_cookie_item(key = nil, value = nil, **attributes)
157
- custom_action :set_cookie_item, attributes: { key: key, value: value }.merge(attributes)
174
+ custom_action :set_cookie_item, attributes: attributes.reverse_merge(key: key, value: value)
158
175
  end
159
176
 
160
- def set_focus(target, **attributes)
161
- custom_action_all :set_focus, targets: target, attributes: attributes
177
+ def set_focus(targets = nil, **attributes)
178
+ custom_action_all :set_focus, targets: targets, attributes: attributes
162
179
  end
163
180
 
164
- def set_title(title, **attributes)
165
- custom_action :set_title, attributes: attributes.merge(title: title)
181
+ def set_title(title = nil, **attributes)
182
+ custom_action :set_title, attributes: attributes.reverse_merge(title: title)
166
183
  end
167
184
 
168
185
  # Browser History Actions
169
186
 
170
- def history_go(delta, **attributes)
171
- custom_action :history_go, attributes: attributes.merge(delta: delta)
187
+ def history_back(**attributes)
188
+ custom_action :history_back, attributes: attributes
189
+ end
190
+
191
+ def history_forward(**attributes)
192
+ custom_action :history_forward, attributes: attributes
193
+ end
194
+
195
+ def history_go(delta = 0, **attributes)
196
+ custom_action :history_go, attributes: attributes.reverse_merge(delta: delta)
172
197
  end
173
198
 
174
- def push_state(url, title = nil, state = nil, **attributes)
175
- custom_action :push_state, attributes: attributes.merge(url: url, title: title, state: state)
199
+ def push_state(url = nil, title = "", state = {}, **attributes)
200
+ custom_action :push_state, attributes: attributes.reverse_merge(url: url, title: title, state: state)
176
201
  end
177
202
 
178
- def replace_state(url, title = nil, state = nil, **attributes)
179
- custom_action :replace_state, attributes: attributes.merge(url: url, title: title, state: state)
203
+ def replace_state(url = nil, title = "", state = {}, **attributes)
204
+ custom_action :replace_state, attributes: attributes.reverse_merge(url: url, title: title, state: state)
180
205
  end
181
206
 
182
207
  # Debug Actions
183
208
 
184
- def console_log(message, level = :log, **attributes)
185
- custom_action :console_log, attributes: attributes.merge(message: message, level: level)
209
+ def console_log(message = nil, level = :log, **attributes)
210
+ custom_action :console_log, attributes: attributes.reverse_merge(message: message, level: level)
186
211
  end
187
212
 
188
- def console_table(data, columns, **attributes)
189
- custom_action :console_table, attributes: attributes.merge(data: data, columns: columns)
213
+ def console_table(data = [], columns = [], **attributes)
214
+ custom_action :console_table, attributes: attributes.reverse_merge(data: data, columns: columns)
190
215
  end
191
216
 
192
217
  # Notification Actions
193
218
 
194
219
  def notification(title = nil, **attributes)
195
- custom_action :notification, attributes: { title: title }.merge(attributes)
220
+ custom_action :notification, attributes: attributes.reverse_merge(title: title)
196
221
  end
197
222
 
198
223
  # Turbo Actions
199
224
 
200
- def redirect_to(url = nil, turbo_action = "advance", **attributes)
201
- custom_action :redirect_to, attributes: { url: url, turbo_action: turbo_action }.merge(attributes)
225
+ def redirect_to(url = nil, turbo_action = "advance", turbo_frame = nil, **attributes)
226
+ custom_action :redirect_to, attributes: attributes.reverse_merge(url: url, turbo_action: turbo_action, turbo_frame: turbo_frame).compact
202
227
  end
203
228
 
204
229
  def turbo_clear_cache(**attributes)
@@ -215,18 +240,18 @@ module TurboPower
215
240
  custom_action :turbo_progress_bar_hide, attributes: attributes
216
241
  end
217
242
 
218
- def turbo_progress_bar_set_value(value, **attributes)
219
- custom_action :turbo_progress_bar_set_value, attributes: attributes.merge(value: value)
243
+ def turbo_progress_bar_set_value(value = nil, **attributes)
244
+ custom_action :turbo_progress_bar_set_value, attributes: attributes.reverse_merge(value: value)
220
245
  end
221
246
 
222
247
  # Turbo Frame Actions
223
248
 
224
- def turbo_frame_reload(frame_id, **attributes)
225
- custom_action :turbo_frame_reload, target: frame_id, attributes: attributes
249
+ def turbo_frame_reload(target = nil, **attributes)
250
+ custom_action :turbo_frame_reload, target: target, attributes: attributes
226
251
  end
227
252
 
228
- def turbo_frame_set_src(frame_id, src, **attributes)
229
- custom_action :turbo_frame_set_src, target: frame_id, attributes: attributes.merge(src: src)
253
+ def turbo_frame_set_src(target = nil, src = nil, **attributes)
254
+ custom_action :turbo_frame_set_src, target: target, attributes: attributes.reverse_merge(src: src)
230
255
  end
231
256
  end
232
257
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboPower
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/turbo_power.gemspec CHANGED
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  "[A-Z]*"
28
28
  ]
29
29
 
30
- spec.add_dependency "turbo-rails", "~> 1.3.0"
30
+ spec.add_dependency "turbo-rails", "~> 1.3"
31
31
  end
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.3.0
4
+ version: 0.4.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: 2023-02-12 00:00:00.000000000 Z
11
+ date: 2023-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turbo-rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: '1.3'
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: 1.3.0
26
+ version: '1.3'
27
27
  description: Power-pack for Turbo Streams
28
28
  email:
29
29
  - marco.roth@hey.com
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.4.1
72
+ rubygems_version: 3.3.26
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Power-pack for Turbo Streams