hot-glue 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +12 -8
- data/lib/generators/hot_glue/markup_templates/erb.rb +7 -8
- data/lib/generators/hot_glue/markup_templates/haml.rb +13 -0
- data/lib/generators/hot_glue/scaffold_generator.rb +23 -46
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +1 -1
- data/lib/hotglue/version.rb +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea47eaaf1c1a9a92b6382e2dc41a5e9f119600cfd0f58bc8b8091c33e3ac48a
|
4
|
+
data.tar.gz: c9ebd867495aff539bbb53c7d1ecb09c5fd83cb00121a129eadfc96533647efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2022393514c059339cc9e4c163962501a48609f317ab7d3f4be3a00e467637d6dbb14757dadf9312569dedc6372a43f427e28b6c3b2638067bdc25ca4d23fe3d
|
7
|
+
data.tar.gz: 7a19916224effd9ad2726baf944b110083978ee8328588301f89c4c2ae4791bfad8fcbf5f37b9dc5844153cfe39432933a47e1f890b121b78372e5cdedbc5afc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -88,10 +88,13 @@ Instantly get a simple CRUD interface
|
|
88
88
|
end
|
89
89
|
```
|
90
90
|
|
91
|
-
- Install Bootstrap
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
- Install Bootstrap
|
92
|
+
- Bootstrap with Sprockets (Rails 5 or 7 default — Rails 6 custom)
|
93
|
+
- use twbs/bootstrap-rubygem gem
|
94
|
+
- see README for bootstrap-rubygem to install
|
95
|
+
|
96
|
+
Bootstrap with Webpack RAILS 6 ONLY:
|
97
|
+
- change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
|
95
98
|
- run `yarn add bootstrap`
|
96
99
|
- create a new file at `app/javascript/require_bootstrap.scss` with this content
|
97
100
|
```
|
@@ -102,11 +105,12 @@ Bootstrap with Webpack:
|
|
102
105
|
```
|
103
106
|
import 'require_bootstrap'
|
104
107
|
```
|
105
|
-
|
106
|
-
Bootstrap with Sprockets:
|
107
|
-
- use bootstrap-rubygem gem
|
108
|
-
- see README for bootstrap-rubygem to install
|
109
108
|
|
109
|
+
Bootstrap with Webpack for FOR RAILS 7 :
|
110
|
+
-- See this BLOG POST
|
111
|
+
https://jasonfleetwoodboldt.com/stepping-up-rails/rails-7-with-webpacker-and-bootstrap/
|
112
|
+
|
113
|
+
|
110
114
|
|
111
115
|
- Install Devise or implement your own authentication
|
112
116
|
(or only use --gd mode, see below)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module HotGlue
|
2
2
|
class ErbTemplate < TemplateBase
|
3
3
|
|
4
|
+
# include GeneratorHelper
|
4
5
|
attr_accessor :singular
|
5
6
|
|
6
7
|
def field_output(col, type = nil, width, col_identifier )
|
@@ -35,7 +36,7 @@ module HotGlue
|
|
35
36
|
|
36
37
|
if show_only.include?(col)
|
37
38
|
|
38
|
-
"#{col_identifier}{class: \"form-group
|
39
|
+
"#{col_identifier}{class: \"form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s}) %> \"}
|
39
40
|
= @#{singular}.#{col.to_s}
|
40
41
|
%label.form-text
|
41
42
|
#{col.to_s.humanize}\n"
|
@@ -56,15 +57,14 @@ module HotGlue
|
|
56
57
|
exit_message= "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
|
57
58
|
exit
|
58
59
|
end
|
59
|
-
display_column = derrive_reference_name(assoc.class_name)
|
60
|
+
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
<%= f.collection_select(:#{col.to_s}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control')
|
62
|
+
"<div class='#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{assoc_name.to_s}) %>' >
|
63
|
+
<%= f.collection_select(:#{col.to_s}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control') %>
|
64
64
|
<label class='small form-text text-muted'>#{col.to_s.humanize}</label></div>"
|
65
65
|
|
66
66
|
else
|
67
|
-
"<div class=\"#{col_identifier} form-group
|
67
|
+
"<div class=\"#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col}) %> \" >
|
68
68
|
<%= f.text_field :#{col.to_s}, value: #{singular}.#{col.to_s}, class: 'form-control', size: 4, type: 'number' %>
|
69
69
|
<label class='small form-text text-muted'>#{col.to_s.humanize}</label></div>"
|
70
70
|
|
@@ -156,8 +156,7 @@ module HotGlue
|
|
156
156
|
raise(HotGlue::Error,exit_message)
|
157
157
|
end
|
158
158
|
|
159
|
-
display_column = derrive_reference_name(assoc.class_name)
|
160
|
-
|
159
|
+
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
161
160
|
|
162
161
|
"<div class='#{col_identifer}'>
|
163
162
|
<%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module HotGlue
|
2
2
|
class HamlTemplate < TemplateBase
|
3
3
|
|
4
|
+
def text_area_output(col, field_length, col_identifier )
|
5
|
+
lines = field_length % 40
|
6
|
+
if lines > 5
|
7
|
+
lines = 5
|
8
|
+
end
|
9
|
+
|
10
|
+
"#{col_identifier}{class: \"form-group \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
11
|
+
= f.text_area :#{col.to_s}, class: 'form-control', cols: 40, rows: '#{lines}'
|
12
|
+
%label.form-text
|
13
|
+
#{col.to_s.humanize}\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
4
17
|
attr_accessor :singular
|
5
18
|
|
6
19
|
def field_output(col, type = nil, width, col_identifier )
|
@@ -10,56 +10,32 @@ module HotGlue
|
|
10
10
|
class Error < StandardError
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
display_column
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def text_area_output(col, field_length, col_identifier )
|
36
|
-
lines = field_length % 40
|
37
|
-
if lines > 5
|
38
|
-
lines = 5
|
39
|
-
end
|
40
|
-
|
41
|
-
"#{col_identifier}{class: \"form-group \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
42
|
-
= f.text_area :#{col.to_s}, class: 'form-control', cols: 40, rows: '#{lines}'
|
43
|
-
%label.form-text
|
44
|
-
#{col.to_s.humanize}\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
13
|
+
def self.derrive_reference_name(thing_as_string)
|
14
|
+
assoc_class = eval(thing_as_string)
|
15
|
+
|
16
|
+
if assoc_class.respond_to?("name")
|
17
|
+
display_column = "name"
|
18
|
+
elsif assoc_class.respond_to?("to_label")
|
19
|
+
display_column = "to_label"
|
20
|
+
elsif assoc_class.respond_to?("full_name")
|
21
|
+
display_column = "full_name"
|
22
|
+
elsif assoc_class.respond_to?("display_name")
|
23
|
+
display_column = "display_name"
|
24
|
+
elsif assoc_class.respond_to?("email")
|
25
|
+
display_column = "email"
|
26
|
+
else
|
27
|
+
raise("this should have been caught by the checker in the initializer")
|
28
|
+
# puts "*** Oops: Can't find any column to use as the display label for the #{assoc.name.to_s} association on the #{singular_class} model . TODO: Please implement just one of: 1) name, 2) to_label, 3) full_name, 4) display_name, or 5) email directly on your #{assoc.class_name} model (either as database field or model methods), then RERUN THIS GENERATOR. (If more than one is implemented, the field to use will be chosen based on the rank here, e.g., if name is present it will be used; if not, I will look for a to_label, etc)"
|
29
|
+
end
|
30
|
+
display_column
|
50
31
|
end
|
51
32
|
|
52
|
-
|
53
33
|
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
54
|
-
|
34
|
+
hook_for :form_builder, :as => :scaffold
|
55
35
|
|
56
36
|
source_root File.expand_path('templates', __dir__)
|
57
37
|
attr_accessor :path, :singular, :plural, :singular_class, :nest_with
|
58
38
|
|
59
|
-
|
60
|
-
include GeneratorHelper
|
61
|
-
|
62
|
-
|
63
39
|
class_option :singular, type: :string, default: nil
|
64
40
|
class_option :plural, type: :string, default: nil
|
65
41
|
class_option :singular_class, type: :string, default: nil
|
@@ -188,6 +164,8 @@ module HotGlue
|
|
188
164
|
end
|
189
165
|
end
|
190
166
|
|
167
|
+
@reference_name = HotGlue.derrive_reference_name(singular_class)
|
168
|
+
|
191
169
|
identify_object_owner
|
192
170
|
setup_fields
|
193
171
|
end
|
@@ -301,7 +279,6 @@ module HotGlue
|
|
301
279
|
|
302
280
|
def copy_controller_and_spec_files
|
303
281
|
@default_colspan = @columns.size
|
304
|
-
|
305
282
|
unless @specs_only
|
306
283
|
template "controller.rb.erb", File.join("#{'spec/dummy/' if Rails.env.test?}app/controllers#{namespace_with_dash}", "#{plural}_controller.rb")
|
307
284
|
if @namespace
|
@@ -432,13 +409,13 @@ module HotGlue
|
|
432
409
|
|
433
410
|
def new_path_name
|
434
411
|
|
435
|
-
base =
|
412
|
+
base = "new_#{@namespace+"_" if @namespace}#{(@nested_args.join("_") + "_") if @nested_args.any?}#{singular}_path"
|
436
413
|
if @nested_args.any?
|
437
414
|
base += "(" + @nested_args.collect { |arg|
|
438
415
|
"@#{arg}.id"
|
439
416
|
}.join(", ") + ")"
|
440
|
-
|
441
417
|
end
|
418
|
+
base
|
442
419
|
end
|
443
420
|
|
444
421
|
def nested_assignments
|
@@ -98,7 +98,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
98
98
|
visit <%= path_helper_plural %>
|
99
99
|
find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
|
100
100
|
|
101
|
-
expect(page).to have_content("Editing #{<%= singular
|
101
|
+
expect(page).to have_content("Editing #{<%= singular %>.<%= "abc" %>}")
|
102
102
|
<%=
|
103
103
|
@columns.map { |col|
|
104
104
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot-glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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-09-
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
- - "<="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 7.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.1'
|
30
|
+
- - "<="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 7.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: kaminari
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +102,7 @@ dependencies:
|
|
96
102
|
version: '2.16'
|
97
103
|
description: Simple, plug & play Rails scaffold building companion for Turbo-Rails
|
98
104
|
and Hotwire
|
99
|
-
email:
|
105
|
+
email: code@jasonfb.net
|
100
106
|
executables: []
|
101
107
|
extensions: []
|
102
108
|
extra_rdoc_files: []
|
@@ -162,7 +168,7 @@ files:
|
|
162
168
|
- lib/hot-glue.rb
|
163
169
|
- lib/hotglue/engine.rb
|
164
170
|
- lib/hotglue/version.rb
|
165
|
-
homepage: https://
|
171
|
+
homepage: https://jasonfleetwoodboldt.com/hot-glue/
|
166
172
|
licenses:
|
167
173
|
- Nonstandard
|
168
174
|
metadata:
|