hotwired_component 0.1.0

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: 53fe46ef3fafbc1eeb3ea15eaf5122a88e9ce66792292f9aa03b284f1ae9bb1e
4
+ data.tar.gz: 037be62c8b4f47abb5992b8a59698a30e74f1277a20b6ee95a3770a4932749f8
5
+ SHA512:
6
+ metadata.gz: 5a41c571d89f15a08a31fbb8348247da1999cf510e3af226d673f38abf215ce8642695840b4670a91280823cc51c1df6298060278d290d55879472a5ef53c179
7
+ data.tar.gz: df2271c1b826c3c0d1d02aac3255b98814a92bba3d4c262a16dd94a2180659e4114e7a73dd5ad9c26c4fb489736fa530f3e6ae1eb8f09344c04732010690ec9a
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Jarod Reid
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # HotwiredComponent
2
+ HotwiredComponent adds Hotwired centered generators for Github's ViewComponent
3
+
4
+ ## Usage
5
+
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'hotwired_component'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ ## License
20
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
File without changes
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Generates Hotwired compatible ViewComponents
3
+
4
+ Example:
5
+ bin/rails generate hc:component Thing
6
+
7
+ This will create:
8
+ - components/thing_component.rb
9
+ - components/thing/thing_component.scss
10
+ - components/thing/thing_component.html.erb
11
+ - components/thing/component_controller.js
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HotwiredComponent
4
+ ##
5
+ # Generates ViewComponents with Stimulus/Hotwire
6
+ class ComponentGenerator < Rails::Generators::NamedBase
7
+ source_root File.expand_path("templates", __dir__)
8
+
9
+ def create_component_file
10
+ template(
11
+ "component.rb.erb",
12
+ File.join("app/components", class_path, "#{file_name}_component.rb")
13
+ )
14
+ end
15
+
16
+ def create_scss_file
17
+ template(
18
+ "component.scss.erb",
19
+ File.join(
20
+ "app/components",
21
+ class_path,
22
+ "#{file_name}_component/#{file_name}_component.scss"
23
+ )
24
+ )
25
+ end
26
+
27
+ def create_template_file
28
+ create_file(
29
+ File.join(
30
+ "app/components",
31
+ class_path,
32
+ "#{file_name}_component/#{file_name}_component.html.erb"
33
+ ),
34
+ component_div
35
+ )
36
+ end
37
+
38
+ def create_javascript_file
39
+ template(
40
+ "component_controller.js.erb",
41
+ File.join(
42
+ "app/components",
43
+ class_path,
44
+ "#{file_name}_component/component_controller.js"
45
+ )
46
+ )
47
+ end
48
+
49
+ def create_test_file
50
+ template(
51
+ "component_spec.rb.erb",
52
+ File.join("spec/components", class_path,
53
+ "#{file_name}_component_spec.rb")
54
+ )
55
+ end
56
+
57
+ private
58
+
59
+ def css_class_name
60
+ "#{class_path.join('-')}-#{file_name}"
61
+ end
62
+
63
+ def component_div
64
+ "<div class=\"#{css_class_name}\" " \
65
+ "data-controller=\"#{class_path.join('--')}--" \
66
+ "#{file_name.dasherize}--component\">" \
67
+ "</div>"
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,6 @@
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 %>Component < ApplicationComponent
5
+ <%= " " * indent_level %>end<% class_name.split("::")[0..-2].length.times do %><% indent_level -= 2 %>
6
+ <%= " " * indent_level %>end<% end %>
@@ -0,0 +1,3 @@
1
+ .<%= css_class_name %> {
2
+
3
+ }
@@ -0,0 +1,4 @@
1
+ import {Controller} from "stimulus"
2
+
3
+ export default class extends Controller {
4
+ }
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,6 @@
1
+ require "hotwired_component/version"
2
+ require "hotwired_component/engine"
3
+
4
+ module HotwiredComponent
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ module HotwiredComponent
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module HotwiredComponent
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :hotwired_component do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hotwired_component
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - fugufish
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.3
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.1.3.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.1.3
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.1.3.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: view_component
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2'
47
+ description: Hotwire + ViewComponent
48
+ email:
49
+ - therealfugu@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - app/assets/config/hotwired_component_manifest.js
58
+ - config/routes.rb
59
+ - lib/generators/hotwired_component/component/USAGE
60
+ - lib/generators/hotwired_component/component/component_generator.rb
61
+ - lib/generators/hotwired_component/component/templates/component.rb.erb
62
+ - lib/generators/hotwired_component/component/templates/component.scss.erb
63
+ - lib/generators/hotwired_component/component/templates/component_controller.js.erb
64
+ - lib/generators/hotwired_component/component/templates/component_spec.rb.erb
65
+ - lib/hotwired_component.rb
66
+ - lib/hotwired_component/engine.rb
67
+ - lib/hotwired_component/version.rb
68
+ - lib/tasks/hotwired_component_tasks.rake
69
+ homepage: https://github.com/fugufish/hotwired_component
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.2.15
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Hotwire + ViewComponent
92
+ test_files: []