hot-glue 0.0.2 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -7
  3. data/Gemfile +4 -9
  4. data/Gemfile.lock +42 -22
  5. data/README.md +140 -30
  6. data/Rakefile +1 -1
  7. data/app/assets/config/manifest.js +0 -0
  8. data/bin/rails +2 -2
  9. data/config/database.yml +11 -0
  10. data/db/migrate/20210306212711_create_abcs.rb +11 -0
  11. data/db/migrate/20210306223300_create_defs.rb +9 -0
  12. data/db/migrate/20210306223305_create_hgis.rb +9 -0
  13. data/db/migrate/20210306223309_create_jkls.rb +9 -0
  14. data/db/migrate/20210306223701_devise_create_users.rb +44 -0
  15. data/db/migrate/20210306225506_create_xyzs.rb +9 -0
  16. data/db/schema.rb +60 -0
  17. data/lib/generators/hot_glue/install_generator.rb +3 -3
  18. data/lib/generators/hot_glue/scaffold_generator.rb +250 -138
  19. data/lib/generators/hot_glue/templates/_errors.haml +6 -5
  20. data/lib/generators/hot_glue/templates/_flash_notices.haml +7 -6
  21. data/lib/generators/hot_glue/templates/_line.haml +1 -1
  22. data/lib/generators/hot_glue/templates/_list.haml +4 -2
  23. data/lib/generators/hot_glue/templates/_new_button.haml +1 -1
  24. data/lib/generators/hot_glue/templates/_new_form.haml +10 -0
  25. data/lib/generators/hot_glue/templates/_show.haml +1 -1
  26. data/lib/generators/hot_glue/templates/{base_controller.rb → base_controller.rb.erb} +0 -0
  27. data/lib/generators/hot_glue/templates/{controller.rb → controller.rb.erb} +11 -7
  28. data/lib/generators/hot_glue/templates/create.turbo_stream.haml +12 -3
  29. data/lib/generators/hot_glue/templates/edit.haml +2 -0
  30. data/lib/generators/hot_glue/templates/index.haml +1 -1
  31. data/lib/generators/hot_glue/templates/new.haml +1 -10
  32. data/lib/generators/hot_glue/templates/{controller_spec.rb → request_spec.rb.erb} +0 -0
  33. data/lib/generators/hot_glue/templates/system_spec.rb.erb +109 -0
  34. data/lib/hotglue/version.rb +1 -1
  35. metadata +17 -6
@@ -1,5 +1,6 @@
1
- - if resource.errors.any?
2
- #error_explanation
3
- - resource.errors.full_messages.each do |message|
4
- %div.alert.alert-danger
5
- = message
1
+ = turbo_frame_tag "errors" do
2
+ - if resource.errors.any?
3
+ #error_explanation
4
+ - resource.errors.full_messages.each do |message|
5
+ %div.alert.alert-danger
6
+ = message
@@ -1,7 +1,8 @@
1
- - unless notice.nil?
2
- %div.alert.alert-notice.alert-dismissible
3
- = notice
1
+ = turbo_frame_tag "flash_notices" do
2
+ - unless notice.nil?
3
+ %div.alert.alert-notice.alert-dismissible
4
+ = notice
4
5
 
5
- - unless alert.nil?
6
- %div.alert.alert-danger.alert-dismissible
7
- = alert
6
+ - unless alert.nil?
7
+ %div.alert.alert-danger.alert-dismissible
8
+ = alert
@@ -1,6 +1,6 @@
1
1
  = turbo_frame_tag "<%= singular %>__#{<%= singular %>.id}" do
2
2
  .row{'data-id': <%= singular %>.id, 'data-edit': 'false'}
3
- = render partial: "show", locals: {<%= singular %>: <%= singular %>}
3
+ = render partial: "<%= show_path_partial %>", locals: {<%= singular %>: <%= singular %>}
4
4
 
5
5
 
6
6
 
@@ -1,9 +1,11 @@
1
1
  = turbo_frame_tag "<%= plural %>-list" do
2
- .container.<%= singular %>-table
2
+ .container-fluid.<%= singular %>-table
3
3
  .row
4
4
  <%= list_column_headings %>
5
- %div.tbody
5
+ .col
6
+ %div
6
7
  - if <%= plural %>.empty?
7
8
  None
8
9
  - <%= plural %>.each do |<%= singular %>|
9
10
  = render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %> <%= nested_assignments_with_leading_comma %> }
11
+ <%= @no_paginate ? "" : paginate %>
@@ -1,2 +1,2 @@
1
1
  = turbo_frame_tag "<%= singular %>-new" do
2
- = link_to "New <%= singular.titleize %>", new_<%= singular %>_path(), disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right"
2
+ = link_to "New <%= singular.titlecase %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right"
@@ -0,0 +1,10 @@
1
+ = turbo_frame_tag "<%= singular %>-new" do
2
+ %h3
3
+ New <%= singular.titlecase %>
4
+
5
+ = form_with model: <%= singular %>, url: <%= path_helper_plural %>(<%= nested_objects_arity %>), method: "post" do |f|
6
+ = render partial: "<%=namespace_with_slash%><%= @plural %>/form", locals: {<%= singular %>: <%= singular %>, f: f}
7
+
8
+ .row
9
+ .col-md-12
10
+ = f.submit "Save", class: "btn btn-primary pull-right"
@@ -4,4 +4,4 @@
4
4
  = link_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe, <%= path_helper_full %>(<%= path_helper_args %>), method: :delete, data: {confirm: 'Are you sure?'}, disable_with: "Loading...", class: "delete-<%= singular %>-button btn btn-primary "
5
5
  <% end %>
6
6
  &nbsp;
7
- = link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_full %>(<%= path_helper_args %>), disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary "
7
+ = link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_full %>(<%= path_helper_args %>), <% if @big_edit %>'data-turbo' => 'false', <% end %>disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary "
@@ -1,5 +1,5 @@
1
1
  class <%= controller_class_name %> < <%= controller_descends_from %>
2
- <% unless @auth_identifier == '' || @auth.nil? %>before_action :authenticate_<%= auth_identifier %>!<% end %>
2
+ <% unless @auth_identifier == '' || @auth.nil? %>before_action :authenticate_<%= @auth_identifier %>!<% end %>
3
3
  <% if any_nested? %> <% @nested_args.each do |arg| %>
4
4
  before_action :load_<%= arg %><% end %> <% end %>
5
5
  before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
@@ -52,14 +52,18 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
52
52
  @<%=singular_name %> = <%=class_name %>.create(modified_params)
53
53
 
54
54
  if @<%= singular_name %>.save
55
-
55
+ flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
56
+ load_all_<%= plural %>
57
+ respond_to do |format|
58
+ format.turbo_stream
59
+ format.html { redirect_to <%= plural %>_path }
60
+ end
56
61
  else
57
62
  flash[:alert] = "Oops, your <%= singular_name %> could not be created."
58
- end
59
- load_all_<%= plural %>
60
- respond_to do |format|
61
- format.turbo_stream
62
- format.html { redirect_to <%= plural %>_path }
63
+ respond_to do |format|
64
+ format.turbo_stream
65
+ format.html
66
+ end
63
67
  end
64
68
  end<% end %>
65
69
 
@@ -1,5 +1,14 @@
1
- = turbo_stream.replace "<%= plural %>-list" do
2
- = render partial: "list", locals: {<%= plural %>: @<%= plural %>}
1
+ - if @<%= singular %>.errors.none?
2
+ = turbo_stream.replace "<%= plural %>-list" do
3
+ = render partial: "list", locals: {<%= plural %>: @<%= plural %>}
3
4
 
4
5
  = turbo_stream.replace "<%= singular %>-new" do
5
- = render partial: "new_button"
6
+ - if @<%= singular %>.errors.none?
7
+ = render partial: "new_button"
8
+ - else
9
+ = render partial: "new_form", locals: {<%= singular %>: @<%= singular %>}
10
+
11
+ = turbo_stream.replace "flash_notices" do
12
+ = render partial: "layouts/flash_notices"
13
+ - if @<%= singular %>.errors.any?
14
+ = render partial: "errors", locals: {resource: @<%= singular %>}
@@ -1,3 +1,5 @@
1
+ = link_to "<i class='fa fa-arrow-circle-left 2x'></i> Back to list".html_safe, <%= path_helper_plural %>
2
+
1
3
  = turbo_frame_tag "<%= singular %>__#{<%= "@" + singular %>.id}" do
2
4
  .cell.editable{style: "position: relative;"}
3
5
  - if <%="@" + singular%>.errors.any?
@@ -3,7 +3,7 @@
3
3
  .col-md-12
4
4
  = render partial: "new_button"
5
5
  .clearfix
6
- = render partial: "<%= plural %>/list", locals: {<%= plural %>: @<%= plural %>}
6
+ = render partial: "<%= list_path_partial %>", locals: {<%= plural %>: @<%= plural %>}
7
7
 
8
8
 
9
9
 
@@ -1,10 +1 @@
1
- = turbo_frame_tag "<%= singular %>-new" do
2
- %h3
3
- New <%= singular.titlecase %>
4
-
5
- = form_with model: @invoice, url: <%= path_helper_plural %>(<%= nested_objects_arity %>), method: "post" do |f|
6
- = render partial: "<%=namespace_with_slash%><%= @plural %>/form", locals: {<%= singular %>: @<%= singular %>, f: f}
7
-
8
- .row
9
- .col-md-12
10
- = f.submit "Save", class: "btn btn-primary pull-right"
1
+ = render partial: "new_form", locals: {<%=singular%>: @<%=singular%>}
@@ -0,0 +1,109 @@
1
+ require 'rails_helper'
2
+
3
+ describe "interaction for <%= controller_class_name %>", type: :feature do
4
+ <% unless @auth.nil? %> let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<%end%>
5
+ let(:<%= singular %>) {create(:<%= singular %><%= object_parent_mapping_as_argument_for_specs %> )}
6
+
7
+ <%= objest_nest_factory_setup %>
8
+
9
+ before(:each) do
10
+ @request.env["devise.mapping"] = Devise.mappings[:account]
11
+
12
+ sign_in <%= @auth %>, scope: :<%= @auth %>
13
+ end
14
+
15
+ describe "index" do
16
+ it "should respond" do
17
+ get :index, xhr: true, format: 'js', params: {
18
+ <%= objest_nest_params_by_id_for_specs %>
19
+ }
20
+ end
21
+ end
22
+
23
+ describe "new" do
24
+ it "should show form" do
25
+ get :new, xhr: true, format: 'js', params: {
26
+ <%= objest_nest_params_by_id_for_specs %>
27
+ }
28
+ end
29
+ end
30
+
31
+ describe "create" do
32
+ it "should create a new <%= singular %>" do
33
+ expect {
34
+ post :create, xhr: true, format: 'js', params: {
35
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
36
+ <%= singular %>: {
37
+ <%= columns_spec_with_sample_data %>
38
+ }}
39
+ }.to change { <%= @singular_class %>.all.count }.by(1)
40
+ assert_response :ok
41
+ end
42
+
43
+ # it "should not create if there are errors" do
44
+ # post :create, xhr: true, format: 'js', params: {id: <%= singular %>.id,
45
+ # <%= singular %>: {skin_id: nil}}
46
+ #
47
+ # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
48
+ # end
49
+ end
50
+
51
+ describe "edit" do
52
+ it "should return an editable form" do
53
+ get :edit, xhr: true, format: 'js', params: {
54
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
55
+ id: <%= singular %>.id
56
+ }
57
+ assert_response :ok
58
+ end
59
+ end
60
+
61
+ describe "show" do
62
+ it "should return a view form" do
63
+ get :show, xhr: true, format: 'js', params: {
64
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
65
+ id: <%= singular %>.id
66
+ }
67
+ assert_response :ok
68
+ end
69
+ end
70
+
71
+ describe "update" do
72
+ it "should update" do
73
+ put :update, xhr: true, format: 'js',
74
+ params: {
75
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
76
+ id: <%= singular %>.id,
77
+ <%= singular %>: {
78
+ <%= columns_spec_with_sample_data %>
79
+ }}
80
+
81
+ assert_response :ok
82
+ end
83
+
84
+ # it "should not update if invalid" do
85
+ # put :update, xhr: true, format: 'js',
86
+ # params: {
87
+ # id: <%= singular %>.id,
88
+ # <%= singular %>: {
89
+ # <%= columns_spec_with_sample_data %>
90
+ # }}
91
+ #
92
+ # assert_response :ok
93
+ #
94
+ # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
95
+ # end
96
+ end
97
+
98
+ describe "#destroy" do
99
+ it "should destroy" do
100
+ post :destroy, format: 'js', params: {
101
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
102
+ id: <%= singular %>.id
103
+ }
104
+ assert_response :ok
105
+ expect(<%= @singular_class %>.count).to be(0)
106
+ end
107
+ end
108
+ end
109
+
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-glue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2021-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,9 +108,18 @@ files:
108
108
  - LICENCE
109
109
  - README.md
110
110
  - Rakefile
111
+ - app/assets/config/manifest.js
111
112
  - app/helpers/hot_glue/controller_helper.rb
112
113
  - app/helpers/hot_glue_helper.rb
113
114
  - bin/rails
115
+ - config/database.yml
116
+ - db/migrate/20210306212711_create_abcs.rb
117
+ - db/migrate/20210306223300_create_defs.rb
118
+ - db/migrate/20210306223305_create_hgis.rb
119
+ - db/migrate/20210306223309_create_jkls.rb
120
+ - db/migrate/20210306223701_devise_create_users.rb
121
+ - db/migrate/20210306225506_create_xyzs.rb
122
+ - db/schema.rb
114
123
  - lib/generators/hot_glue/install_generator.rb
115
124
  - lib/generators/hot_glue/scaffold_generator.rb
116
125
  - lib/generators/hot_glue/templates/_errors.haml
@@ -119,16 +128,18 @@ files:
119
128
  - lib/generators/hot_glue/templates/_line.haml
120
129
  - lib/generators/hot_glue/templates/_list.haml
121
130
  - lib/generators/hot_glue/templates/_new_button.haml
131
+ - lib/generators/hot_glue/templates/_new_form.haml
122
132
  - lib/generators/hot_glue/templates/_show.haml
123
- - lib/generators/hot_glue/templates/base_controller.rb
124
- - lib/generators/hot_glue/templates/controller.rb
125
- - lib/generators/hot_glue/templates/controller_spec.rb
133
+ - lib/generators/hot_glue/templates/base_controller.rb.erb
134
+ - lib/generators/hot_glue/templates/controller.rb.erb
126
135
  - lib/generators/hot_glue/templates/create.turbo_stream.haml
127
136
  - lib/generators/hot_glue/templates/destroy.turbo_stream.haml
128
137
  - lib/generators/hot_glue/templates/edit.haml
129
138
  - lib/generators/hot_glue/templates/edit.turbo_stream.haml
130
139
  - lib/generators/hot_glue/templates/index.haml
131
140
  - lib/generators/hot_glue/templates/new.haml
141
+ - lib/generators/hot_glue/templates/request_spec.rb.erb
142
+ - lib/generators/hot_glue/templates/system_spec.rb.erb
132
143
  - lib/generators/hot_glue/templates/update.turbo_stream.haml
133
144
  - lib/hot-glue.rb
134
145
  - lib/hotglue/engine.rb
@@ -171,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
182
  - !ruby/object:Gem::Version
172
183
  version: '0'
173
184
  requirements: []
174
- rubygems_version: 3.0.8
185
+ rubygems_version: 3.2.11
175
186
  signing_key:
176
187
  specification_version: 4
177
188
  summary: A gem build scaffolding.