hotwire_crud 0.1.1 → 1.0.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 +4 -4
- data/hotwire_crud.gemspec +7 -3
- data/lib/generators/hotwire_crud/USAGE +8 -0
- data/lib/generators/hotwire_crud/hotwire_crud_generator.rb +55 -0
- data/lib/generators/hotwire_crud/templates/controller.erb +10 -0
- data/lib/generators/hotwire_crud/templates/controller_spec.erb +15 -0
- data/lib/generators/hotwire_crud/templates/static_controller.erb +8 -0
- data/lib/generators/hotwire_crud/templates/static_controller_spec.erb +15 -0
- data/lib/generators/hotwire_crud/templates/views/edit.html.erb +0 -0
- data/lib/generators/hotwire_crud/templates/views/index.html.erb +1 -0
- data/lib/generators/hotwire_crud/templates/views/new.html.erb +0 -0
- data/lib/generators/hotwire_crud/templates/views/show.html.erb +0 -0
- data/lib/generators/hotwire_crud/templates/views/static_edit.html.erb +0 -0
- data/lib/generators/hotwire_crud/templates/views/static_index.html.erb +1 -0
- data/lib/generators/hotwire_crud/templates/views/static_new.html.erb +0 -0
- data/lib/generators/hotwire_crud/templates/views/static_show.html.erb +0 -0
- metadata +34 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e28611e36f142b7cbc686342aa46add0584de857664561cb12da7c3ac9e9b7f
|
4
|
+
data.tar.gz: 7ce6fa2c4d1245df5231a4f70ad177049681e1aa9df714ef4da2f5b36a5e6492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e37b02588f1d5cfd9d974efa90858711c481451e59922648deba621e2cbf6d36c265bd81c59b7712cb6e66769f55e08dc2283aefad1ba965d507e4e6074f36a
|
7
|
+
data.tar.gz: dfd4ebb3f66e9d70de6f01923653f010484ebf2566b8ecad942fa250d43466703c059293f531deb62dfcb5ba8ae6e2982a997ad7e4de389a23ff433a2fe4ec56
|
data/hotwire_crud.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = 'hotwire_crud'
|
3
|
-
spec.version = '0.
|
5
|
+
spec.version = '1.0.0'
|
4
6
|
spec.summary = 'crud generator with hotwire approach and static routes'
|
5
7
|
spec.description = 'Crud generator with static routes which lazy loads content using content routes'
|
6
8
|
spec.authors = ['Umair Azam']
|
@@ -10,10 +12,12 @@ Gem::Specification.new do |spec|
|
|
10
12
|
|
11
13
|
spec.files = Dir['lib/**/*', 'templates/**/*', '*.gemspec']
|
12
14
|
spec.require_paths = ['lib']
|
13
|
-
|
15
|
+
spec.required_ruby_version = '3.1.2'
|
14
16
|
spec.add_runtime_dependency 'rails', '>= 6.0'
|
15
17
|
# Add other dependencies if needed
|
16
18
|
|
17
19
|
# Specify the custom generator file(s)
|
18
20
|
spec.add_development_dependency 'railties'
|
19
|
-
|
21
|
+
spec.add_development_dependency 'rubocop', '~> 1.0'
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A Rails generator that creates a CRUD (Create, Read, Update, Delete) controller
|
4
|
+
# with Hotwire support.
|
5
|
+
#
|
6
|
+
# This generator creates a controller file, view files, and sets up the
|
7
|
+
# routes for the CRUD operations. It is designed to be used with Hotwire
|
8
|
+
# for a more interactive and dynamic user interface.
|
9
|
+
#
|
10
|
+
# Usage:
|
11
|
+
# rails generate hotwire_crud resource_controller_name
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
# rails generate hotwire_crud products
|
15
|
+
#
|
16
|
+
# This will generate a Products controller with actions for index, show, new, edit,
|
17
|
+
# create, update, and destroy, along with corresponding view templates.
|
18
|
+
#
|
19
|
+
|
20
|
+
# lib/generators/hotwire_crud_generator.rb
|
21
|
+
class HotwireCrudGenerator < Rails::Generators::NamedBase
|
22
|
+
source_root File.expand_path('templates', __dir__)
|
23
|
+
|
24
|
+
argument :actions, type: :array, default: %w[index edit new show]
|
25
|
+
|
26
|
+
def create_static_controller_file
|
27
|
+
template 'static_controller.erb', File.join('app/controllers/static', "#{file_name}_controller.rb")
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_static_controller_test
|
31
|
+
template 'static_controller_spec.erb', File.join('spec/controllers/static', "#{file_name}_controller_spec.rb")
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_controller_file
|
35
|
+
template 'controller.erb', File.join('app/controllers', "#{file_name}_controller.rb")
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_controller_test
|
39
|
+
template 'controller_spec.erb', File.join('spec/controllers', "#{file_name}_controller_spec.rb")
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_views
|
43
|
+
actions.each do |action|
|
44
|
+
template "views/static_#{action}.html.erb", File.join('app/views/static', file_name, "#{action}.html.haml")
|
45
|
+
template "views/#{action}.html.erb", File.join('app/views', file_name, "#{action}.html.haml")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def insert_routes
|
50
|
+
route "resources :#{file_name}, only: #{actions.map(&:to_sym).inspect}"
|
51
|
+
|
52
|
+
route_namespace = 'static'
|
53
|
+
route "namespace :#{route_namespace} do\n resources :#{file_name}, only: #{actions.map(&:to_sym).inspect}\nend"
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe <%= "#{class_name}Controller" %>, type: :controller do
|
4
|
+
|
5
|
+
<% actions.each do |action|%>
|
6
|
+
describe 'GET #<%= action %>' do
|
7
|
+
it 'returns http success' do
|
8
|
+
get :<%= action %>
|
9
|
+
expect(response).to have_http_status(:success)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
# Define other tests here if needed
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe <%= "Static::#{class_name}Controller" %>, type: :controller do
|
4
|
+
|
5
|
+
<% actions.each do |action|%>
|
6
|
+
describe 'GET #<%= action %>' do
|
7
|
+
it 'returns http success' do
|
8
|
+
get :<%= action %>
|
9
|
+
expect(response).to have_http_status(:success)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
# Define other tests here if needed
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
%h hello index listing
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
%h hello static index listing
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotwire_crud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umair Azam
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
41
55
|
description: Crud generator with static routes which lazy loads content using content
|
42
56
|
routes
|
43
57
|
email:
|
@@ -47,26 +61,41 @@ extensions: []
|
|
47
61
|
extra_rdoc_files: []
|
48
62
|
files:
|
49
63
|
- hotwire_crud.gemspec
|
64
|
+
- lib/generators/hotwire_crud/USAGE
|
65
|
+
- lib/generators/hotwire_crud/hotwire_crud_generator.rb
|
66
|
+
- lib/generators/hotwire_crud/templates/controller.erb
|
67
|
+
- lib/generators/hotwire_crud/templates/controller_spec.erb
|
68
|
+
- lib/generators/hotwire_crud/templates/static_controller.erb
|
69
|
+
- lib/generators/hotwire_crud/templates/static_controller_spec.erb
|
70
|
+
- lib/generators/hotwire_crud/templates/views/edit.html.erb
|
71
|
+
- lib/generators/hotwire_crud/templates/views/index.html.erb
|
72
|
+
- lib/generators/hotwire_crud/templates/views/new.html.erb
|
73
|
+
- lib/generators/hotwire_crud/templates/views/show.html.erb
|
74
|
+
- lib/generators/hotwire_crud/templates/views/static_edit.html.erb
|
75
|
+
- lib/generators/hotwire_crud/templates/views/static_index.html.erb
|
76
|
+
- lib/generators/hotwire_crud/templates/views/static_new.html.erb
|
77
|
+
- lib/generators/hotwire_crud/templates/views/static_show.html.erb
|
50
78
|
homepage: https://github.com/omairrazam/hotwire_crud.git
|
51
79
|
licenses:
|
52
80
|
- MIT
|
53
|
-
metadata:
|
81
|
+
metadata:
|
82
|
+
rubygems_mfa_required: 'true'
|
54
83
|
post_install_message:
|
55
84
|
rdoc_options: []
|
56
85
|
require_paths:
|
57
86
|
- lib
|
58
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
88
|
requirements:
|
60
|
-
- -
|
89
|
+
- - '='
|
61
90
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
91
|
+
version: 3.1.2
|
63
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
93
|
requirements:
|
65
94
|
- - ">="
|
66
95
|
- !ruby/object:Gem::Version
|
67
96
|
version: '0'
|
68
97
|
requirements: []
|
69
|
-
rubygems_version: 3.3.
|
98
|
+
rubygems_version: 3.3.7
|
70
99
|
signing_key:
|
71
100
|
specification_version: 4
|
72
101
|
summary: crud generator with hotwire approach and static routes
|