diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 98971647..39fbd17b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [14, 16, 18] steps: - uses: actions/checkout@master diff --git a/cable_ready.gemspec b/cable_ready.gemspec index 444a4ebf..2f38b3cf 100644 --- a/cable_ready.gemspec +++ b/cable_ready.gemspec @@ -19,8 +19,6 @@ Gem::Specification.new do |gem| "[A-Z]*" ] - gem.test_files = Dir["test/**/*.rb"] - rails_version = ">= 5.2" gem.add_dependency "actioncable", rails_version gem.add_dependency "actionpack", rails_version diff --git a/javascript/elements/updates_for_element.js b/javascript/elements/updates_for_element.js index dd8f7647..8c5ce12d 100644 --- a/javascript/elements/updates_for_element.js +++ b/javascript/elements/updates_for_element.js @@ -55,10 +55,10 @@ export default class UpdatesForElement extends SubscribingElement { const blocks = Array.from( document.querySelectorAll(this.query), element => new Block(element) - ) + ).filter(block => block.shouldUpdate(data)) // first updates-for element in the DOM *at any given moment* updates all of the others - if (blocks[0].element !== this) return + if (blocks.length === 0 || blocks[0].element !== this) return // hold a reference to the active element so that it can be restored after the morph ActiveElement.set(document.activeElement) @@ -113,9 +113,6 @@ class Block { } async process (data, html, index) { - // with the index incremented, we can now safely bail - before a fetch - if there's no work to be done - if (!this.shouldUpdate(data)) return - const blockIndex = index[this.url] const template = document.createElement('template') this.element.setAttribute('updating', 'updating') diff --git a/lib/cable_ready/channels.rb b/lib/cable_ready/channels.rb index 94420824..600cd54c 100644 --- a/lib/cable_ready/channels.rb +++ b/lib/cable_ready/channels.rb @@ -13,7 +13,7 @@ def initialize def [](*keys) keys.select!(&:itself) - identifier = keys.many? || (keys.one? && keys.first.respond_to?(:to_global_id)) ? compound(keys) : keys.pop + identifier = (keys.many? || (keys.one? && keys.first.respond_to?(:to_global_id))) ? compound(keys) : keys.pop @channels[identifier] ||= CableReady::Channel.new(identifier) end diff --git a/lib/cable_ready/installer.rb b/lib/cable_ready/installer.rb index 704dbccb..a77027e4 100644 --- a/lib/cable_ready/installer.rb +++ b/lib/cable_ready/installer.rb @@ -181,6 +181,7 @@ def gemfile end def prefix + # standard:disable Style/RedundantStringEscape @prefix ||= { "vite" => "..\/", "webpacker" => "", @@ -188,6 +189,7 @@ def prefix "importmap" => "", "esbuild" => ".\/" }[footgun] + # standard:enable Style/RedundantStringEscape end def application_record_path diff --git a/lib/install/esbuild.rb b/lib/install/esbuild.rb index c02bc947..2eaae5f8 100644 --- a/lib/install/esbuild.rb +++ b/lib/install/esbuild.rb @@ -79,7 +79,7 @@ # uncomment_lines only works with Ruby comments 🙄 lines = pack_path.readlines matches = lines.select { |line| line =~ controllers_commented_pattern } - lines[lines.index(matches.last).to_i] = "import \".\/controllers\"\n" + lines[lines.index(matches.last).to_i] = "import \".\/controllers\"\n" # standard:disable Style/RedundantStringEscape pack_path.write lines.join say "✅ Stimulus controllers imported in #{friendly_pack_path}" else @@ -91,7 +91,7 @@ else lines = pack_path.readlines matches = lines.select { |line| line =~ /^import / } - lines.insert lines.index(matches.last).to_i + 1, "import \".\/controllers\"\n" + lines.insert lines.index(matches.last).to_i + 1, "import \".\/controllers\"\n" # standard:disable Style/RedundantStringEscape pack_path.write lines.join say "✅ Stimulus controllers imported in #{friendly_pack_path}" end diff --git a/lib/install/mrujs.rb b/lib/install/mrujs.rb index 8991f36e..651ed4e5 100644 --- a/lib/install/mrujs.rb +++ b/lib/install/mrujs.rb @@ -30,7 +30,7 @@ say "✅ pin mrujs" end - if !importmap.include?("pin \"mrujs\/plugins\"") + if !importmap.include?("pin \"mrujs/plugins\"") append_file(importmap_path, <<~RUBY, verbose: false) pin "mrujs/plugins", to: "https://ga.jspm.io/npm:mrujs@0.10.1/plugins/dist/plugins.module.js" RUBY @@ -59,7 +59,7 @@ index = index_path.read friendly_index_path = index_path.relative_path_from(Rails.root).to_s mrujs_pattern = /import ['"].\/mrujs['"]/ - mrujs_import = "import '.\/mrujs'\n" + mrujs_import = "import '.\/mrujs'\n" # standard:disable Style/RedundantStringEscape if !index.match?(mrujs_pattern) append_file(index_path, mrujs_import, verbose: false) diff --git a/lib/install/vite.rb b/lib/install/vite.rb index 52ca184e..8669e23a 100644 --- a/lib/install/vite.rb +++ b/lib/install/vite.rb @@ -26,7 +26,7 @@ controllers_pattern = /import ['"](\.\.\/)?controllers['"]/ controllers_commented_pattern = /\s*\/\/\s*#{controllers_pattern}/ -prefix = "..\/" +prefix = "..\/" # standard:disable Style/RedundantStringEscape if pack.match?(controllers_pattern) if pack.match?(controllers_commented_pattern) diff --git a/lib/tasks/cable_ready/cable_ready.rake b/lib/tasks/cable_ready/cable_ready.rake index 8d418554..1cbbfa1f 100644 --- a/lib/tasks/cable_ready/cable_ready.rake +++ b/lib/tasks/cable_ready/cable_ready.rake @@ -78,7 +78,7 @@ namespace :cable_ready do kv[1] = if kv[1] == "true" true else - kv[1] == "false" ? false : kv[1] + (kv[1] == "false") ? false : kv[1] end options[kv[0]] = kv[1] end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb index fe48fc34..9c7a620b 100644 --- a/test/dummy/config/initializers/assets.rb +++ b/test/dummy/config/initializers/assets.rb @@ -1,7 +1,7 @@ # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +# Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path