hotwire_crud 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hotwire_crud.gemspec +1 -1
- data/lib/generators/hotwire_crud/USAGE +8 -0
- data/lib/generators/hotwire_crud/hotwire_crud_generator.rb +37 -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 +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25f04e72ad847d12f99121934f13baaf8da963481b04628f6a76357d42f9820
|
4
|
+
data.tar.gz: 287751890a2a0621252beea80b0e49e124ad5ada68b5fa2a25daffa2d63eed66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b1edd548ae2dc3a89abc980a787af39e50bc9e96782703c70d3c95f8e2c119f1bc3017b9d19904bdc9584998c94df81a13bf03c13e478a9b53a1f5c83815ca6
|
7
|
+
data.tar.gz: 823d42026f4c4aa9607379e4a966c3f8696c627cca2fb34d577879446070eecd221b81c4406a766d0b8c438971533b297f6e53f214d15628478f8d55f1cc5038
|
data/hotwire_crud.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'hotwire_crud'
|
3
|
-
spec.version = '0.1.
|
3
|
+
spec.version = '0.1.2'
|
4
4
|
spec.summary = 'crud generator with hotwire approach and static routes'
|
5
5
|
spec.description = 'Crud generator with static routes which lazy loads content using content routes'
|
6
6
|
spec.authors = ['Umair Azam']
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class HotwireCrudGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path("templates", __dir__)
|
5
|
+
|
6
|
+
argument :actions, type: :array, default: %w[index edit new show]
|
7
|
+
|
8
|
+
def create_static_controller_file
|
9
|
+
template "static_controller.erb", File.join("app/controllers/static", "#{file_name}_controller.rb")
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_static_controller_test
|
13
|
+
template "static_controller_spec.erb", File.join("spec/controllers/static", "#{file_name}_controller_spec.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_controller_file
|
17
|
+
template "controller.erb", File.join("app/controllers", "#{file_name}_controller.rb")
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_controller_test
|
21
|
+
template "controller_spec.erb", File.join("spec/controllers", "#{file_name}_controller_spec.rb")
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_views
|
25
|
+
actions.each do |action|
|
26
|
+
template "views/static_#{action}.html.erb", File.join("app/views/static", file_name, "#{action}.html.haml")
|
27
|
+
template "views/#{action}.html.erb", File.join("app/views", file_name, "#{action}.html.haml")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def insert_routes
|
32
|
+
route "resources :#{file_name}, only: #{actions.map(&:to_sym).inspect}"
|
33
|
+
|
34
|
+
route_namespace = 'static'
|
35
|
+
route "namespace :#{route_namespace} do\n resources :#{file_name}, only: #{actions.map(&:to_sym).inspect}\nend"
|
36
|
+
end
|
37
|
+
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umair Azam
|
@@ -47,6 +47,20 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- hotwire_crud.gemspec
|
50
|
+
- lib/generators/hotwire_crud/USAGE
|
51
|
+
- lib/generators/hotwire_crud/hotwire_crud_generator.rb
|
52
|
+
- lib/generators/hotwire_crud/templates/controller.erb
|
53
|
+
- lib/generators/hotwire_crud/templates/controller_spec.erb
|
54
|
+
- lib/generators/hotwire_crud/templates/static_controller.erb
|
55
|
+
- lib/generators/hotwire_crud/templates/static_controller_spec.erb
|
56
|
+
- lib/generators/hotwire_crud/templates/views/edit.html.erb
|
57
|
+
- lib/generators/hotwire_crud/templates/views/index.html.erb
|
58
|
+
- lib/generators/hotwire_crud/templates/views/new.html.erb
|
59
|
+
- lib/generators/hotwire_crud/templates/views/show.html.erb
|
60
|
+
- lib/generators/hotwire_crud/templates/views/static_edit.html.erb
|
61
|
+
- lib/generators/hotwire_crud/templates/views/static_index.html.erb
|
62
|
+
- lib/generators/hotwire_crud/templates/views/static_new.html.erb
|
63
|
+
- lib/generators/hotwire_crud/templates/views/static_show.html.erb
|
50
64
|
homepage: https://github.com/omairrazam/hotwire_crud.git
|
51
65
|
licenses:
|
52
66
|
- MIT
|