turbo-rails 0.6.0 → 0.7.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: 42d7a658511c698c83b4e41853f96f5b2534a9ee81b89500044a22d6695a5150
4
- data.tar.gz: 46e9abb9a01e4c9b50d2c2b704ff0e522a7231496b58d7acbc78303cdef67486
3
+ metadata.gz: d791adac758f16b877d9d7c1ed0706e9bb684ba6238f94c3a1de0dcc424b85d4
4
+ data.tar.gz: 9a60a2a70b4b732687220f2cd209454b02a963a450af1ce07ff49708ad8bf0cd
5
5
  SHA512:
6
- metadata.gz: be906021b12ba905c7ce316900cb28db1ec22cbec561c2e009758a58cb059c82984862bae1f045c2f60b1db9fd396ebb2c88ba07c08a2871d1f39556f67cd2b1
7
- data.tar.gz: de3c17c9f07971421add4c6038f385b609d465eb939f1860900c635b35b72b65ebbbea030a2d45722bb6bda86b2b38e5d794c005e063698c3ec63478fd3dd083
6
+ metadata.gz: 2c76c8475cb8509f86208a3553e6561d6dcaec91198d226aa2c23a6b9d45c0615db36cab291b77b82001330c46de12923c817250aa93d2ba9e28bc37b5fbd4b1
7
+ data.tar.gz: c78eb044de3328bb08edb26f552716df709913c640676ff1156ee878e956cc3d860f9a1f82fbe5889491182092563a83708dda4721db1747769b927fac1956a7
data/README.md CHANGED
@@ -38,7 +38,7 @@ The JavaScript for Turbo can either be run through the asset pipeline, which is
38
38
  2. Run `./bin/bundle install`
39
39
  3. Run `./bin/rails turbo:install`
40
40
 
41
- Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used.
41
+ Running `turbo:install` will install through NPM if Webpacker is installed 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.
42
42
 
43
43
  If you're using Webpack and need to use the cable consumer, you can import [`cable`](https://github.com/hotwired/turbo-rails/blob/main/app/javascript/turbo/cable.js) (`import { cable } from "@hotwired/turbo-rails"`), but ensure that your application actually *uses* the members it `import`s when using this style (see [turbo-rails#48](https://github.com/hotwired/turbo-rails/issues/48)).
44
44
 
@@ -62,7 +62,7 @@ Turbo can coexist with Rails UJS, but you need to take a series of upgrade steps
62
62
 
63
63
  * To run the Rails tests: `bundle exec rake`.
64
64
  * To install dependencies: `bundle install`
65
- * To prepare the test database: `cd tests/dummy; RAILS_ENV=test ./bin/rails db:migrate`
65
+ * To prepare the test database: `cd test/dummy; RAILS_ENV=test ./bin/rails db:migrate`
66
66
  * To compile the JavaScript for the asset pipeline: `yarn build`
67
67
 
68
68
 
@@ -1,27 +1,8 @@
1
- APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
2
- IMPORTMAP_PATH = Rails.root.join("app/assets/javascripts/importmap.json.erb")
1
+ APP_JS_ROOT = Rails.root.join("app/assets/javascripts")
3
2
  CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
4
3
 
5
- if APPLICATION_LAYOUT_PATH.exist?
6
- say "Yield head in application layout for cache helper"
7
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= yield :head %>", before: /\s*<\/head>/
8
-
9
- if APPLICATION_LAYOUT_PATH.read =~ /stimulus/
10
- say "Add Turbo include tags in application layout"
11
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module-shim" %>), after: /<%= stimulus_include_tags %>/
12
-
13
- if IMPORTMAP_PATH.exist?
14
- say "Add Turbo to importmap"
15
- insert_into_file IMPORTMAP_PATH, %( "turbo": "<%= asset_path "turbo" %>",\n), after: / "imports": {\s*\n/
16
- end
17
- else
18
- say "Add Turbo include tags in application layout"
19
- insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module" %>), before: /\s*<\/head>/
20
- end
21
- else
22
- say "Default application.html.erb is missing!", :red
23
- say %( Add <%= javascript_include_tag("turbo", type: "module-shim") %> and <%= yield :head %> within the <head> tag after Stimulus includes in your custom layout.)
24
- end
4
+ say "Import turbo-rails in existing app/assets/javascripts/application.js"
5
+ append_to_file APP_JS_ROOT.join("application.js"), %(import "@hotwired/turbo-rails"\n)
25
6
 
26
7
  if CABLE_CONFIG_PATH.exist?
27
8
  say "Enable redis in bundle"
@@ -32,5 +13,3 @@ if CABLE_CONFIG_PATH.exist?
32
13
  else
33
14
  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.'
34
15
  end
35
-
36
- say "Turbo successfully installed ⚡️", :green
@@ -25,5 +25,3 @@ if CABLE_CONFIG_PATH.exist?
25
25
  else
26
26
  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.'
27
27
  end
28
-
29
- say "Turbo successfully installed ⚡️", :green
data/lib/turbo/engine.rb CHANGED
@@ -26,6 +26,14 @@ module Turbo
26
26
  end
27
27
  end
28
28
 
29
+ initializer "turbo.importmap" do
30
+ if Rails.application.config.respond_to?(:importmap)
31
+ Rails.application.config.importmap.paths.tap do |paths|
32
+ paths.asset "@hotwired/turbo-rails", path: "turbo"
33
+ end
34
+ end
35
+ end
36
+
29
37
  initializer "turbo.helpers", before: :load_config_initializers do
30
38
  ActiveSupport.on_load(:action_controller_base) do
31
39
  include Turbo::Streams::TurboStreamsTagBuilder, Turbo::Frames::FrameRequest, Turbo::Native::Navigation
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
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: 0.6.0
4
+ version: 0.7.0
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: 2021-07-21 00:00:00.000000000 Z
13
+ date: 2021-08-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails