stimulus-rails 0.5.1 → 0.5.2

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: 96b9b74f895ea578d6b80110094d94dd06057c6bdaf9554ed57a07b402ef45be
4
- data.tar.gz: 910d75cea83fffa62328a5a5f913ba5cf4b54a462ee092388b6e87ebf34f8565
3
+ metadata.gz: 55f2f78c04bb5e5e457a008c8be807c29ed61c6192f75633643b8f9b2cbda516
4
+ data.tar.gz: b03050a3322e99eab6d85006feb1b0190ab70d9c8715e410ad868f65d75947af
5
5
  SHA512:
6
- metadata.gz: '09f2b5d9bee56151ead42d5c5d854bc8aede8e2d3c18c97b9d6b2470de9bab42c119ccb1b2a7c0907f5719e8c6780cb1d0dddcec37176895064f31fe587a6ab4'
7
- data.tar.gz: 7d922f521c2d3cb4f60fd6331340505c656817a83377c8ecd3341c0fbb73f224fbe8d5ee2fd64b976c451923b399a614e91be043acc23291613c133d7a577387
6
+ metadata.gz: 8f281e3eb9e2f3e8c31d2097b557e116151390e54a7c5f1b5e333770514be4bf0ebb2794011bad1e6a163e661c56e903c7b7344fed49430471cb48f87b1f1173
7
+ data.tar.gz: 10d351b7e2f7e37ede5641ad9d049953405fb981217673e65aa7f734338e5f3aa0f67720e529a425673f379e81da8fcb493e92dd5fdbc3a53fb9b082c8fb67a3
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [Stimulus](https://stimulus.hotwired.dev) is a JavaScript framework with modest ambitions. It doesn’t seek to take over your entire front-end in fact, it’s not concerned with rendering HTML at all. Instead, it’s designed to augment your HTML with just enough behavior to make it shine. Stimulus pairs beautifully with Turbo to provide a complete solution for fast, compelling applications with a minimal amount of effort. Together they form the core of [Hotwire](https://hotwired.dev).
4
4
 
5
- Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It relies on `importmap-rails` to make stimulus available via ESM. Make sure to install this first!
5
+ Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It relies on either `importmap-rails` to make Stimulus available via ESM or a node-capable Rails (like via `jsbundling-rails`) to include Stimulus in the bundle. Make sure to install one of these first!
6
6
 
7
7
 
8
8
  ## Installation
@@ -11,7 +11,7 @@ Stimulus for Rails makes it easy to use this modest framework with the asset pip
11
11
  2. Run `./bin/bundle install`.
12
12
  3. Run `./bin/rails stimulus:install`
13
13
 
14
- The installer will automatically detect whether you're using an [import map](https://github.com/rails/importmap-rails) or [JavaScript bundler](https://github.com/rails/jsbundling-rails) to manage your application's JavaScript. If you're using an import map, the Stimulus dependencies will be pinned to the versions of the library included with this gem. If you're using node, yarn will add the dependencies to your package.json file.
14
+ The installer will automatically detect whether you're using an [import map](https://github.com/rails/importmap-rails) or [JavaScript bundler](https://github.com/rails/jsbundling-rails) to manage your application's JavaScript. If you're using an import map, the Stimulus dependencies will be pinned to the versions of the library included with this gem. If you're using node, yarn will add the dependencies to your `package.json` file.
15
15
 
16
16
 
17
17
  ## Usage
@@ -14,7 +14,7 @@ export function parseImportmapJson() {
14
14
 
15
15
  function registerControllerFromPath(path, under, application) {
16
16
  const name = path
17
- .replace(`${under}/`, "")
17
+ .replace(new RegExp(`^${under}/`), "")
18
18
  .replace("_controller", "")
19
19
  .replace(/\//g, "--")
20
20
  .replace(/_/g, "-")
@@ -3,16 +3,20 @@ module Stimulus::Manifest
3
3
 
4
4
  def generate_from(controllers_path)
5
5
  extract_controllers_from(controllers_path).collect do |controller_path|
6
- module_path = controller_path.relative_path_from(controllers_path).to_s.remove(".js")
7
- controller_class_name = module_path.camelize.gsub(/::/, "__")
8
- tag_name = module_path.remove("_controller").gsub(/\//, "--")
9
-
10
- <<-JS
6
+ import_and_register_controller(controllers_path, controller_path)
7
+ end
8
+ end
9
+
10
+ def import_and_register_controller(controllers_path, controller_path)
11
+ module_path = controller_path.relative_path_from(controllers_path).to_s.remove(".js")
12
+ controller_class_name = module_path.camelize.gsub(/::/, "__")
13
+ tag_name = module_path.remove("_controller").gsub(/_/, "-").gsub(/\//, "--")
14
+
15
+ <<-JS
11
16
 
12
17
  import #{controller_class_name} from "./#{module_path}"
13
18
  application.register("#{tag_name}", #{controller_class_name})
14
- JS
15
- end
19
+ JS
16
20
  end
17
21
 
18
22
  def extract_controllers_from(directory)
@@ -1,3 +1,3 @@
1
1
  module Stimulus
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
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-09-11 00:00:00.000000000 Z
13
+ date: 2021-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails