turbo_power 0.1.0 → 0.1.1

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: 2100e6501a16f8b18459a8cb2072e8d9c8f0fda27363a9185275886b4f9e102c
4
- data.tar.gz: 3bd04cb90cc78d23a481240217403f0aea950fca60e83fb800093a68938468bc
3
+ metadata.gz: 4ec77740a41b50382edd8441dcb76a453fc60d57d5429e107398de38578e147b
4
+ data.tar.gz: f4419c8721ffd08fdcc02b1f1449d2671af16cc34c7e2f73185777276236bc27
5
5
  SHA512:
6
- metadata.gz: b05a8b3f4423f0cf19acc08983bdc4e9cd99586b462a971f5e889b9adbe452a3d79f4b2feba087a569f3a8533156bb62484eadddd7b0798ed2fcee6cba2b8b07
7
- data.tar.gz: 4998190fa7ef683921c6460a291ff16800bb452578f98bade23844b2500ae26ae8418d3f97da095a99523ca0d1ce722939b8247812a30a3592856f026778cb32
6
+ metadata.gz: 8f1a90e7eae214a0f6d3d1bcb371f4c8a9f06e302f5a8135a68027be105a6c93f549ba860de1bdc9be7959309c277458295661d9dbd14e2158583017ee931101
7
+ data.tar.gz: 0a8753c7d57f4865ca27641d8767723dc1d97bda6c5e6fb37aee54f6f1d2e58e64d3e79d2a9472abbce1664e7abb22793d0073ad4d1e999bcc125838424d2f3c
data/Gemfile CHANGED
@@ -11,3 +11,4 @@ gem "minitest", "~> 5.0"
11
11
  gem "rubocop", "~> 1.21"
12
12
 
13
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
@@ -8,15 +8,50 @@ GIT
8
8
  activejob (>= 6.0.0)
9
9
  railties (>= 6.0.0)
10
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
+
11
20
  PATH
12
21
  remote: .
13
22
  specs:
14
- turbo_power (0.1.0)
23
+ turbo_power (0.1.1)
15
24
  turbo-rails
25
+ turbo_ready
16
26
 
17
27
  GEM
18
28
  remote: https://rubygems.org/
19
29
  specs:
30
+ actioncable (7.0.3.1)
31
+ actionpack (= 7.0.3.1)
32
+ activesupport (= 7.0.3.1)
33
+ nio4r (~> 2.0)
34
+ 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)
41
+ mail (>= 2.7.1)
42
+ net-imap
43
+ net-pop
44
+ 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)
50
+ mail (~> 2.5, >= 2.5.4)
51
+ net-imap
52
+ net-pop
53
+ net-smtp
54
+ rails-dom-testing (~> 2.0)
20
55
  actionpack (7.0.3.1)
21
56
  actionview (= 7.0.3.1)
22
57
  activesupport (= 7.0.3.1)
@@ -24,6 +59,13 @@ GEM
24
59
  rack-test (>= 0.6.3)
25
60
  rails-dom-testing (~> 2.0)
26
61
  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)
67
+ globalid (>= 0.6.0)
68
+ nokogiri (>= 1.8.5)
27
69
  actionview (7.0.3.1)
28
70
  activesupport (= 7.0.3.1)
29
71
  builder (~> 3.1)
@@ -33,6 +75,18 @@ GEM
33
75
  activejob (7.0.3.1)
34
76
  activesupport (= 7.0.3.1)
35
77
  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)
88
+ marcel (~> 1.0)
89
+ mini_mime (>= 1.1.0)
36
90
  activesupport (7.0.3.1)
37
91
  concurrent-ruby (~> 1.0, >= 1.0.2)
38
92
  i18n (>= 1.6, < 2)
@@ -42,6 +96,7 @@ GEM
42
96
  builder (3.2.4)
43
97
  concurrent-ruby (1.1.10)
44
98
  crass (1.0.6)
99
+ digest (3.1.0)
45
100
  erubi (1.11.0)
46
101
  globalid (1.0.0)
47
102
  activesupport (>= 5.0)
@@ -51,8 +106,27 @@ GEM
51
106
  loofah (2.18.0)
52
107
  crass (~> 1.0.2)
53
108
  nokogiri (>= 1.5.9)
109
+ mail (2.7.1)
110
+ mini_mime (>= 0.1.1)
111
+ marcel (1.0.2)
54
112
  method_source (1.0.0)
113
+ mini_mime (1.1.2)
55
114
  minitest (5.16.3)
115
+ net-imap (0.2.3)
116
+ digest
117
+ net-protocol
118
+ strscan
119
+ net-pop (0.1.1)
120
+ digest
121
+ net-protocol
122
+ timeout
123
+ net-protocol (0.1.3)
124
+ timeout
125
+ net-smtp (0.3.1)
126
+ digest
127
+ net-protocol
128
+ timeout
129
+ nio4r (2.5.8)
56
130
  nokogiri (1.13.8-x86_64-darwin)
57
131
  racc (~> 1.4)
58
132
  parallel (1.22.1)
@@ -62,6 +136,20 @@ GEM
62
136
  rack (2.2.4)
63
137
  rack-test (2.0.2)
64
138
  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)
151
+ bundler (>= 1.15.0)
152
+ railties (= 7.0.3.1)
65
153
  rails-dom-testing (2.0.3)
66
154
  activesupport (>= 4.2.0)
67
155
  nokogiri (>= 1.6)
@@ -91,10 +179,15 @@ GEM
91
179
  rubocop-ast (1.21.0)
92
180
  parser (>= 3.1.1.0)
93
181
  ruby-progressbar (1.11.0)
182
+ strscan (3.0.4)
94
183
  thor (1.2.1)
184
+ timeout (0.3.0)
95
185
  tzinfo (2.0.5)
96
186
  concurrent-ruby (~> 1.0)
97
187
  unicode-display_width (2.2.0)
188
+ websocket-driver (0.7.5)
189
+ websocket-extensions (>= 0.1.0)
190
+ websocket-extensions (0.1.5)
98
191
  zeitwerk (2.6.0)
99
192
 
100
193
  PLATFORMS
@@ -106,6 +199,7 @@ DEPENDENCIES
106
199
  rubocop (~> 1.21)
107
200
  turbo-rails!
108
201
  turbo_power!
202
+ turbo_ready!
109
203
 
110
204
  BUNDLED WITH
111
205
  2.3.19
data/README.md CHANGED
@@ -1,20 +1,109 @@
1
- # TurboPower
1
+ # TurboPower Rails
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/turbo_power`. To experiment with that code, run `bin/console` for an interactive prompt.
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
4
 
5
5
  ## Installation
6
6
 
7
7
  Install the gem and add to the application's Gemfile by executing:
8
8
 
9
- $ bundle add turbo_power
9
+ ```shell
10
+ bundle add turbo_power
11
+ ```
10
12
 
11
- If bundler is not being used to manage dependencies, install the gem by executing:
13
+ Install the JavaScript package:
12
14
 
13
- $ gem install turbo_power
15
+ ```shell
16
+ yarn add turbo_power
17
+ ```
18
+
19
+ Initialize TurboPower in `application.js`:
20
+
21
+ ```diff
22
+ // application.js
23
+ import * as Turbo from '@hotwired/turbo'
24
+
25
+ +import TurboPower from 'turbo_power'
26
+ +TurboPower.initialize(Turbo.StreamActions)
27
+ ```
14
28
 
15
29
  ## Usage
16
30
 
17
- TODO: Write usage instructions here
31
+ ### Actions from `turbo_ready`
32
+
33
+ * [`turbo_stream.invoke(method, *args, selector: nil, camelize: true, id: nil)`](https://github.com/hopsoft/turbo_ready)
34
+
35
+ ### Actions from `turbo-morph`
36
+
37
+ * [`turbo_stream.morph(target, html = nil, **attributes, &block)`](https://github.com/marcoroth/turbo-morph)
38
+
39
+ ### DOM Actions
40
+
41
+ * `turbo_stream.graft(target, parent, **attributes)`
42
+ * `turbo_stream.inner_html(target, html = nil, **attributes, &block)`
43
+ * `turbo_stream.insert_adjacent_html(target, html = nil, position: 'beforeend', **attributes, &block)`
44
+ * `turbo_stream.insert_adjacent_text(target, text, position: 'beforebegin', **attributes)`
45
+ * `turbo_stream.morph(target, html = nil, **attribtues, &block)`
46
+ * `turbo_stream.outer_html(target, html = nil, **attributes, &block)`
47
+ * `turbo_stream.text_content(target, text, **attributes)`
48
+ * `turbo_stream.set_meta(name, content, **attributes)`
49
+
50
+
51
+ ### Attribute Actions
52
+
53
+ * `turbo_stream.add_css_class(target, classes, **attributes)`
54
+ * `turbo_stream.remove_attribute(target, attribute, **attributes)`
55
+ * `turbo_stream.remove_css_class(target, classes, **attributes)`
56
+ * `turbo_stream.set_attribute(target, attribute, value, **attributes)`
57
+ * `turbo_stream.set_dataset_attribute(target, attribute, value, **attributes)`
58
+ * `turbo_stream.set_property(target, property, value, **attributes)`
59
+ * `turbo_stream.set_style(target, name, value, **attributes)`
60
+ * `turbo_stream.set_styles(target, styles, **attributes)`
61
+ * `turbo_stream.set_value(target, value, **attributes)`
62
+
63
+
64
+ ### Event Actions
65
+
66
+ * `turbo_stream.dispatch_event(target, name, detail: {}, **attributes)`
67
+
68
+
69
+ ### Storage Actions
70
+
71
+ * `turbo_stream.clear_storage(type, **attributes)`
72
+ * `turbo_stream.clear_local_storage(**attributes)`
73
+ * `turbo_stream.clear_session_storage(**attributes)`
74
+ * `turbo_stream.remove_storage_item(key, type, **attributes)`
75
+ * `turbo_stream.remove_local_storage_item(key, **attributes)`
76
+ * `turbo_stream.remove_session_storage_item(key, **attributes)`
77
+ * `turbo_stream.set_storage_item(key, value, type, **attributes)`
78
+ * `turbo_stream.set_local_storage_item(key, value, **attributes)`
79
+ * `turbo_stream.set_session_storage_item(key, value, **attributes)`
80
+
81
+
82
+ ### Browser Actions
83
+
84
+ * `turbo_stream.redirect_to(url, action_name = nil, **attributes)`
85
+ * `turbo_stream.reload(**attributes)`
86
+ * `turbo_stream.scroll_into_view(target, inline = "nearest", **attributes)`
87
+ * `turbo_stream.set_cookie(cookie, **attributes)`
88
+ * `turbo_stream.set_cookie_item(key, value, **attributes)`
89
+ * `turbo_stream.set_focus(target, **attributes)`
90
+
91
+
92
+ ### Browser History Actions
93
+
94
+ * `turbo_stream.history_go(delta, **attributes)`
95
+ * `turbo_stream.push_state(url, title = nil, state = nil, **attributes)`
96
+ * `turbo_stream.replace_state(url, title = nil, state = nil, **attributes)`
97
+
98
+
99
+ ### Debug Actions
100
+
101
+ * `turbo_stream.console_log(message, level = 'log', **attributes)`
102
+ * `turbo_stream.console_table(data, columns, **attributes)`
103
+
104
+ ### Notification Actions
105
+
106
+ * `turbo_stream.notification(title, options, **attributes)`
18
107
 
19
108
  ## Development
20
109
 
@@ -24,7 +113,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
24
113
 
25
114
  ## Contributing
26
115
 
27
- Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/turbo_power. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/marcoroth/turbo_power/blob/master/CODE_OF_CONDUCT.md).
116
+ Bug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/turbo_power-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/marcoroth/turbo_power-rails/blob/master/CODE_OF_CONDUCT.md).
28
117
 
29
118
  ## License
30
119
 
@@ -32,4 +121,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
32
121
 
33
122
  ## Code of Conduct
34
123
 
35
- Everyone interacting in the TurboPower project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/marcoroth/turbo_power/blob/master/CODE_OF_CONDUCT.md).
124
+ Everyone interacting in the TurboPower project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/marcoroth/turbo_power-rails/blob/master/CODE_OF_CONDUCT.md).
@@ -3,7 +3,7 @@ require "turbo-rails"
3
3
  module TurboPower
4
4
  module StreamHelper
5
5
 
6
- # DOM Mutations
6
+ # DOM Actions
7
7
 
8
8
  def graft(target, parent, **attributes)
9
9
  action_all :graft, targets: target, attributes: attributes.merge(parent: parent)
@@ -33,9 +33,12 @@ module TurboPower
33
33
  action_all :text_content, targets: target, attributes: attributes.merge(text: text)
34
34
  end
35
35
 
36
+ def set_meta(name, content, **attributes)
37
+ action :set_meta, attributes: attributes.merge(name: name, content: content)
38
+ end
36
39
 
37
- # Element Attribute/Property Mutations
38
40
 
41
+ # Attribute Actions
39
42
 
40
43
  def add_css_class(target, classes, **attributes)
41
44
  action_all :add_css_class, targets: target, attributes: attributes.merge(classes: classes)
@@ -74,18 +77,14 @@ module TurboPower
74
77
  end
75
78
 
76
79
 
77
- # DOM Events
80
+ # Event Actions
78
81
 
79
82
  def dispatch_event(target, name, detail: {}, **attributes)
80
83
  action_all :dispatch_event, targets: target, attributes: attributes.merge(detail: detail)
81
84
  end
82
85
 
83
- def set_meta(name, content)
84
- action :set_meta, attributes: attributes.merge(name: name, content: content)
85
- end
86
86
 
87
-
88
- # LocalStorage / SessionStorage
87
+ # Storage Actions
89
88
 
90
89
  def clear_storage(type, **attributes)
91
90
  action :clear_storage, attributes: attributes.merge(type: type)
@@ -99,7 +98,6 @@ module TurboPower
99
98
  clear_storage("session", **attributes)
100
99
  end
101
100
 
102
-
103
101
  def remove_storage_item(key, type, **attributes)
104
102
  action :remove_storage_item, attributes: attributes.merge(key: key, type: type)
105
103
  end
@@ -126,18 +124,18 @@ module TurboPower
126
124
  end
127
125
 
128
126
 
129
- # Browser Manipulations
127
+ # Browser Actions
130
128
 
131
129
  def redirect_to(url, action_name = nil, **attributes)
132
130
  action :redirect_to, attributes: attributes.merge(url: url, action: action_name)
133
131
  end
134
132
 
135
133
  def reload(**attributes)
136
- action :relaod, attributes: attributes
134
+ action :reload, attributes: attributes
137
135
  end
138
136
 
139
- def scroll_into_view(target, inline = "nearest")
140
- action_all :relaod, targets: target, attributes: attributes.merge(inline: inline)
137
+ def scroll_into_view(target, inline = "nearest", **attributes)
138
+ action_all :scroll_into_view, targets: target, attributes: attributes.merge(inline: inline)
141
139
  end
142
140
 
143
141
  def set_cookie(cookie, **attributes)
@@ -145,7 +143,7 @@ module TurboPower
145
143
  end
146
144
 
147
145
  def set_cookie_item(key, value, **attributes)
148
- action :set_cookie, attributes: attributes.merge(key: key, value: value)
146
+ action :set_cookie_item, attributes: attributes.merge(key: key, value: value)
149
147
  end
150
148
 
151
149
  def set_focus(target, **attributes)
@@ -153,7 +151,7 @@ module TurboPower
153
151
  end
154
152
 
155
153
 
156
- # Browser History
154
+ # Browser History Actions
157
155
 
158
156
  def history_go(delta, **attributes)
159
157
  action :history_go, attributes: attributes.merge(delta: delta)
@@ -168,16 +166,18 @@ module TurboPower
168
166
  end
169
167
 
170
168
 
171
- # Notifications
169
+ # Debug Actions
172
170
 
173
- def console_log(message, level: :log)
174
- action :console_log, attributes: { message: message, level: level }
171
+ def console_log(message, level = :log, **attributes)
172
+ action :console_log, attributes: attributes.merge(message: message, level: level)
175
173
  end
176
174
 
177
175
  def console_table(data, columns, **attributes)
178
176
  action :console_table, attributes: attributes.merge(data: data, columns: columns)
179
177
  end
180
178
 
179
+ # Notification Actions
180
+
181
181
  def notification(title, options, **attributes)
182
182
  action :notification, attributes: attributes.merge(title: title, options: options)
183
183
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboPower
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/turbo_power.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "turbo_ready"
3
4
  require_relative "turbo_power/version"
4
5
  require_relative "turbo_power/stream_helper"
5
6
 
7
+ TurboReady.patch!
8
+
6
9
  module TurboPower
7
10
  end
data/turbo_power.gemspec CHANGED
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.test_files = Dir["test/**/*.rb"]
30
30
 
31
31
  spec.add_dependency "turbo-rails"
32
+ spec.add_dependency "turbo_ready"
32
33
  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.1.0
4
+ version: 0.1.1
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-26 00:00:00.000000000 Z
11
+ date: 2022-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turbo-rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: turbo_ready
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Powerpack for Turbo
28
42
  email:
29
43
  - marco.roth@hey.com