hot-glue 0.3.9 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +2 -1
- data/Gemfile +4 -4
- data/Gemfile.lock +17 -17
- data/README.md +811 -0
- data/config/database.yml +83 -8
- data/config/hot_glue.yml +3 -0
- data/db/schema.rb +3 -3
- data/lib/generators/hot_glue/helpers.rb +13 -0
- data/lib/generators/hot_glue/install_generator.rb +48 -13
- data/lib/generators/hot_glue/layout/builder.rb +115 -0
- data/lib/generators/hot_glue/markup_templates/erb.rb +158 -180
- data/lib/generators/hot_glue/markup_templates/haml.rb +7 -2
- data/lib/generators/hot_glue/scaffold_generator.rb +119 -77
- data/lib/generators/hot_glue/templates/capybara_login.rb +3 -3
- data/lib/generators/hot_glue/templates/erb/_form.erb +1 -1
- data/lib/generators/hot_glue/templates/erb/_list.erb +11 -13
- data/lib/generators/hot_glue/templates/erb/_show.erb +10 -8
- data/lib/generators/hot_glue/templates/erb/index.erb +2 -0
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +65 -41
- data/lib/hotglue/version.rb +1 -1
- metadata +8 -25
- data/db/migrate/20210306212711_create_abcs.rb +0 -11
- data/db/migrate/20210306223300_create_defs.rb +0 -9
- data/db/migrate/20210306223305_create_ghis.rb +0 -9
- data/db/migrate/20210306223309_create_jkls.rb +0 -9
- data/db/migrate/20210306223701_devise_create_users.rb +0 -44
- data/db/migrate/20210306225506_create_xyzs.rb +0 -9
@@ -2,19 +2,20 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe "interaction for <%= controller_class_name %>", type: :feature do
|
4
4
|
include HotGlue::ControllerHelper
|
5
|
+
<%= @existing_content %>
|
5
6
|
<% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<%end%>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
else
|
7
|
+
<%= (@columns - @show_only).map { |col|
|
8
|
+
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
9
|
+
case type
|
10
|
+
when :integer
|
11
|
+
if col.to_s.ends_with?("_id")
|
12
|
+
assoc = "#{col.to_s.gsub('_id','')}"
|
13
|
+
"let!(:#{assoc}1) {create(:#{assoc})}"
|
15
14
|
end
|
16
|
-
|
17
|
-
|
15
|
+
else
|
16
|
+
end
|
17
|
+
}.compact.join("\n")
|
18
|
+
%>
|
18
19
|
<% item1_addOns = ""
|
19
20
|
if (eval(@singular_class).instance_methods.include?(display_class.to_s))
|
20
21
|
item1_addOns << "#{display_class}: FFaker::Name.name"
|
@@ -24,7 +25,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
24
25
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
25
26
|
case type
|
26
27
|
when :string
|
27
|
-
"#{col}: FFaker::Movie.title"
|
28
|
+
(col.to_s.include?('email') ? "#{col}: FFaker::Internet.email" : "#{col}: FFaker::Movie.title")
|
28
29
|
when :text
|
29
30
|
"#{col}: FFaker::Lorem.paragraphs(10).join(" ")"
|
30
31
|
|
@@ -40,7 +41,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
40
41
|
"#{col}: DateTime.current + rand(1000).seconds"
|
41
42
|
when :integer
|
42
43
|
if col.to_s.ends_with?("_id")
|
43
|
-
#
|
44
|
+
"#{col.to_s.gsub('_id','')}: #{col.to_s.gsub('_id','')}1"
|
44
45
|
else
|
45
46
|
"#{col}: rand(100)"
|
46
47
|
end
|
@@ -65,6 +66,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
65
66
|
if !col.ends_with?("_id")
|
66
67
|
" " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
|
67
68
|
end
|
69
|
+
else
|
70
|
+
" " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
|
68
71
|
end
|
69
72
|
|
70
73
|
}.join("\n")
|
@@ -79,9 +82,16 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
79
82
|
expect(page).to have_selector(:xpath, './/h3[contains(., "New <%= singular.titlecase %>")]')
|
80
83
|
|
81
84
|
<%=
|
82
|
-
@columns.map { |col|
|
85
|
+
(@columns - @show_only).map { |col|
|
83
86
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
84
87
|
case type
|
88
|
+
when :date
|
89
|
+
" " + "new_#{col} = Date.current + (rand(100).days) \n" +
|
90
|
+
' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
91
|
+
when :time
|
92
|
+
# " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
93
|
+
# ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
94
|
+
|
85
95
|
when :datetime
|
86
96
|
" " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
87
97
|
' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
@@ -106,9 +116,18 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
106
116
|
when :boolean
|
107
117
|
" new_#{col} = rand(2).floor \n" +
|
108
118
|
" find(\"[name='#{singular}[#{col}]'][value='\#{new_" + col.to_s + "}']\").choose"
|
109
|
-
|
119
|
+
when :string
|
120
|
+
if col.to_s.include?("email")
|
121
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
122
|
+
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
123
|
+
|
124
|
+
else
|
110
125
|
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
111
126
|
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
127
|
+
end
|
128
|
+
when :text
|
129
|
+
" " + "new_#{col} = FFaker::Lorem.paragraphs(1).join("") \n" +
|
130
|
+
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
112
131
|
end
|
113
132
|
|
114
133
|
}.join("\n")
|
@@ -116,17 +135,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
116
135
|
%>
|
117
136
|
click_button "Save"
|
118
137
|
expect(page).to have_content("Successfully created")
|
138
|
+
<%=" " +
|
119
139
|
|
120
|
-
|
121
|
-
@columns.map { |col|
|
140
|
+
(@columns - @show_only).map { |col|
|
122
141
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
123
142
|
|
124
143
|
case type
|
125
144
|
when :datetime
|
126
|
-
|
127
|
-
new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
|
128
|
-
new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
|
129
|
-
timezonize(current_timezone))"
|
145
|
+
# " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
|
146
|
+
# new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
|
147
|
+
# new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
|
148
|
+
# timezonize(current_timezone))"
|
130
149
|
when :integer
|
131
150
|
if col.to_s.ends_with?("_id")
|
132
151
|
# shoould the assoication be on here
|
@@ -139,28 +158,29 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
139
158
|
|
140
159
|
}.compact.join("\n ")
|
141
160
|
%>
|
142
|
-
|
143
161
|
end
|
144
162
|
end<% end %>
|
145
163
|
|
146
|
-
|
164
|
+
<% unless @no_edit %>
|
147
165
|
describe "edit & update" do
|
148
166
|
it "should return an editable form" do
|
149
167
|
visit <%= path_helper_plural %>
|
150
168
|
find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
|
151
169
|
|
152
|
-
expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class
|
170
|
+
expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %>.squish || "(no name)"}")
|
153
171
|
<%=
|
154
|
-
@columns.map { |col|
|
172
|
+
(@columns - @show_only).map { |col|
|
155
173
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
156
174
|
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
|
157
175
|
sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
|
158
176
|
case type
|
159
177
|
when :datetime
|
178
|
+
" new_#{col} = DateTime.current + 1.day \n" +
|
179
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
|
160
180
|
when :integer
|
161
181
|
if !col.to_s.ends_with?("_id")
|
162
|
-
"
|
163
|
-
"
|
182
|
+
" new_#{col} = rand(10000).floor \n" +
|
183
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
|
164
184
|
end
|
165
185
|
when :text
|
166
186
|
if sql_type == "text"
|
@@ -172,12 +192,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
172
192
|
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
173
193
|
end
|
174
194
|
when :string
|
175
|
-
|
176
|
-
|
177
|
-
|
195
|
+
|
196
|
+
if col.to_s.include?("email")
|
197
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
198
|
+
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
199
|
+
|
200
|
+
elsif sql_type == "varchar"
|
201
|
+
" " + "new_#{col.to_s} = FFaker::Name.name \n" +
|
202
|
+
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
178
203
|
else
|
179
|
-
|
180
|
-
|
204
|
+
" " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
|
205
|
+
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
181
206
|
end
|
182
207
|
when :boolean
|
183
208
|
" new_#{col} = rand(2).floor \n" +
|
@@ -186,11 +211,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
186
211
|
" new_#{col} = rand(1)*5000 \n" +
|
187
212
|
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
|
188
213
|
when :date
|
189
|
-
"
|
190
|
-
"
|
214
|
+
" new_#{col} = Date.current + rand(100).days \n" +
|
215
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
|
191
216
|
when :time
|
192
217
|
" new_#{col} = Time.current + rand(144).hours \n" +
|
193
218
|
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
|
219
|
+
when :datetime
|
220
|
+
" new_#{col} = DateTime.current + rand(1000).minutes \n" +
|
221
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
|
222
|
+
|
194
223
|
when :enum
|
195
224
|
" list_of_#{col.to_s} = #{singular_class}.defined_enums['#{col.to_s}'].keys \n" +
|
196
225
|
" " + "new_#{col.to_s} = list_of_#{col.to_s}[rand(list_of_#{col.to_s}.length)].to_s \n" +
|
@@ -205,10 +234,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
205
234
|
%>
|
206
235
|
click_button "Save"
|
207
236
|
within("turbo-frame#<%= singular %>__#{<%= singular %>1.id} ") do
|
208
|
-
|
209
|
-
|
210
237
|
<%=
|
211
|
-
@columns.map { |col|
|
238
|
+
(@columns - @show_only).map { |col|
|
212
239
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
213
240
|
case type
|
214
241
|
when :datetime
|
@@ -226,10 +253,9 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
226
253
|
end
|
227
254
|
}.compact.join("\n")
|
228
255
|
%>
|
229
|
-
|
230
256
|
end
|
231
257
|
end
|
232
|
-
end
|
258
|
+
end <% end %>
|
233
259
|
|
234
260
|
<% unless @no_delete %> describe "destroy" do
|
235
261
|
it "should destroy" do
|
@@ -237,8 +263,6 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
237
263
|
accept_alert do
|
238
264
|
find("form[action='<%= namespace_with_dash %>/<%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
|
239
265
|
end
|
240
|
-
# find("form[action='<%= namespace_with_dash %>/<%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
|
241
|
-
|
242
266
|
expect(page).to_not have_content(<%= singular %>1.<%= @display_class %>)
|
243
267
|
expect(<%= singular_class %>.where(id: <%= singular %>1.id).count).to eq(0)
|
244
268
|
end
|
data/lib/hotglue/version.rb
CHANGED
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.3
|
4
|
+
version: 0.4.3
|
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:
|
11
|
+
date: 2022-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.1'
|
20
20
|
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 7
|
22
|
+
version: '7'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.1'
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 7
|
32
|
+
version: '7'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: kaminari
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.2'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: turbo-rails
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.5'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.5'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: sass-rails
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,14 +93,11 @@ files:
|
|
107
93
|
- app/views/layouts/_flash_notices.erb
|
108
94
|
- bin/rails
|
109
95
|
- config/database.yml
|
110
|
-
-
|
111
|
-
- db/migrate/20210306223300_create_defs.rb
|
112
|
-
- db/migrate/20210306223305_create_ghis.rb
|
113
|
-
- db/migrate/20210306223309_create_jkls.rb
|
114
|
-
- db/migrate/20210306223701_devise_create_users.rb
|
115
|
-
- db/migrate/20210306225506_create_xyzs.rb
|
96
|
+
- config/hot_glue.yml
|
116
97
|
- db/schema.rb
|
98
|
+
- lib/generators/hot_glue/helpers.rb
|
117
99
|
- lib/generators/hot_glue/install_generator.rb
|
100
|
+
- lib/generators/hot_glue/layout/builder.rb
|
118
101
|
- lib/generators/hot_glue/markup_templates/base.rb
|
119
102
|
- lib/generators/hot_glue/markup_templates/erb.rb
|
120
103
|
- lib/generators/hot_glue/markup_templates/haml.rb
|
@@ -164,7 +147,7 @@ files:
|
|
164
147
|
- lib/hotglue/version.rb
|
165
148
|
homepage: https://jasonfleetwoodboldt.com/hot-glue/
|
166
149
|
licenses:
|
167
|
-
-
|
150
|
+
- Commercial with free option
|
168
151
|
metadata:
|
169
152
|
source_code_uri: https://github.com/jasonfb/hot-glue
|
170
153
|
tutorial: https://jfbcodes.com/hot-glue-tutorial
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class DeviseCreateUsers < ActiveRecord::Migration[6.1]
|
4
|
-
def change
|
5
|
-
create_table :users do |t|
|
6
|
-
## Database authenticatable
|
7
|
-
t.string :email, null: false, default: ""
|
8
|
-
t.string :encrypted_password, null: false, default: ""
|
9
|
-
|
10
|
-
## Recoverable
|
11
|
-
t.string :reset_password_token
|
12
|
-
t.datetime :reset_password_sent_at
|
13
|
-
|
14
|
-
## Rememberable
|
15
|
-
t.datetime :remember_created_at
|
16
|
-
|
17
|
-
## Trackable
|
18
|
-
# t.integer :sign_in_count, default: 0, null: false
|
19
|
-
# t.datetime :current_sign_in_at
|
20
|
-
# t.datetime :last_sign_in_at
|
21
|
-
# t.string :current_sign_in_ip
|
22
|
-
# t.string :last_sign_in_ip
|
23
|
-
|
24
|
-
## Confirmable
|
25
|
-
# t.string :confirmation_token
|
26
|
-
# t.datetime :confirmed_at
|
27
|
-
# t.datetime :confirmation_sent_at
|
28
|
-
# t.string :unconfirmed_email # Only if using reconfirmable
|
29
|
-
|
30
|
-
## Lockable
|
31
|
-
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
32
|
-
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
33
|
-
# t.datetime :locked_at
|
34
|
-
|
35
|
-
|
36
|
-
t.timestamps null: false
|
37
|
-
end
|
38
|
-
|
39
|
-
add_index :users, :email, unique: true
|
40
|
-
add_index :users, :reset_password_token, unique: true
|
41
|
-
# add_index :users, :confirmation_token, unique: true
|
42
|
-
# add_index :users, :unlock_token, unique: true
|
43
|
-
end
|
44
|
-
end
|