view_component_attributes 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9ededd2236874dfc8ff92082cd9174bb62e90198a0e76bc61fd99415f252c470
4
+ data.tar.gz: d9fa9e3e6080d34ae04ec9c2cf419fe4a04881866805750718cb04e6899ef8b5
5
+ SHA512:
6
+ metadata.gz: d9dbd59ff20a1e3bd4c07c1fbf86d361a5894f4ddc59a6096a7a5d16b820a918e5fcb1ce532273f87bce6b4963ae538c30a02b2509e730357853cf6e38a0e5a4
7
+ data.tar.gz: abf4456e69ff5f3ff5cae3d386cac1727742992e6c97c4c697c91aaacd74f724c3c7a5f0944212bede66dacb3900f33acef352a8f02724a21e96db539c124674
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --order rand
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at romaric.pascal@amba.co. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # TODO: Release on Rubygem so it can be set up in the gemspec file
6
+ gem "merge_attributes", github: "Amba-Health/merge_attributes", ref: "d7810fd"
7
+
8
+ group :test do
9
+ gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
10
+ end
11
+
12
+ # Specify your gem's dependencies in view_component_attributes.gemspec
13
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,236 @@
1
+ GIT
2
+ remote: https://github.com/Amba-Health/merge_attributes
3
+ revision: d7810fd7c175d5229fefb631f4b9d4295aa70d24
4
+ ref: d7810fd
5
+ specs:
6
+ merge_attributes (0.1.1)
7
+ activesupport (>= 6.1.0)
8
+ rails (>= 6.1.0)
9
+
10
+ PATH
11
+ remote: .
12
+ specs:
13
+ view_component_attributes (0.1.1)
14
+ actionview
15
+ activemodel
16
+ activesupport
17
+ view_component
18
+ zeitwerk
19
+
20
+ GEM
21
+ remote: https://rubygems.org/
22
+ specs:
23
+ actioncable (6.1.6.1)
24
+ actionpack (= 6.1.6.1)
25
+ activesupport (= 6.1.6.1)
26
+ nio4r (~> 2.0)
27
+ websocket-driver (>= 0.6.1)
28
+ actionmailbox (6.1.6.1)
29
+ actionpack (= 6.1.6.1)
30
+ activejob (= 6.1.6.1)
31
+ activerecord (= 6.1.6.1)
32
+ activestorage (= 6.1.6.1)
33
+ activesupport (= 6.1.6.1)
34
+ mail (>= 2.7.1)
35
+ actionmailer (6.1.6.1)
36
+ actionpack (= 6.1.6.1)
37
+ actionview (= 6.1.6.1)
38
+ activejob (= 6.1.6.1)
39
+ activesupport (= 6.1.6.1)
40
+ mail (~> 2.5, >= 2.5.4)
41
+ rails-dom-testing (~> 2.0)
42
+ actionpack (6.1.6.1)
43
+ actionview (= 6.1.6.1)
44
+ activesupport (= 6.1.6.1)
45
+ rack (~> 2.0, >= 2.0.9)
46
+ rack-test (>= 0.6.3)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
49
+ actiontext (6.1.6.1)
50
+ actionpack (= 6.1.6.1)
51
+ activerecord (= 6.1.6.1)
52
+ activestorage (= 6.1.6.1)
53
+ activesupport (= 6.1.6.1)
54
+ nokogiri (>= 1.8.5)
55
+ actionview (6.1.6.1)
56
+ activesupport (= 6.1.6.1)
57
+ builder (~> 3.1)
58
+ erubi (~> 1.4)
59
+ rails-dom-testing (~> 2.0)
60
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
61
+ activejob (6.1.6.1)
62
+ activesupport (= 6.1.6.1)
63
+ globalid (>= 0.3.6)
64
+ activemodel (6.1.6.1)
65
+ activesupport (= 6.1.6.1)
66
+ activerecord (6.1.6.1)
67
+ activemodel (= 6.1.6.1)
68
+ activesupport (= 6.1.6.1)
69
+ activestorage (6.1.6.1)
70
+ actionpack (= 6.1.6.1)
71
+ activejob (= 6.1.6.1)
72
+ activerecord (= 6.1.6.1)
73
+ activesupport (= 6.1.6.1)
74
+ marcel (~> 1.0)
75
+ mini_mime (>= 1.1.0)
76
+ activesupport (6.1.6.1)
77
+ concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ i18n (>= 1.6, < 2)
79
+ minitest (>= 5.1)
80
+ tzinfo (~> 2.0)
81
+ zeitwerk (~> 2.3)
82
+ addressable (2.8.0)
83
+ public_suffix (>= 2.0.2, < 5.0)
84
+ ast (2.4.2)
85
+ builder (3.2.4)
86
+ capybara (3.36.0)
87
+ addressable
88
+ matrix
89
+ mini_mime (>= 0.1.3)
90
+ nokogiri (~> 1.8)
91
+ rack (>= 1.6.0)
92
+ rack-test (>= 0.6.3)
93
+ regexp_parser (>= 1.5, < 3.0)
94
+ xpath (~> 3.2)
95
+ concurrent-ruby (1.1.10)
96
+ crass (1.0.6)
97
+ diff-lcs (1.5.0)
98
+ erubi (1.10.0)
99
+ globalid (1.0.0)
100
+ activesupport (>= 5.0)
101
+ i18n (1.12.0)
102
+ concurrent-ruby (~> 1.0)
103
+ json (2.6.2)
104
+ loofah (2.18.0)
105
+ crass (~> 1.0.2)
106
+ nokogiri (>= 1.5.9)
107
+ mail (2.7.1)
108
+ mini_mime (>= 0.1.1)
109
+ marcel (1.0.2)
110
+ matrix (0.4.2)
111
+ method_source (1.0.0)
112
+ mini_mime (1.1.2)
113
+ mini_portile2 (2.8.0)
114
+ minitest (5.16.2)
115
+ nio4r (2.5.8)
116
+ nokogiri (1.13.8)
117
+ mini_portile2 (~> 2.8.0)
118
+ racc (~> 1.4)
119
+ parallel (1.22.1)
120
+ parser (3.1.2.0)
121
+ ast (~> 2.4.1)
122
+ public_suffix (4.0.7)
123
+ racc (1.6.0)
124
+ rack (2.2.4)
125
+ rack-test (2.0.2)
126
+ rack (>= 1.3)
127
+ rails (6.1.6.1)
128
+ actioncable (= 6.1.6.1)
129
+ actionmailbox (= 6.1.6.1)
130
+ actionmailer (= 6.1.6.1)
131
+ actionpack (= 6.1.6.1)
132
+ actiontext (= 6.1.6.1)
133
+ actionview (= 6.1.6.1)
134
+ activejob (= 6.1.6.1)
135
+ activemodel (= 6.1.6.1)
136
+ activerecord (= 6.1.6.1)
137
+ activestorage (= 6.1.6.1)
138
+ activesupport (= 6.1.6.1)
139
+ bundler (>= 1.15.0)
140
+ railties (= 6.1.6.1)
141
+ sprockets-rails (>= 2.0.0)
142
+ rails-dom-testing (2.0.3)
143
+ activesupport (>= 4.2.0)
144
+ nokogiri (>= 1.6)
145
+ rails-html-sanitizer (1.4.3)
146
+ loofah (~> 2.3)
147
+ railties (6.1.6.1)
148
+ actionpack (= 6.1.6.1)
149
+ activesupport (= 6.1.6.1)
150
+ method_source
151
+ rake (>= 12.2)
152
+ thor (~> 1.0)
153
+ rainbow (3.1.1)
154
+ rake (13.0.6)
155
+ regexp_parser (2.5.0)
156
+ rexml (3.2.5)
157
+ rspec (3.11.0)
158
+ rspec-core (~> 3.11.0)
159
+ rspec-expectations (~> 3.11.0)
160
+ rspec-mocks (~> 3.11.0)
161
+ rspec-core (3.11.0)
162
+ rspec-support (~> 3.11.0)
163
+ rspec-expectations (3.11.0)
164
+ diff-lcs (>= 1.2.0, < 2.0)
165
+ rspec-support (~> 3.11.0)
166
+ rspec-mocks (3.11.1)
167
+ diff-lcs (>= 1.2.0, < 2.0)
168
+ rspec-support (~> 3.11.0)
169
+ rspec-rails (5.1.2)
170
+ actionpack (>= 5.2)
171
+ activesupport (>= 5.2)
172
+ railties (>= 5.2)
173
+ rspec-core (~> 3.10)
174
+ rspec-expectations (~> 3.10)
175
+ rspec-mocks (~> 3.10)
176
+ rspec-support (~> 3.10)
177
+ rspec-support (3.11.0)
178
+ rubocop (1.32.0)
179
+ json (~> 2.3)
180
+ parallel (~> 1.10)
181
+ parser (>= 3.1.0.0)
182
+ rainbow (>= 2.2.2, < 4.0)
183
+ regexp_parser (>= 1.8, < 3.0)
184
+ rexml (>= 3.2.5, < 4.0)
185
+ rubocop-ast (>= 1.19.1, < 2.0)
186
+ ruby-progressbar (~> 1.7)
187
+ unicode-display_width (>= 1.4.0, < 3.0)
188
+ rubocop-ast (1.19.1)
189
+ parser (>= 3.1.1.0)
190
+ rubocop-performance (1.14.3)
191
+ rubocop (>= 1.7.0, < 2.0)
192
+ rubocop-ast (>= 0.4.0)
193
+ ruby-progressbar (1.11.0)
194
+ sprockets (4.1.1)
195
+ concurrent-ruby (~> 1.0)
196
+ rack (> 1, < 3)
197
+ sprockets-rails (3.4.2)
198
+ actionpack (>= 5.2)
199
+ activesupport (>= 5.2)
200
+ sprockets (>= 3.0.0)
201
+ standard (1.14.0)
202
+ rubocop (= 1.32.0)
203
+ rubocop-performance (= 1.14.3)
204
+ standardrb (1.0.1)
205
+ standard
206
+ thor (1.2.1)
207
+ tzinfo (2.0.5)
208
+ concurrent-ruby (~> 1.0)
209
+ unicode-display_width (2.2.0)
210
+ view_component (2.63.0)
211
+ activesupport (>= 5.0.0, < 8.0)
212
+ method_source (~> 1.0)
213
+ websocket-driver (0.7.5)
214
+ websocket-extensions (>= 0.1.0)
215
+ websocket-extensions (0.1.5)
216
+ xpath (3.2.0)
217
+ nokogiri (~> 1.8)
218
+ zeitwerk (2.6.0)
219
+
220
+ PLATFORMS
221
+ ruby
222
+
223
+ DEPENDENCIES
224
+ bundler (~> 1.17)
225
+ capybara
226
+ merge_attributes!
227
+ rails (>= 6.1.0)
228
+ rake (>= 12.2)
229
+ rspec (~> 3.0)
230
+ rspec-rails
231
+ standardrb
232
+ tzinfo-data
233
+ view_component_attributes!
234
+
235
+ BUNDLED WITH
236
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Amba Health & Care
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # ViewComponentAttributes
2
+
3
+ This Gem helps the management of attributes received by View Components (or props, options, however you name them). It offers a set of concerns to mix into your components to:
4
+
5
+ - declare the attributes your component expects to receive. Backed by ActiveModel's API for familiarity
6
+ - collect attributes not declared by the component, for later use as HTML attributes in rendering to set ad-hoc classes or Stimulus controllers, for example
7
+ - declaring a component's "root" element and managing its attributes either in the class or the template
8
+ - merging attributes coming from outside the component with those computed inside its class and template
9
+ - defining temporary defaults for component's attributes, allowing to customise the rendering of sub-components without passing attributes at each step
10
+
11
+ You can buy in as much or as little of this as you want by picking the concerns you include, it's up to you.
12
+
13
+ ## Usage
14
+
15
+ Pick and chose the concern to include in your components to give them more or less power
16
+
17
+ ###  `WithAttributes`: Declare expected attributes
18
+
19
+ Include the `WithAttributes` concern to let your component declare the attributes it expects with the same `attribute` API as ActiveModel (a similar take as [`view_component-contrib`'s use of `dry-initializer`](https://github.com/palkan/view_component-contrib#hanging-initialize-out-to-dry)).
20
+
21
+ ```rb
22
+ class MyComponent < ViewComponent::Base
23
+ include ViewComponentAttributes::WithAttributes
24
+
25
+ attribute :some_attribute
26
+ attribute :attribute_with_default, default: 5
27
+
28
+ # If you need to compute a default based on other attributes
29
+ # you can override the getter and use ActiveModel's `attribute`
30
+ # method to read any value provided to the component
31
+ attribute :attribute_with_computed_default
32
+ def attribute_with_computed_default
33
+ attribute(:attribute_with_computed_default) || do_some_computation
34
+ end
35
+ end
36
+ ```
37
+
38
+ ### `WithUnknownAttributes`: Collect unknown attributes for later use
39
+
40
+ By default `ActiveModel` will throw if you use unknown attributes during initialization. This makes models safer, but when it comes to the view, you often need to add attributes that shouldn't be the responsibility of the component itself:
41
+
42
+ - new `class`es because of where the component is rendered, or an `id` to be referenced by `aria-labelledby` or `aria-controls` for accessibility...
43
+ - Stimulus attributes to make the component a [target](https://stimulus.hotwired.dev/reference/targets), trigger an [action](https://stimulus.hotwired.dev/reference/actions) or maybe just some extra [controllers](https://stimulus.hotwired.dev/reference/controllers).
44
+
45
+ Include the `WithUnknownAttributes` concern to avoid an error being thrown and the extra attributes made available through the `unknown_attributes` method.
46
+
47
+ _Includes `WithAttribute`_
48
+
49
+ ```rb
50
+ class MyComponent < ViewComponent::Base
51
+ include ViewComponentAttributes::WithUnknownAttributes
52
+ end
53
+
54
+ component = MyComponent.new(class:'some-class', id: 'some-id')
55
+ component.unknown_attributes # {:class=>"some-class", :id=>"some-id"}
56
+ ```
57
+
58
+ ### `WithRoot` and `WithRootAttributes`: Declare a component's root element and manage its attributes
59
+
60
+ Most components have their content wrapped by a single root element or sub-component. `WithRoot` and `WithRootAttributes` help you define which element or component to use, and combine attributes from different places in a standardised way: declarative defaults (that can be computed), component's template and component's initialization.
61
+
62
+ They can each be used independently, but work best together:
63
+
64
+ ```rb
65
+ class MyComponent < ViewComponent::Base
66
+ # Needs to be first to ensure its `root_attributes` method
67
+ # gets overriden as necessary by that of `WithRootAttributes`
68
+ include ViewComponentAttributes::WithRoot
69
+ include WithComponentAttributes::WithRootAttributes
70
+ end
71
+ ```
72
+
73
+ #### Configuring the component's root element/component
74
+
75
+ `WithRoot` provides some help for declaring and rendering the component's root element or component.
76
+
77
+ From the template or the component's `call` method, the **`root` instance method** renders the root of the component.
78
+
79
+ ```erb
80
+ <%# my_component.html.erb %>
81
+ <%= root(:article, class: "a-class", id: "an-id") do %>
82
+ <%# Inside of the component gets rendered here %>
83
+ <% end %>
84
+ ```
85
+
86
+ The element or component's class to render can be passed as first positional parameters: a class will be treated as a component, anything else sent to the [`tag` helper](https://api.rubyonrails.org/v7.0.2/classes/ActionView/Helpers/TagHelper.html#method-i-tag).
87
+
88
+ If you don't provide any, whichever you provided using the `root` class method. This can help keep code related to each other in the same place rather than split across class and template. Default is a `<div>`, but please do take some time to use [elements with built-in semantics](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) to give your users the best experience).
89
+
90
+ ```rb
91
+ class MyComponent < ViewComponent::Base
92
+ root AnotherComponent
93
+ end
94
+ ```
95
+
96
+ That element or component will be rendered with the provided attributes and the block containing what's inside it.
97
+
98
+ Why not plainly set the element in the template (or `call`)? Using the `root` method sets you up for a consitent way to make computations for the rendering ot component's root:
99
+
100
+ - **picking the element or component of the root** with the `root_type` method when none is provided in the template. For example, this list component can switch its semantics based on an `ordered` attribute:
101
+
102
+ ```rb
103
+ class ListComponent < ViewComponent::Base
104
+ include ViewComponentAttributes::WithAttributes
105
+ include ViewComponentAttributes::WithRoot
106
+
107
+ attribute :ordered
108
+
109
+ def root_type(template_root)
110
+ if (ordered)
111
+ :ol
112
+ else
113
+ :ul
114
+ end
115
+ end
116
+
117
+ def call
118
+ root {content}
119
+ end
120
+ end
121
+ ```
122
+
123
+ - **computing the attributes of that root element/component**, with the `root_attributes` method, potentially merging them from different origins.
124
+ That's what the `WithRootAttributes` concern takes advantage of to work its wonders.
125
+
126
+ ####  Configuring the component's root attributes
127
+
128
+ `WithRoot` provides some structure, but is really mostly a setup for `WithRootAttribute`. This concern is responsible for mixing attributes coming from different part of the components:
129
+
130
+ - default attributes configured at class level, using the **`root_attributes` class method** (either as a hash, or a block if they require computations)
131
+ - attributes passed to the `root` method (or the **`root_attributes` instance method** if you need to compute root attributes for a helper like `link_to` or `form_for`)
132
+ - attributes passed to the component at initialization, those explicitely passed as the `root_attributes` attributes, as well as all the `unknown_attributes` gathered by the `WithUnknownAttributes` concern
133
+
134
+ ```rb
135
+ class PostComponent
136
+ include WithRoot
137
+ include WithRootAttributes
138
+
139
+ attribute :heading
140
+
141
+ # At class-level, the root attributes can take
142
+ # various shape:
143
+ # A static set of attributes...
144
+ root_attributes({class: 'a-class'})
145
+ #
146
+ # ...or a block, when computations are needed.
147
+ #
148
+ # That block can return a hash...
149
+ root_attributes do
150
+ {
151
+ class: compute_the_class
152
+ }
153
+ end
154
+ #
155
+ # ... or an array of hashes, allowing to separate different sets of attributes
156
+ #
157
+ root_attributes do
158
+ [
159
+ {
160
+ class: compute_the_class
161
+ },
162
+ attributes_for_responsibility_a
163
+ attributes_for_responsibility_b
164
+ ]
165
+ end
166
+
167
+ def attributes_for_responsibility_a
168
+ # ...
169
+ end
170
+ def attributes_for_responsibility_b
171
+ # ...
172
+ end
173
+ end
174
+ ```
175
+
176
+ ```erb
177
+ <%#
178
+ These extra attributes will be merged with the defaults,
179
+ allowing them to stay grouped in the same file for easier understanding
180
+ %>
181
+ <%= root(:article, class: 'blog-article') do %>
182
+ <h1 class="blog-article__heading"><%= heading %></h1>
183
+ <div class="blog-article__body">
184
+ <%= content %>
185
+ </div>
186
+ <% end %>
187
+ ```
188
+
189
+ ```erb
190
+ <%#
191
+ Finally, attributes from instanciation will get merged in as well,
192
+ allowing to set extra attributes based on:
193
+ - where the component is rendered,
194
+ - what data it's rendering
195
+ - or anything else it's not responsible for.
196
+ In case of collision of a root_attribute with one of the component,
197
+ you can use the `root_attributes` attribute to make sure of which is which.
198
+ %>
199
+ <%= render PostComponent.new(
200
+ heading: post.title,
201
+ id: dom_id(post),
202
+ class: 'post-list__post'
203
+ ) do %>
204
+ <%= post.content %>
205
+ <% end %>
206
+ ```
207
+
208
+ ### `WithContextAttributes`: Setting temporary default attributes
209
+
210
+ Sometimes you have a `GrandParentComponent`, that renders a `ParentComponent`, that then renders a `ChildComponent`, which finally renders a `GrandChildComponent`. It's all nice... until in a specific scenario that `GrandChildComponent` needs an extra attribute, for that one time only.
211
+
212
+ Sure the `GrandParentComponent` could take it, pass it down, and so could the `ParentComponent` and the `ChildComponent`... until it reaches the `GrandChildComponent`. That's one more responsibility for them, which is not ideal. And after all, it's all the `GrandChildComponent` fault if that needs to happen so best it be the one handling it.
213
+
214
+ That's what the `WithContextAttributes` mixin handles. It adds a `with_attributes` class method to the `GrandChildComponent` to temporarily set defaults:
215
+
216
+ ```erb
217
+ <% GrandChildComponent.with_attributes('data-accordion-target': 'content') do %>
218
+ <%#
219
+ # Inside this block, new instances of `GrandChildComponent` will receive
220
+ # the `data-accordion-target` attribute.
221
+ %>
222
+ <%= render GrandParentComponent.new(...) %>
223
+ <% end %>
224
+ <%#
225
+ Back out of the block, new instances won't have the attribute,
226
+ it's back to normal
227
+ %>
228
+ ```
229
+
230
+ ## Installation
231
+
232
+ Add these lines to your application's Gemfile
233
+
234
+ ```ruby
235
+ # Ideally replace the `branch: "main"` with a commit reference (`ref: COMMIT_HASH`)
236
+ # https://bundler.io/guides/git.html
237
+ gem "merge_attributes", github: "Amba-Health/merge_attributes", branch: "main"
238
+ gem "view_component_attributes", github: "Amba-Health/view_component_attributes", branch: "main"
239
+ ```
240
+
241
+ <details>
242
+ <summary>Coming soon!</summary>
243
+
244
+ Add this line to your application's Gemfile:
245
+
246
+ ```ruby
247
+ gem 'view_component_attributes'
248
+ ```
249
+
250
+ And then execute:
251
+
252
+ bundle
253
+
254
+ Or install it yourself as:
255
+
256
+ gem install view_component_attributes
257
+
258
+ </details>
259
+
260
+ ## Development
261
+
262
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
263
+
264
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
265
+
266
+ ## Contributing
267
+
268
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/[USERNAME>]/view_component_attributes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
269
+
270
+ ## License
271
+
272
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
273
+
274
+ ## Code of Conduct
275
+
276
+ Everyone interacting in the ViewComponentAttributes project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/view_component_attributes/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "view_component_attributes"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ # Pre-load some likely necessary libraries
15
+ require "rails"
16
+ require "view_component"
17
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ module ViewComponentAttributes
2
+ MAJOR = 0
3
+ MINOR = 1
4
+ TINY = 1
5
+ PRE = nil
6
+
7
+ VERSION = [MAJOR, MINOR, TINY, PRE].compact.join(".")
8
+ end
@@ -0,0 +1,20 @@
1
+ require "active_support"
2
+ require "active_model"
3
+
4
+ module ViewComponentAttributes
5
+ module WithAttributes
6
+ extend ActiveSupport::Concern
7
+ include ActiveModel::Model
8
+ include ActiveModel::Attributes
9
+
10
+ # Little gotcha as the internal @attributes AttributeSet
11
+ # used by ActiveModel::Model uses String keys.
12
+ # https://github.com/rails/rails/blob/76489d81ba77216271870e11fba6889088016fa5/activemodel/lib/active_model/attributes.rb#L99
13
+ # It's very natural to use a Symbol here,
14
+ # so turning the name into a string
15
+ # to avoid pitfals
16
+ def attribute(name)
17
+ super(name.to_s)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,47 @@
1
+ module ViewComponentAttributes
2
+ module WithContextAttributes
3
+ ## Allows to configure default attributes for the component
4
+ # specifically for the execution of a block. This comes handy
5
+ # for passing defaults to sub-components without having
6
+ # to have each component in the chain passing them down
7
+ #
8
+ # ```
9
+ # - Component.with_attributes(option: 'value') do
10
+ # -# Say `GrandParendComponent` renders a `ParentComponent`
11
+ # -# Which in turn renders our `Component`
12
+ # -# Our component will have its `option` attribute defaulted
13
+ # -# to `'value'` when called without having `GrandParentComponent`
14
+ # -# or `ParentComponent` having to take responsibility for passing it
15
+ # = render GrandParentComponent.new(...)
16
+ # ```
17
+
18
+ extend ActiveSupport::Concern
19
+ include ViewComponentAttributes::WithAttributes
20
+ include MergeAttributes::Helper
21
+
22
+ included do
23
+ class_attribute :block_attributes
24
+
25
+ # Prepend the initializer so its `super` calls
26
+ # the class' `initialize` method rather than
27
+ # the other way around
28
+ prepend WithContextAttributes::Initializer
29
+ end
30
+
31
+ class_methods do
32
+ def with_attributes(**attributes)
33
+ self.block_attributes = attributes
34
+
35
+ yield
36
+ ensure
37
+ self.block_attributes = nil
38
+ end
39
+ end
40
+
41
+ module Initializer
42
+ def initialize(*args, **initialize_attributes)
43
+ super(*args, **merge_attributes(block_attributes || {}, initialize_attributes))
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,86 @@
1
+ require "active_support"
2
+
3
+ module ViewComponentAttributes
4
+ module WithRoot
5
+ ##
6
+ # Most components are wrapped in a single root element/component
7
+ # This module formalises this with:
8
+ # - The configuration of that root element, either:
9
+ # - at class level using the `root` class method
10
+ # - at instanciation through the `root` (or `tag_name`) attribute
11
+ # - The rendering of the root using the `root` instance method.
12
+ #
13
+ # **Passing attributes**
14
+ #
15
+ # It accepts a hash of attributes and a block with the content
16
+ # to be rendered inside the root. The attributes can be processed
17
+ # using the `root_attributes` instance method
18
+ # (for ex. with the `WithRootAttributes` concern)
19
+ #
20
+ # ```haml
21
+ # = root(class: 'a-class', id: 'the-id') do
22
+ # = "Content of the component goes here"
23
+ # ```
24
+ #
25
+ # **Customizing root element/component**
26
+ #
27
+ # To keep semantics in the same place, you can also provide
28
+ # the root element/component at render time as a positional arg
29
+ #
30
+ # ```haml
31
+ # = root(:ul, class: 'list-group') do
32
+ # - collection.each do
33
+ # %li.list-group-item
34
+ # ```
35
+ #
36
+ # That value is processed by the `root_type` method that you can
37
+ # override should the root element/component depend on some
38
+ # logic from the component:
39
+ #
40
+ # ```rb
41
+ # def root_type(template_root)
42
+ # if ordered?
43
+ # :ol
44
+ # else
45
+ # :ul
46
+ # end
47
+ # end
48
+ # ```
49
+ extend ActiveSupport::Concern
50
+
51
+ include ViewComponentAttributes::WithAttributes
52
+
53
+ included do
54
+ # Class attribute to store default set at class definition
55
+ class_attribute :default_root, default: :div
56
+
57
+ # Instance attributes to store value configured at instanciation
58
+ attribute :root
59
+ alias_attribute :tag_name, :root
60
+ end
61
+
62
+ class_methods do
63
+ def root(tag_name_or_component)
64
+ self.default_root = tag_name_or_component
65
+ end
66
+ end
67
+
68
+ def root(template_root = nil, **template_attributes, &block)
69
+ root_to_render = root_type(template_root)
70
+
71
+ if root_to_render.is_a?(Class)
72
+ render(root_to_render.new(**root_attributes(**template_attributes)), &block)
73
+ else
74
+ tag.send(root_to_render, **root_attributes(**template_attributes), &block)
75
+ end
76
+ end
77
+
78
+ def root_type(template_root)
79
+ @root_type ||= attribute(:root) || template_root || default_root
80
+ end
81
+
82
+ def root_attributes(**template_attributes)
83
+ template_attributes
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,110 @@
1
+ module ViewComponentAttributes
2
+ module WithRootAttributes
3
+ ##
4
+ # Formalises the generation of the attributes of the root
5
+ # element/components. It defines the `root_attributes`
6
+ # method to merge attributes configured at different
7
+ # points of the component's lifecycle:
8
+ # - class definition, through a `root_attributes` class method
9
+ # allowing to set either (but not both, for now):
10
+ # - a static hash of attributes
11
+ # ```rb
12
+ # root_attributes {class: 'component-class'}
13
+ # ```
14
+ # - a block that'll get evaluated against the component when
15
+ # the attributes are generated.
16
+ # ```rb
17
+ # root_attributes do
18
+ # {
19
+ # class: compute_the_class
20
+ # }
21
+ # end
22
+
23
+ # def compute_the_class
24
+ # ...
25
+ # end
26
+ # ```
27
+ # - overriding the `dynamic_root_attributes` method for computations
28
+ # that don't fit in a block. It can return an Array of attribute hashes.
29
+ # Don't forget to call `super`
30
+ # - attribute computation, collecting the keyword arguments
31
+ # to the `root_attributes` call so that relevant groups
32
+ # of related attributes (BEM classes, Stimulus controller and targets)
33
+ # can live in the same file (template or class)
34
+ # - object instanciation, through:
35
+ # - the collection of the `unknown_attributes`
36
+ # - a `root_attributes` attribute passed to `new`
37
+
38
+ # ```
39
+ # HasRootAttributesComponent.new(
40
+ # root_attributes: {
41
+ # class: 'a-class'
42
+ # },
43
+ # id: 'the-id'
44
+ # ) # Will have `{class: 'a-class', id: 'the-id'}` as root attributes
45
+ # ```
46
+ #
47
+ # **Controlling merge order**
48
+ #
49
+ # By default, attributes are merged from the "most generic" (class definition) place of declaration
50
+ # to the "most specific" (object instanciation, to allow manual setting of any attributes)
51
+ #
52
+ # 1. static_root_attributes # Instance method
53
+ # 2. dynamic_root_attributes # Instance method
54
+ # 3. template_attributes # Arguments of `root_attributes`
55
+ # 4. unknown_attributes # Instance method
56
+ # 5. instance_root_attributes # Instance method
57
+ #
58
+ # If a different order is required for a specific component,
59
+ # you can override the `root_attributes` method to `merge_attributes`
60
+ # in the relevant order.
61
+ extend ActiveSupport::Concern
62
+
63
+ include ViewComponentAttributes::WithAttributes
64
+ include ViewComponentAttributes::WithUnknownAttributes
65
+ # Necessary to include MergeAttributes::Helper
66
+ include ActionView::Helpers::TagHelper
67
+ include MergeAttributes::Helper
68
+
69
+ included do
70
+ attribute :root_attributes
71
+
72
+ class_attribute :static_root_attributes, instance_accessor: false
73
+ end
74
+
75
+ class_methods do
76
+ def root_attributes(default_value = nil, &block)
77
+ if block
78
+ # Allows to have the right scope when running the block
79
+ define_method :get_default_root_attributes, &block
80
+ end
81
+
82
+ self.static_root_attributes = default_value
83
+ end
84
+ end
85
+
86
+ def root_attributes(**template_attributes)
87
+ merge_attributes(
88
+ static_root_attributes,
89
+ dynamic_root_attributes,
90
+ template_attributes,
91
+ unknown_attributes,
92
+ instance_root_attributes
93
+ )
94
+ end
95
+
96
+ def instance_root_attributes
97
+ attribute(:root_attributes)
98
+ end
99
+
100
+ def dynamic_root_attributes
101
+ if respond_to?(:get_default_root_attributes)
102
+ get_default_root_attributes
103
+ end
104
+ end
105
+
106
+ def static_root_attributes
107
+ singleton_class.static_root_attributes
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,37 @@
1
+ require "active_support"
2
+ module ViewComponentAttributes
3
+ module WithUnknownAttributes
4
+ ##
5
+ # Allows gathering of unknown attributes
6
+ # when setting attributes on a Component
7
+ # (or any ActiveModel, for that matter).
8
+ #
9
+ # This lets us collect the extra attributes
10
+ # to be used as HTML attributes later on
11
+ extend ActiveSupport::Concern
12
+ include ViewComponentAttributes::WithAttributes
13
+
14
+ def assign_unknown_attribute(attribute_name, value)
15
+ unknown_attributes[attribute_name.to_sym] = value
16
+ end
17
+
18
+ def unknown_attributes
19
+ @unknown_attributes ||= {}
20
+ end
21
+
22
+ private
23
+
24
+ ##
25
+ # Overrides the _assign_attribute method
26
+ # to avoid adding many computations during
27
+ # component instanciation.
28
+ def _assign_attribute(k, v)
29
+ setter = :"#{k}="
30
+ if respond_to?(setter)
31
+ public_send(setter, v)
32
+ else
33
+ assign_unknown_attribute(k, v)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ require "view_component_attributes/version"
2
+
3
+ require "zeitwerk"
4
+ loader = Zeitwerk::Loader.for_gem
5
+ loader.setup
6
+
7
+ module ViewComponentAttributes
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "view_component_attributes/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "view_component_attributes"
7
+ spec.version = ViewComponentAttributes::VERSION
8
+ spec.authors = ["Romaric Pascal", "Amba Health & Care"]
9
+ spec.email = ["hello@romaricpascal.is", "developers@amba.co"]
10
+
11
+ spec.summary = "Concerns to help manage attributes in View Components"
12
+ spec.homepage = "https://github.com/Amba-Health/view_component_attributes"
13
+ spec.license = "MIT"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.17"
25
+ spec.add_development_dependency "rake", ">= 12.2"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rails", ">= 6.1.0"
28
+ spec.add_development_dependency "rspec-rails"
29
+ spec.add_development_dependency "capybara"
30
+ spec.add_development_dependency "standardrb"
31
+
32
+ spec.add_dependency "zeitwerk"
33
+ spec.add_dependency "view_component"
34
+ spec.add_dependency "activemodel"
35
+ spec.add_dependency "actionview"
36
+ spec.add_dependency "activesupport"
37
+ end
metadata ADDED
@@ -0,0 +1,232 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: view_component_attributes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Romaric Pascal
8
+ - Amba Health & Care
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2024-07-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.17'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.17'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '12.2'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '12.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rails
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 6.1.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 6.1.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-rails
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: capybara
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: standardrb
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: zeitwerk
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: view_component
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: activemodel
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: actionview
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: activesupport
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ description:
183
+ email:
184
+ - hello@romaricpascal.is
185
+ - developers@amba.co
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".gitignore"
191
+ - ".rspec"
192
+ - ".travis.yml"
193
+ - CODE_OF_CONDUCT.md
194
+ - Gemfile
195
+ - Gemfile.lock
196
+ - LICENSE.txt
197
+ - README.md
198
+ - Rakefile
199
+ - bin/console
200
+ - bin/setup
201
+ - lib/view_component_attributes.rb
202
+ - lib/view_component_attributes/version.rb
203
+ - lib/view_component_attributes/with_attributes.rb
204
+ - lib/view_component_attributes/with_context_attributes.rb
205
+ - lib/view_component_attributes/with_root.rb
206
+ - lib/view_component_attributes/with_root_attributes.rb
207
+ - lib/view_component_attributes/with_unknown_attributes.rb
208
+ - view_component_attributes.gemspec
209
+ homepage: https://github.com/Amba-Health/view_component_attributes
210
+ licenses:
211
+ - MIT
212
+ metadata: {}
213
+ post_install_message:
214
+ rdoc_options: []
215
+ require_paths:
216
+ - lib
217
+ required_ruby_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
227
+ requirements: []
228
+ rubygems_version: 3.4.19
229
+ signing_key:
230
+ specification_version: 4
231
+ summary: Concerns to help manage attributes in View Components
232
+ test_files: []