turbo-rails 2.0.6 → 2.0.7

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: 7bc53746ef39d3412872a00dade91b735622b4edca9b42d321c4f2114da6dd4b
4
- data.tar.gz: 53974cb2408b7a98cf7cf6a33b9fc8c9ebf948c1e196597f33f499437ea47a47
3
+ metadata.gz: 4553ee49b6504b50ebd79364400cd57bcba2a4fd544aff65f88a4c5a12ffdaac
4
+ data.tar.gz: 7500ba88dc381e1601b0778c31e68be1a16ce72dcc535bbd8b54ba4eebac5d0e
5
5
  SHA512:
6
- metadata.gz: 16fdd0089b68c5f6ed5777324af45fb54a2101439319b70637d60eebaa29965e8f9b3ae9dc2b825505d6b9155a2e74b319c47231f80300aac622b32ed2d0c908
7
- data.tar.gz: 8d8753af6214007c64250931c9bbba39b341a91decb60a71b6d5a1bf62a08803076127e81a9db3d87ca209a2753558f688cc2319df78a7def4c9a7ca878c0e55
6
+ metadata.gz: 40376048e8a552fb9ac3570e6fce78f7d0741cdab4b8d3851305fb5541f50dd381a4d9616e7c4fb147a1d58d7b546ab6d07061ac79f3851b8163605084cabc62
7
+ data.tar.gz: 85414d553bc478bf46ba0294381b09031e58949edd93d47e8f02b721a0fcb556388a5b3b20741a3011f3547fb0281d9bdbcc7e518a97df27953474ce3d012add
data/README.md CHANGED
@@ -109,7 +109,6 @@ This gem is automatically configured for applications made with Rails 7+ (unless
109
109
  1. Add the `turbo-rails` gem to your Gemfile: `gem 'turbo-rails'`
110
110
  2. Run `./bin/bundle install`
111
111
  3. Run `./bin/rails turbo:install`
112
- 4. Run `./bin/rails turbo:install:redis` to change the development Action Cable adapter from Async (the default one) to Redis. The Async adapter does not support Turbo Stream broadcasting.
113
112
 
114
113
  Running `turbo:install` will install through NPM or Bun if a JavaScript runtime is used in the application. Otherwise the asset pipeline version is used. To use the asset pipeline version, you must have `importmap-rails` installed first and listed higher in the Gemfile.
115
114
 
@@ -125,6 +124,8 @@ import "@hotwired/turbo-rails"
125
124
 
126
125
  You can watch [the video introduction to Hotwire](https://hotwired.dev/#screencast), which focuses extensively on demonstrating Turbo in a Rails demo. Then you should familiarize yourself with [Turbo handbook](https://turbo.hotwired.dev/handbook/introduction) to understand Drive, Frames, and Streams in-depth. Finally, dive into the code documentation by starting with [`Turbo::FramesHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb), [`Turbo::StreamsHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/streams_helper.rb), [`Turbo::Streams::TagBuilder`](https://github.com/hotwired/turbo-rails/blob/main/app/models/turbo/streams/tag_builder.rb), and [`Turbo::Broadcastable`](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
127
126
 
127
+ Note that in development, the default Action Cable adapter is the single-process `async` adapter. This means that turbo updates are only broadcast within that same process. So you can't start `bin/rails console` and trigger Turbo broadcasts and expect them to show up in a browser connected to a server running in a separate `bin/dev` or `bin/rails server` process. Instead, you should use the web-console when needing to manaually trigger Turbo broadcasts inside the same process. Add "console" to any action or "<%= console %>" in any view to make the web console appear.
128
+
128
129
  ### RubyDoc Documentation
129
130
 
130
131
  For the API documentation covering this gem's classes and packages, [visit the RubyDoc page](https://rubydoc.info/github/hotwired/turbo-rails/main).
@@ -194,6 +195,14 @@ yarn build
194
195
 
195
196
  Now you can reference your version of turbo-rails in your Rails projects packaged with your local version of Turbo.
196
197
 
198
+ ## Contributing
199
+
200
+ Having a way to reproduce your issue will help people confirm, investigate, and ultimately fix your issue. You can do this by providing an executable test case. To make this process easier, we have prepared an [executable bug report Rails application](./bug_report_template.rb) for you to use as a starting point.
201
+
202
+ This template includes the boilerplate code to set up a System Test case. Copy the content of the template into a `.rb` file and make the necessary changes to demonstrate the issue. You can execute it by running `ruby the_file.rb` in your terminal. If all goes well, you should see your test case failing.
203
+
204
+ You can then share your executable test case as a gist or paste the content into the issue description.
205
+
197
206
  ## License
198
207
 
199
208
  Turbo is released under the [MIT License](https://opensource.org/licenses/MIT).
@@ -48,7 +48,13 @@ module Turbo::StreamsHelper
48
48
  # It is also possible to pass additional parameters to the channel by passing them through `data` attributes:
49
49
  #
50
50
  # <%= turbo_stream_from "room", channel: RoomChannel, data: {room_name: "room #1"} %>
51
+ #
52
+ # Raises an +ArgumentError+ if all streamables are blank
53
+ #
54
+ # <%= turbo_stream_from("") %> # => ArgumentError: streamables can't be blank
55
+ # <%= turbo_stream_from("", nil) %> # => ArgumentError: streamables can't be blank
51
56
  def turbo_stream_from(*streamables, **attributes)
57
+ raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
52
58
  attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
53
59
  attributes[:"signed-stream-name"] = Turbo::StreamsChannel.signed_stream_name(streamables)
54
60
 
@@ -228,32 +228,6 @@ class Turbo::Streams::TagBuilder
228
228
  action_all :prepend, targets, content, **rendering, &block
229
229
  end
230
230
 
231
- # Morph the <tt>target</tt> in the dom with either the <tt>content</tt> passed in or a rendering result determined
232
- # by the <tt>rendering</tt> keyword arguments, the content in the block, or the rendering of the target as a record. Examples:
233
- #
234
- # <%= turbo_stream.morph "clearance_5", "<div id='clearance_5'>Morph the dom target identified by clearance_5</div>" %>
235
- # <%= turbo_stream.morph clearance %>
236
- # <%= turbo_stream.morph clearance, partial: "clearances/clearance", locals: { title: "Hello" } %>
237
- # <%= turbo_stream.morph "clearance_5" do %>
238
- # <div id='clearance_5'>Morph the dom target identified by clearance_5</div>
239
- # <% end %>
240
- def morph(target, content = nil, **rendering, &block)
241
- action :morph, target, content, **rendering, &block
242
- end
243
-
244
- # Morph the <tt>targets</tt> in the dom with either the <tt>content</tt> passed in or a rendering result determined
245
- # by the <tt>rendering</tt> keyword arguments, the content in the block, or the rendering of the targets as a record. Examples:
246
- #
247
- # <%= turbo_stream.morph_all ".clearance_item", "<div class='clearance_item'>Morph the dom target identified by the class clearance_item</div>" %>
248
- # <%= turbo_stream.morph_all clearance %>
249
- # <%= turbo_stream.morph_all clearance, partial: "clearances/clearance", locals: { title: "Hello" } %>
250
- # <%= turbo_stream.morph_all ".clearance_item" do %>
251
- # <div class='clearance_item'>Morph the dom target identified by the class clearance_item</div>
252
- # <% end %>
253
- def morph_all(targets, content = nil, **rendering, &block)
254
- action_all :morph, targets, content, **rendering, &block
255
- end
256
-
257
231
  # Send an action of the type <tt>name</tt> to <tt>target</tt>. Options described in the concrete methods.
258
232
  def action(name, target, content = nil, allow_inferred_rendering: true, **rendering, &block)
259
233
  template = render_template(target, content, allow_inferred_rendering: allow_inferred_rendering, **rendering, &block)
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- get "recede_historical_location" => "turbo/native/navigation#recede", as: :turbo_recede_historical_location
3
- get "resume_historical_location" => "turbo/native/navigation#resume", as: :turbo_resume_historical_location
4
- get "refresh_historical_location" => "turbo/native/navigation#refresh", as: :turbo_refresh_historical_location
2
+ get "recede_historical_location", to: "turbo/native/navigation#recede", as: :turbo_recede_historical_location
3
+ get "resume_historical_location", to: "turbo/native/navigation#resume", as: :turbo_resume_historical_location
4
+ get "refresh_historical_location", to: "turbo/native/navigation#refresh", as: :turbo_refresh_historical_location
5
5
  end if Turbo.draw_routes
@@ -5,20 +5,6 @@ module Turbo
5
5
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}"
6
6
  end
7
7
 
8
- def redis_installed?
9
- Gem.win_platform? ?
10
- system('where redis-server > NUL 2>&1') :
11
- system('which redis-server > /dev/null')
12
- end
13
-
14
- def switch_on_redis_if_available
15
- if redis_installed?
16
- Rake::Task["turbo:install:redis"].invoke
17
- else
18
- puts "Run turbo:install:redis to switch on Redis and use it in development for turbo streams"
19
- end
20
- end
21
-
22
8
  def using_bun?
23
9
  Rails.root.join("bun.config.js").exist?
24
10
  end
@@ -43,24 +29,16 @@ namespace :turbo do
43
29
  desc "Install Turbo into the app with asset pipeline"
44
30
  task :importmap do
45
31
  Turbo::Tasks.run_turbo_install_template "turbo_with_importmap"
46
- Turbo::Tasks.switch_on_redis_if_available
47
32
  end
48
33
 
49
34
  desc "Install Turbo into the app with webpacker"
50
35
  task :node do
51
36
  Turbo::Tasks.run_turbo_install_template "turbo_with_node"
52
- Turbo::Tasks.switch_on_redis_if_available
53
37
  end
54
38
 
55
39
  desc "Install Turbo into the app with bun"
56
40
  task :bun do
57
41
  Turbo::Tasks.run_turbo_install_template "turbo_with_bun"
58
- Turbo::Tasks.switch_on_redis_if_available
59
- end
60
-
61
- desc "Switch on Redis and use it in development"
62
- task :redis do
63
- Turbo::Tasks.run_turbo_install_template "turbo_needs_redis"
64
42
  end
65
43
  end
66
44
  end
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-19 00:00:00.000000000 Z
13
+ date: 2024-09-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activejob
@@ -93,7 +93,6 @@ files:
93
93
  - app/models/turbo/thread_debouncer.rb
94
94
  - app/views/layouts/turbo_rails/frame.html.erb
95
95
  - config/routes.rb
96
- - lib/install/turbo_needs_redis.rb
97
96
  - lib/install/turbo_with_bun.rb
98
97
  - lib/install/turbo_with_importmap.rb
99
98
  - lib/install/turbo_with_node.rb
@@ -124,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
123
  - !ruby/object:Gem::Version
125
124
  version: '0'
126
125
  requirements: []
127
- rubygems_version: 3.5.11
126
+ rubygems_version: 3.5.16
128
127
  signing_key:
129
128
  specification_version: 4
130
129
  summary: The speed of a single-page web application without having to write any JavaScript.
@@ -1,20 +0,0 @@
1
- if (cable_config_path = Rails.root.join("config/cable.yml")).exist?
2
- say "Enable redis in bundle"
3
-
4
- gemfile_content = File.read(Rails.root.join("Gemfile"))
5
- pattern = /gem ['"]redis['"]/
6
-
7
- if gemfile_content.match?(pattern)
8
- uncomment_lines "Gemfile", pattern
9
- else
10
- append_file "Gemfile", "\n# Use Redis for Action Cable"
11
- gem 'redis', '~> 4.0'
12
- end
13
-
14
- run_bundle
15
-
16
- say "Switch development cable to use redis"
17
- gsub_file cable_config_path.to_s, /development:\n\s+adapter: async/, "development:\n adapter: redis\n url: redis://localhost:6379/1"
18
- else
19
- say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
20
- end