hotwired_component 0.2.0 → 0.3.0

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: e54c39d514ec1c512a060a3260142f8ceb8847055bc071c1a83a44a90da3e507
4
- data.tar.gz: dadfb497f35a9ed01ffbf236e4727cf529fcc2e7291c067a8c7df5f2cb71f7dc
3
+ metadata.gz: c154c7e2689c88350c38776f1582ba4e3a2ba58adb4252fa4adfa7dc21c50492
4
+ data.tar.gz: 640a49b20cedbefd567964dfa0637f32584d71cf263d63806c63293b46f831b3
5
5
  SHA512:
6
- metadata.gz: 6684a70a745b802a9b3096ed0b2ee38eba5534bc93c42998f654103ec473a44ac4b203ce25d1403a071e0aa902f9d311643ad3a78a502147cbaad1dd0a09d316
7
- data.tar.gz: '0822e71d8d76dcae04f099754ce20668235ba76ee52f52eb6445e1814476c7a1b6c6357f20f2c44c00a7b01f72e6a36337dec4b724a57066655df54fa3abd7f4'
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
- "component_spec.rb.erb",
52
- File.join("spec/components", class_path,
53
- "#{file_name}_component_spec.rb")
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
- run "rails hotwire:install"
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
- component_stylesheets.keys().map(component_stylesheets);
19
- JAVASCRIPT
9
+ def add_application_component
10
+ template "application_component.rb.erb",
11
+ "app/components/application_component.rb"
12
+ end
20
13
 
21
- end
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
@@ -0,0 +1,2 @@
1
+ class ApplicationComponent < ViewComponent::Base
2
+ end
@@ -2,6 +2,7 @@ require "hotwire-rails"
2
2
 
3
3
  require "hotwired_component/version"
4
4
  require "hotwired_component/engine"
5
+ require "view_component/engine"
5
6
 
6
7
  module HotwiredComponent
7
8
  # Your code goes here...
@@ -1,3 +1,3 @@
1
1
  module HotwiredComponent
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-04-26 00:00:00.000000000 Z
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/component_spec.rb.erb
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
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- require "rails_helper"
3
-
4
- RSpec.describe <%= class_name %>Component, type: :view do
5
- pending "add tests here"
6
- end