turbo_boost-commands 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of turbo_boost-commands might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a8b3d24673a0244201ee03bedf31a31fefa5bb862b4e642c52ecf83353bb92b
4
- data.tar.gz: 95d18d2b3c0dc04f9ca2ded0329c557ce9d11e1c19fc2c8d76788b1574bb6aeb
3
+ metadata.gz: 278f5591c9be78cac56fb62a3e3bedecd567b5cf72aebe7dafb69356145b40ab
4
+ data.tar.gz: c71e80af6f7c3a36f2f2b2dede92ebecd114a81011dec4b77b4041743fbb1362
5
5
  SHA512:
6
- metadata.gz: e2c3c404a309e009b40e27a076dffd8c700cb6a427250e05cf89d5443eafb6c6bfb837b05566d57b6e581e72e31f9ffaed03a57a34636275062a16f1b80670db
7
- data.tar.gz: d1a80d66f7cfb7418f5674ac9a36b472574a780827ef477693ad91c433036eef18f967fd3c25ca9274d8cbb1acfdb8b186bd76ee7f35126a3da7c9f2ad0368d0
6
+ metadata.gz: 7ce066b9f04f16039b13550a1f6b764b0fc117c2c8d80470986ffecf7be765be897bef70f58186ecb85e49b40bb42102ead1153e3feb2127c8ce1647b05361bf
7
+ data.tar.gz: 7add3bce722083f351de933375e558f81718a6081896c865db66bcd00b2762058c5689519df6ed5caa378b93fd2869e52cb1642dd6e3cbf81fd1febdfc9f4cf6
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_boost-commands (0.0.1)
4
+ turbo_boost-commands (0.0.3)
5
5
  rails (>= 6.1)
6
6
  turbo-rails (>= 1.1)
7
- turbo_boost-streams (>= 0.0.1)
7
+ turbo_boost-streams (>= 0.0.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -126,12 +126,13 @@ GEM
126
126
  matrix (0.4.2)
127
127
  method_source (1.0.0)
128
128
  mini_mime (1.1.2)
129
- minitest (5.16.3)
129
+ minitest (5.17.0)
130
130
  minitest-reporters (1.5.0)
131
131
  ansi
132
132
  builder
133
133
  minitest (>= 5.0)
134
134
  ruby-progressbar
135
+ model_probe (1.0.7)
135
136
  net-imap (0.3.4)
136
137
  date
137
138
  net-protocol
@@ -161,10 +162,10 @@ GEM
161
162
  pry-rails (0.3.9)
162
163
  pry (>= 0.10.4)
163
164
  public_suffix (5.0.1)
164
- puma (6.0.1)
165
+ puma (6.0.2)
165
166
  nio4r (~> 2.0)
166
167
  racc (1.6.2)
167
- rack (2.2.4)
168
+ rack (2.2.5)
168
169
  rack-test (2.0.2)
169
170
  rack (>= 1.3)
170
171
  rails (7.0.4)
@@ -208,7 +209,7 @@ GEM
208
209
  rubocop-ast (>= 1.23.0, < 2.0)
209
210
  ruby-progressbar (~> 1.7)
210
211
  unicode-display_width (>= 1.4.0, < 3.0)
211
- rubocop-ast (1.24.0)
212
+ rubocop-ast (1.24.1)
212
213
  parser (>= 3.1.1.0)
213
214
  rubocop-performance (1.15.1)
214
215
  rubocop (>= 1.7.0, < 2.0)
@@ -244,10 +245,7 @@ GEM
244
245
  actionpack (>= 6.0.0)
245
246
  activejob (>= 6.0.0)
246
247
  railties (>= 6.0.0)
247
- turbo_boost-streams (0.0.1)
248
- rails (>= 6.1)
249
- turbo-rails (>= 1.1)
250
- turbo_ready (0.1.4)
248
+ turbo_boost-streams (0.0.4)
251
249
  rails (>= 6.1)
252
250
  turbo-rails (>= 1.1)
253
251
  tzinfo (2.0.5)
@@ -284,6 +282,7 @@ DEPENDENCIES
284
282
  importmap-rails
285
283
  magic_frozen_string_literal
286
284
  minitest-reporters
285
+ model_probe
287
286
  net-smtp
288
287
  pry-byebug
289
288
  pry-doc
@@ -297,7 +296,6 @@ DEPENDENCIES
297
296
  standardrb
298
297
  tailwindcss-rails
299
298
  turbo_boost-commands!
300
- turbo_ready
301
299
  web-console
302
300
  webdrivers
303
301
 
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  </h1>
9
9
  <p align="center">
10
10
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/">
11
- <img alt="Lines of Code" src="https://img.shields.io/badge/loc-1277-47d299.svg" />
11
+ <img alt="Lines of Code" src="https://img.shields.io/badge/loc-1401-47d299.svg" />
12
12
  </a>
13
13
  <a href="https://codeclimate.com/github/hopsoft/turbo_boost-commands/maintainability">
14
14
  <img src="https://api.codeclimate.com/v1/badges/fe1162a742fe83a4fdfd/maintainability" />
@@ -37,6 +37,12 @@
37
37
  <a href="https://github.com/hopsoft/turbo_boost-commands/actions/workflows/tests.yml">
38
38
  <img alt="Tests" src="https://github.com/hopsoft/turbo_boost-commands/actions/workflows/tests.yml/badge.svg" />
39
39
  </a>
40
+ <a href="https://github.com/hopsoft/turbo_boost-commands/discussions" target="_blank">
41
+ <img alt="GitHub Discussions" src="https://img.shields.io/github/discussions/hopsoft/turbo_boost-commands?color=168AFE&logo=github">
42
+ </a>
43
+ <a href="https://github.com/sponsors/hopsoft">
44
+ <img alt="Sponsors" src="https://img.shields.io/github/sponsors/hopsoft?color=eb4aaa&logo=GitHub%20Sponsors" />
45
+ </a>
40
46
  <a href="https://twitter.com/hopsoft">
41
47
  <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/hopsoft?logo=twitter&style=social">
42
48
  </a>
@@ -66,22 +72,24 @@
66
72
  - [Putting it All Together](#putting-it-all-together)
67
73
  - [Running Locally](#running-locally)
68
74
  - [Running in Docker](#running-in-docker)
69
- - [License](#license)
70
- - [Todos](#todos)
75
+ - [Community](#community)
76
+ - [Discussions](#discussions)
77
+ - [Twitter](#twitter)
71
78
  - [Releasing](#releasing)
79
+ - [About TurboBoost](#about-turboboost)
80
+ - [License](#license)
72
81
 
73
82
  <!-- Tocer[finish]: Auto-generated, don't remove. -->
74
83
 
75
84
  ## Why TurboBoost Commands?
76
85
 
77
- Commands to help you build robust reactive applications with Rails & Hotwire.
78
- They allow you to declaratively specify server methods that will execute when triggered by users *(think reactive applications)*.
86
+ Commands help you build robust reactive applications with Rails & Hotwire.
87
+ They allow you to declaratively specify server methods that will execute whenever client side events are triggered by users.
79
88
 
80
89
  TurboBoost Commands work with Hotwire's Turbo Frames.
81
- They also work independent of frames.
82
- You choose.
90
+ __They also work independent of frames.__
83
91
 
84
- They let you *sprinkle* ✨ in reactive functionality and skip the ceremony of the typical
92
+ Commands let you *sprinkle* ✨ in reactive functionality and skip the ceremony of the typical
85
93
  [REST semantics](https://en.wikipedia.org/wiki/Representational_state_transfer)
86
94
  imposed by Rails conventions and Turbo Frames i.e. boilerplate *(routes, controllers, actions, etc...)*.
87
95
 
@@ -100,11 +108,11 @@ Namely,
100
108
 
101
109
  *The primary distinction being that __state is wholly managed by the server__.*
102
110
 
103
- Commands are executed via Rails a `before_action` which means that reactivity runs over HTTP.
111
+ Commands are executed via a Rails `before_action` which means that reactivity runs over HTTP.
104
112
  _**Web sockets are NOT used for the reactive critical path!** 🎉_
105
113
  This also means that standard Rails mechanics drive their behavior.
106
114
 
107
- Also, commands can be tested in isolation or via Rails controller, integration, and system tests.
115
+ Commands can be tested in isolation as well as with standard Rails controller, integration, and system tests.
108
116
 
109
117
  ## Sponsors
110
118
 
@@ -151,7 +159,7 @@ Also, commands can be tested in isolation or via Rails controller, integration,
151
159
  +import '@turbo-boost/commands'
152
160
  ```
153
161
 
154
- 2. Add TurboBoost Commands behavior to the Rails app
162
+ 2. Add TurboBoost to your Rails app
155
163
 
156
164
  ```diff
157
165
  # app/views/layouts/application.html.erb
@@ -173,7 +181,7 @@ This example illustrates how to use TurboBoost Commands to manage upvotes on a P
173
181
  ```erb
174
182
  <!-- app/views/posts/show.html.erb -->
175
183
  <%= turbo_frame_tag dom_id(@post) do %>
176
- <a href="#" data-command="PostCommand#upvote">Upvote</a>
184
+ <a href="#" data-turbo-command="PostCommand#upvote">Upvote</a>
177
185
  Upvote Count: <%= @post.votes %>
178
186
  <% end %>
179
187
  ```
@@ -205,14 +213,14 @@ It's possible to override these defaults like so.
205
213
 
206
214
  ```js
207
215
  // restrict `click` monitoring to <a> and <button> elements
208
- TurboBoost.Commands.registerEventDelegate('click', ['a[data-command]', 'button[data-command]'])
216
+ TurboBoost.Commands.registerEventDelegate('click', ['a[data-turbo-command]', 'button[data-command]'])
209
217
  ```
210
218
 
211
219
  You can also register custom events and elements.
212
220
  Here's an example that sets up monitoring for the `sl-change` event on the `sl-switch` element from the [Shoelace web component library](https://shoelace.style/).
213
221
 
214
222
  ```js
215
- TurboBoost.Commands.registerEventDelegate('sl-change', ['sl-switch[data-command]'])
223
+ TurboBoost.Commands.registerEventDelegate('sl-change', ['sl-switch[data-turbo-command]'])
216
224
  ```
217
225
 
218
226
  ### Lifecycle Events
@@ -232,7 +240,7 @@ but you can also explicitly target other frames just like you normally would wit
232
240
 
233
241
  ```erb
234
242
  <input type="checkbox"
235
- data-command="ExampleCommand#work"
243
+ data-turbo-command="ExampleCommand#work"
236
244
  data-turbo-frame="some-frame-id">
237
245
  ```
238
246
 
@@ -240,44 +248,44 @@ but you can also explicitly target other frames just like you normally would wit
240
248
 
241
249
  ```erb
242
250
  <turbo-frame id="example-frame">
243
- <input type="checkbox" data-command="ExampleCommand#work">
251
+ <input type="checkbox" data-turbo-command="ExampleCommand#work">
244
252
  </turbo-frame>
245
253
  ```
246
254
 
247
255
  ### Working with Forms
248
256
 
249
257
  TurboBoost Commands work great with Rails forms.
250
- Just specify the `data-command` attribute on the form.
258
+ Just specify the `data-turbo-command` attribute on the form.
251
259
 
252
260
  ```erb
253
261
  # app/views/posts/post.html.erb
254
262
  <%= turbo_frame_tag dom_id(@post) do %>
255
- <%= form_with model: @post, data: { command: "ExampleCommand#work" } do |form| %>
263
+ <%= form_with model: @post, data: { turbo_command: "ExampleCommand#work" } do |form| %>
256
264
  ...
257
265
  <% end %>
258
266
  <% end %>
259
267
 
260
268
  <%= turbo_frame_tag dom_id(@post) do %>
261
- <%= form_for @post, remote: true, data: { command: "ExampleCommand#work" } do |form| %>
269
+ <%= form_for @post, remote: true, data: { turbo_command: "ExampleCommand#work" } do |form| %>
262
270
  ...
263
271
  <% end %>
264
272
  <% end %>
265
273
 
266
274
  <%= form_with model: @post,
267
- data: { turbo_frame: dom_id(@post), command: "ExampleCommand#work" } do |form| %>
275
+ data: { turbo_frame: dom_id(@post), turbo_command: "ExampleCommand#work" } do |form| %>
268
276
  ...
269
277
  <% end %>
270
278
  ```
271
279
 
272
280
  ### Server Side Commands
273
281
 
274
- The client side DOM attribute `data-command` indicates what Ruby class and method to invoke.
282
+ The client side DOM attribute `data-turbo-command` indicates what Ruby class and method to invoke.
275
283
  *The attribute value is specified with RDoc notation. i.e. `ClassName#method_name`*
276
284
 
277
285
  Here's an example.
278
286
 
279
287
  ```erb
280
- <a data-command="DemoCommand#example">
288
+ <a data-turbo-command="DemoCommand#example">
281
289
  ```
282
290
 
283
291
  Server side commands can live anywhere in your app; however, we recommend you keep them in the `app/commands` directory.
@@ -295,18 +303,19 @@ Commands are simple Ruby classes that inherit from `TurboBoost::Commands::Comman
295
303
  They expose the following instance methods and properties.
296
304
 
297
305
  ```ruby
306
+ # * controller .................. The Rails controller processing the HTTP request
307
+ # * css_id_selector ............. Returns a CSS selector for an element `id` i.e. prefixes with `#`
298
308
  # * dom_id ...................... The Rails dom_id helper
299
309
  # * dom_id_selector ............. Returns a CSS selector for a dom_id
300
- # * controller .................. The Rails controller processing the HTTP request
301
310
  # * element ..................... A struct that represents the DOM element that triggered the command
302
311
  # * morph ....................... Appends a Turbo Stream to morph a DOM element
303
312
  # * params ...................... Commands specific params (frame_id, element, etc.)
304
313
  # * render ...................... Renders Rails templates, partials, etc. (doesn't halt controller request handling)
305
314
  # * render_response ............. Renders a full controller response
306
315
  # * renderer .................... An ActionController::Renderer
316
+ # * state ....................... An object that stores ephemeral `state`
307
317
  # * turbo_stream ................ A Turbo Stream TagBuilder
308
318
  # * turbo_streams ............... A list of Turbo Streams to append to the response (also aliased as streams)
309
- # * state ....................... An object that stores ephemeral `state`
310
319
  ```
311
320
 
312
321
  ```ruby
@@ -356,7 +365,7 @@ Here's an example that shows how to do this.
356
365
  ```erb
357
366
  <!-- app/views/posts/index.html.erb -->
358
367
  <%= turbo_frame_tag dom_id(@posts) do %>
359
- <%= check_box_tag :all, :all, @all, data: { command: "PostsCommand#toggle_all" } %>
368
+ <%= check_box_tag :all, :all, @all, data: { turbo_command: "PostsCommand#toggle_all" } %>
360
369
  View All
361
370
 
362
371
  <% @posts.each do |post| %>
@@ -400,7 +409,7 @@ Here's how to do it.
400
409
  ```erb
401
410
  <!-- app/views/users/show.html.erb -->
402
411
  <%= turbo_frame_tag "user-alt" do %>
403
- <%= form_with model: @user, data: { command: "UserCommand#example" } do |form| %>
412
+ <%= form_with model: @user, data: { turbo_command: "UserCommand#example" } do |form| %>
404
413
  ...
405
414
  <% end %>
406
415
  <% end %>
@@ -473,9 +482,19 @@ docker compose up -d
473
482
  You can review the implementation in [`test/dummy/app`](https://github.com/hopsoft/turbo_boost-commands/tree/main/test/dummy).
474
483
  *Feel free to add some demos and submit a pull request while you're in there.*
475
484
 
476
- ## License
485
+ ## Community
477
486
 
478
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
487
+ ### Discussions
488
+
489
+ Feel free to add to the conversation here on [GitHub Discussions](https://github.com/hopsoft/turbo_boost-commands/discussions).
490
+
491
+ ### Twitter
492
+
493
+ Connect with the core team on Twitter.
494
+
495
+ <a href="https://twitter.com/hopsoft" target="_blank">
496
+ <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/hopsoft?logo=twitter&style=social">
497
+ </a>
479
498
 
480
499
  ## Releasing
481
500
 
@@ -485,7 +504,20 @@ The gem is available as open source under the terms of the [MIT License](https:/
485
504
  1. Run `rake build` and `yarn build`
486
505
  1. Commit and push changes to GitHub
487
506
  1. Run `rake release`
488
- 1. Run `yarn publish --no-git-tag-version`
507
+ 1. Run `yarn publish --no-git-tag-version --access public`
489
508
  1. Yarn will prompt you for the new version. Pre-release versions use `-preN`
490
509
  1. Commit and push any changes to GitHub
491
510
  1. Create a new release on GitHub ([here](https://github.com/hopsoft/turbo_boost-commands/releases)) and generate the changelog for the stable release for it
511
+
512
+ ## About TurboBoost
513
+
514
+ TurboBoost is a suite of projects that enhance Rails and Hotwire to make building server rendered reactive applications simpler and more powerful.
515
+ Be sure to check out all of the various the libraries.
516
+
517
+ - [Streams](https://github.com/hopsoft/turbo_boost-streams)
518
+ - [Commands](https://github.com/hopsoft/turbo_boost-commands)
519
+ - Coming soon...
520
+
521
+ ## License
522
+
523
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).