hotwired_component 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/lib/generators/hotwired_component/component/component_generator.rb +3 -3
- data/lib/generators/hotwired_component/component/templates/component_test.rb.erb +7 -0
- data/lib/generators/hotwired_component/install/install_generator.rb +9 -16
- data/lib/generators/hotwired_component/install/templates/application_component.rb.erb +2 -0
- data/lib/hotwired_component.rb +1 -0
- data/lib/hotwired_component/version.rb +1 -1
- metadata +6 -5
- data/lib/generators/hotwired_component/component/templates/component_spec.rb.erb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c154c7e2689c88350c38776f1582ba4e3a2ba58adb4252fa4adfa7dc21c50492
|
4
|
+
data.tar.gz: 640a49b20cedbefd567964dfa0637f32584d71cf263d63806c63293b46f831b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0381ef8e62ed5a515e085685a36e54cf538b47aa1194b0da8ca101695876d2833baafd6268727ae834140877e39e61e0ba20c17da168d60915db77eeb6acfb83'
|
7
|
+
data.tar.gz: 151a541643197deabb8fceaf4025b59d86f63f69c375f4fb34cf06764ef82b486fef5e26ced35f5ecb2953cf344c41551304daffe944a09badf311f76d7ddb5b
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# HotwiredComponent
|
2
|
-
HotwiredComponent adds Hotwired centered generators for Github's ViewComponent
|
2
|
+
HotwiredComponent adds Hotwired centered generators for Github's [ViewComponent](https://github.com/github/view_component) utilizing
|
3
|
+
the side car metod. Components generated using this gem will by convention also generate an `scss` file and Stimulus controller.
|
4
|
+
Components are class namespaced by their name, and by default every component has a stimulus controller.
|
3
5
|
|
4
6
|
## Usage
|
5
|
-
|
7
|
+
`rails g hotwire_component:component My::Widget`
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
Add this line to your application's Gemfile:
|
@@ -16,5 +18,11 @@ And then execute:
|
|
16
18
|
$ bundle
|
17
19
|
```
|
18
20
|
|
21
|
+
And run:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ rails g hotwired_component:install
|
25
|
+
```
|
26
|
+
|
19
27
|
## License
|
20
28
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -48,9 +48,9 @@ module HotwiredComponent
|
|
48
48
|
|
49
49
|
def create_test_file
|
50
50
|
template(
|
51
|
-
"
|
52
|
-
File.join("
|
53
|
-
"#{file_name}
|
51
|
+
"component_test.rb.erb",
|
52
|
+
File.join("test/components", class_path,
|
53
|
+
"#{file_name}_component_test.rb")
|
54
54
|
)
|
55
55
|
end
|
56
56
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
<% indent_level = 0 %><% class_name.split('::')[0..-2].each do |name| %><%= " " * indent_level %>module <%= name %>
|
4
|
+
<% indent_level += 2 %><% end %><%= " " * indent_level %>class <%= class_name.split("::").last %>ComponentTest < ViewComponent::TestCase
|
5
|
+
<%= " " * indent_level %>end<% class_name.split("::")[0..-2].length.times do %><% indent_level -= 2 %>
|
6
|
+
<%= " " * indent_level %>end<% end %>
|
7
|
+
|
@@ -2,26 +2,19 @@ module HotwiredComponent
|
|
2
2
|
class InstallGenerator < Rails::Generators::Base
|
3
3
|
source_root File.expand_path('templates', __dir__)
|
4
4
|
|
5
|
-
def install_hotwired_rails
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def add_component_controllers
|
10
|
-
append_to_file "app/javascript/packs/application.js" do
|
11
|
-
<<~JAVASCRIPT
|
12
|
-
const component_stylesheets = require.context(
|
13
|
-
"../../components/",
|
14
|
-
true,
|
15
|
-
/\.scss$/
|
16
|
-
);
|
5
|
+
# def install_hotwired_rails
|
6
|
+
# rake "hotwire:install"
|
7
|
+
# end
|
17
8
|
|
18
|
-
|
19
|
-
|
9
|
+
def add_application_component
|
10
|
+
template "application_component.rb.erb",
|
11
|
+
"app/components/application_component.rb"
|
12
|
+
end
|
20
13
|
|
21
|
-
|
14
|
+
def add_component_controllers
|
22
15
|
append_to_file "app/javascript/controllers/index.js" do
|
23
16
|
<<~JAVASCRIPT
|
24
|
-
context = require.context("components", true, /_controller\.js$/)
|
17
|
+
context = require.context("../../components", true, /_controller\.js$/)
|
25
18
|
application.load(definitionsFromContext(context))
|
26
19
|
JAVASCRIPT
|
27
20
|
end
|
data/lib/hotwired_component.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotwired_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fugufish
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2'
|
53
|
+
version: '2.0'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2'
|
60
|
+
version: '2.0'
|
61
61
|
description: Hotwire + ViewComponent
|
62
62
|
email:
|
63
63
|
- therealfugu@gmail.com
|
@@ -75,9 +75,10 @@ files:
|
|
75
75
|
- lib/generators/hotwired_component/component/templates/component.rb.erb
|
76
76
|
- lib/generators/hotwired_component/component/templates/component.scss.erb
|
77
77
|
- lib/generators/hotwired_component/component/templates/component_controller.js.erb
|
78
|
-
- lib/generators/hotwired_component/component/templates/
|
78
|
+
- lib/generators/hotwired_component/component/templates/component_test.rb.erb
|
79
79
|
- lib/generators/hotwired_component/install/USAGE
|
80
80
|
- lib/generators/hotwired_component/install/install_generator.rb
|
81
|
+
- lib/generators/hotwired_component/install/templates/application_component.rb.erb
|
81
82
|
- lib/hotwired_component.rb
|
82
83
|
- lib/hotwired_component/engine.rb
|
83
84
|
- lib/hotwired_component/version.rb
|