stimulizer 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7ff225da6cb516af29d0cd30787586c6c13a9ac6db4bb26eaa2e8dc11f832d0
4
- data.tar.gz: 88c7d3e6259d1052c19e254f15402ff859ccd8e480d21254b13f29f141d80ff6
3
+ metadata.gz: e783af7b60936cc4f7b1d13f98cf9519d81aed08d00b40696caf7d3b90166982
4
+ data.tar.gz: e0c34c9c72c9f6cbbe7e3d57d262f230c91bc11d2f3451145bf062c36a4649bc
5
5
  SHA512:
6
- metadata.gz: f4b33e806d801cebce6220f0c6d63ed14facc335fd6e8eeb38c893b38fffba85e8fa6cde19b30d9a42d0bea36dcf7e833b895c2648a54c9a8d9da231cfb26da3
7
- data.tar.gz: d7049053a80543023684f9581c37ac4d32b11a6ab835079af617a9a6a7a12850cabcad8b316d3b4ecd8c4053bb693d2490f7be98de6ad4ffda4e323db60d0a4a
6
+ metadata.gz: 3a7217915c0e1daca592ad6493b2a3235c1f72ff5e4d0380ae1631e844d1d4601cb3305ec7b7b73f8feb653bc8ebfd2200f2c55ac9ca12fcd6ec9101a880b504
7
+ data.tar.gz: 0a278b19ec5b6bd797894bf2905038aeea4d4ab01f2cfc409e0bf9cce1dc6807b8ffc8a93e85017333eef8d3def540e09f65eeeefe97976f57c6d5e20f1c6de2
data/README.md CHANGED
@@ -16,7 +16,7 @@ For example:
16
16
  <div
17
17
  data-controller="mynamespace--deeper--buttons-grid-component"
18
18
  data-mynamespace--deeper--buttons-grid-component-url-value="http://example.com"
19
- data-mynamespace--deeper--buttons-grid-component-url-color="#ff0000"
19
+ data-mynamespace--deeper--buttons-grid-component-color-value="#ff0000"
20
20
  data-action="click->data-mynamespace--deeper--buttons-grid-component#doSomething"
21
21
  >
22
22
  ```
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stimulizer
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/stimulizer.rb CHANGED
@@ -49,13 +49,11 @@ module Stimulizer
49
49
  output = stimulus_hash(*args)
50
50
  return output if _stimulizer_opts[:output] == :hash
51
51
 
52
- raw(
53
- output.to_a
54
- .map { |k, v| %(#{k.to_s.strip}="#{v.to_s.strip}") }
55
- .join(" ")
56
- .squish
57
- .strip
58
- )
52
+ output.to_a
53
+ .map { |k, v| %(#{k.to_s.strip}="#{v.to_s.strip}") }
54
+ .join(" ")
55
+ .squish
56
+ .strip
59
57
  end
60
58
 
61
59
  private
@@ -85,7 +83,7 @@ module Stimulizer
85
83
  # ... or combine them:
86
84
  #
87
85
  # <%= stimulus(:controller, target: "button", action: "click->doThing")
88
- def build_stimulus_hash(default_controller = false, controller_name: nil, controller: nil, target: nil, action: nil, params: nil, values: nil, classes: nil)
86
+ def build_stimulus_hash(default_controller = false, controller_name: nil, controller: nil, target: nil, action: nil, params: nil, values: nil, classes: nil, outlets: nil)
89
87
  raise ArgumentError(":controller_name specified, but blank") if controller_name&.blank?
90
88
  raise ArgumentError(":controller specified, but blank") if controller&.blank?
91
89
  raise ArgumentError(":target specified, but blank") if target&.blank?
@@ -93,6 +91,7 @@ module Stimulizer
93
91
  raise ArgumentError(":params specified, but blank") if params&.blank?
94
92
  raise ArgumentError(":values specified, but blank") if values&.blank?
95
93
  raise ArgumentError(":classes specified, but blank") if classes&.blank?
94
+ raise ArgumentError(":outlets specified, but blank") if outlets&.blank?
96
95
 
97
96
  {}.tap do |hash|
98
97
  hash[:"data-controller"] = ""
@@ -139,6 +138,10 @@ module Stimulizer
139
138
  hash[:"data-#{local_controller_name}-#{LuckyCase.dash_case(key.to_s)}-class"] = value
140
139
  end
141
140
 
141
+ outlets&.each do |key, value|
142
+ hash[:"data-#{local_controller_name}-#{LuckyCase.dash_case(key.to_s)}-outlet"] = value
143
+ end
144
+
142
145
  hash[:"data-#{local_controller_name}-target"] = target if target
143
146
  end
144
147
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt E Patterson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable