hot-glue 0.0.3 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -1
  3. data/.gitignore +12 -7
  4. data/Gemfile +4 -9
  5. data/Gemfile.lock +40 -23
  6. data/README.md +123 -31
  7. data/Rakefile +1 -1
  8. data/app/assets/config/manifest.js +0 -0
  9. data/bin/rails +2 -2
  10. data/config/database.yml +11 -0
  11. data/db/migrate/20210306212711_create_abcs.rb +11 -0
  12. data/db/migrate/20210306223300_create_defs.rb +9 -0
  13. data/db/migrate/20210306223305_create_hgis.rb +9 -0
  14. data/db/migrate/20210306223309_create_jkls.rb +9 -0
  15. data/db/migrate/20210306223701_devise_create_users.rb +44 -0
  16. data/db/migrate/20210306225506_create_xyzs.rb +9 -0
  17. data/db/schema.rb +60 -0
  18. data/lib/generators/hot_glue/install_generator.rb +3 -3
  19. data/lib/generators/hot_glue/scaffold_generator.rb +230 -138
  20. data/lib/generators/hot_glue/templates/_errors.haml +6 -5
  21. data/lib/generators/hot_glue/templates/_flash_notices.haml +7 -6
  22. data/lib/generators/hot_glue/templates/_new_form.haml +10 -0
  23. data/lib/generators/hot_glue/templates/_show.haml +1 -1
  24. data/lib/generators/hot_glue/templates/{base_controller.rb → base_controller.rb.erb} +0 -0
  25. data/lib/generators/hot_glue/templates/{controller.rb → controller.rb.erb} +11 -7
  26. data/lib/generators/hot_glue/templates/create.turbo_stream.haml +12 -3
  27. data/lib/generators/hot_glue/templates/edit.haml +2 -0
  28. data/lib/generators/hot_glue/templates/new.haml +1 -10
  29. data/lib/generators/hot_glue/templates/{controller_spec.rb → request_spec.rb.erb} +0 -0
  30. data/lib/generators/hot_glue/templates/system_spec.rb.erb +53 -0
  31. data/lib/hotglue/version.rb +1 -1
  32. metadata +24 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea5d85ef61b4bdedf3b9b883596d6cb99ce8fe404dcf0d22d6fec74b9389f7fb
4
- data.tar.gz: 4d94d90506fd14642672b32e5437ba789e94618d6b91459a7c41b9475df272d8
3
+ metadata.gz: 831970726374d97ef6b5380d122033384777a520ba5fcaeebc9ee79717b82ef1
4
+ data.tar.gz: f45f7a48e78a6bfd62973a11d5b55b24d7ba7a7979855940429ea00398e3ef1f
5
5
  SHA512:
6
- metadata.gz: 7bb028acd27535bfaa5c53559418638eb7af6e45456d4e294e903ab1f3077ee14240056188b5f48677c491f9d4a265cc42add3e36d009552331ffa2cce42db43
7
- data.tar.gz: 1ae9c5018d520969710f68b85af0522485b5011bdaf39ac0056889a5c341046dc8d744a761426d2dd8bd6ca7969fefdc8e1560a0d481e6e78a8f592ab874e236
6
+ metadata.gz: 23fa8de6cc6460b36d3a867c502a708c6ea825575f25240d28f11f0c0f5a333fc6fe583fa95668d517555bbef96177407432a8c98ca41a29caeca82fa37e765a
7
+ data.tar.gz: a1c9db09d05ab741a85906e31b9cc5336c73f4108f550edbd14166d00f0623b65b1ea8c97a8b9c95c39de55a72bc006cb657ab3d5cddff17258983eb26183ccc
data/.github/FUNDING.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  github: [jasonfb]
2
- custom: ["https://jfb.teachable.com"]
2
+ custom: ["https://www.instagram.com/jfbcodes/"]
data/.gitignore CHANGED
@@ -1,16 +1,21 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
- test/dummy/db/*.sqlite3
5
- test/dummy/db/*.sqlite3-journal
6
- test/dummy/db/*.sqlite3-*
7
- test/dummy/log/*.log
8
- test/dummy/storage/
9
- test/dummy/tmp/
4
+
10
5
  .byebug_history
11
6
 
12
7
  .idea/
13
8
  *.gem
14
9
  .DS_Store
15
10
 
16
- dump.rdb
11
+ dump.rdb
12
+ tmp/
13
+
14
+
15
+ db/*.sqlite3
16
+
17
+ spec/dummy/app/views/
18
+ spec/dummy/app/controllers/
19
+ spec/dummy/specs/
20
+
21
+ spec/strawman/
data/Gemfile CHANGED
@@ -1,15 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- # Declare your gem's dependencies in common_core_js.gemspec.
5
- # Bundler will treat runtime dependencies like base dependencies, and
6
- # development dependencies will be added by default to the :development group.
7
4
  gemspec
8
5
 
9
- # Declare any dependencies that are still in development here instead of in
10
- # your gemspec. These might include edge Rails or gems from your path or
11
- # Git. Remember to move these dependencies to your gemspec before releasing
12
- # your gem to rubygems.org.
6
+ gem 'sqlite3'
7
+ gem 'byebug'
13
8
 
14
- # To use a debugger
15
- # gem 'byebug', group: [:development, :test]
9
+ gem 'rails', '6.1'
10
+ gem 'devise', require: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.0.2)
4
+ hot-glue (0.0.8)
5
5
  ffaker (~> 2.16)
6
6
  haml-rails (~> 2.0)
7
7
  kaminari (~> 1.2)
@@ -71,13 +71,21 @@ GEM
71
71
  minitest (>= 5.1)
72
72
  tzinfo (~> 2.0)
73
73
  zeitwerk (~> 2.3)
74
+ bcrypt (3.1.16)
74
75
  builder (3.2.4)
76
+ byebug (11.1.3)
75
77
  concurrent-ruby (1.1.8)
76
78
  crass (1.0.6)
79
+ devise (4.7.3)
80
+ bcrypt (~> 3.0)
81
+ orm_adapter (~> 0.1)
82
+ railties (>= 4.1.0)
83
+ responders
84
+ warden (~> 1.2.3)
77
85
  erubi (1.10.0)
78
86
  erubis (2.7.0)
79
- ffaker (2.17.0)
80
- ffi (1.14.2)
87
+ ffaker (2.18.0)
88
+ ffi (1.15.0)
81
89
  globalid (0.4.2)
82
90
  activesupport (>= 4.2.0)
83
91
  haml (5.2.1)
@@ -118,10 +126,13 @@ GEM
118
126
  method_source (1.0.0)
119
127
  mimemagic (0.3.5)
120
128
  mini_mime (1.0.2)
121
- minitest (5.14.3)
122
- nio4r (2.5.4)
123
- nokogiri (1.11.1-x86_64-darwin)
129
+ mini_portile2 (2.5.0)
130
+ minitest (5.14.4)
131
+ nio4r (2.5.7)
132
+ nokogiri (1.11.1)
133
+ mini_portile2 (~> 2.5.0)
124
134
  racc (~> 1.4)
135
+ orm_adapter (0.5.0)
125
136
  racc (1.5.2)
126
137
  rack (2.2.3)
127
138
  rack-test (1.1.0)
@@ -153,30 +164,30 @@ GEM
153
164
  rake (>= 0.8.7)
154
165
  thor (~> 1.0)
155
166
  rake (13.0.3)
156
- rb-fsevent (0.10.4)
157
- rb-inotify (0.10.1)
158
- ffi (~> 1.0)
159
- ruby_parser (3.15.0)
167
+ responders (3.0.1)
168
+ actionpack (>= 5.0)
169
+ railties (>= 5.0)
170
+ ruby_parser (3.15.1)
160
171
  sexp_processor (~> 4.9)
161
- sass (3.7.4)
162
- sass-listen (~> 4.0.0)
163
- sass-listen (4.0.0)
164
- rb-fsevent (~> 0.9, >= 0.9.4)
165
- rb-inotify (~> 0.9, >= 0.9.7)
166
- sass-rails (5.1.0)
167
- railties (>= 5.2.0)
168
- sass (~> 3.1)
169
- sprockets (>= 2.8, < 4.0)
170
- sprockets-rails (>= 2.0, < 4.0)
171
- tilt (>= 1.1, < 3)
172
- sexp_processor (4.15.1)
173
- sprockets (3.7.2)
172
+ sass-rails (6.0.0)
173
+ sassc-rails (~> 2.1, >= 2.1.1)
174
+ sassc (2.4.0)
175
+ ffi (~> 1.9)
176
+ sassc-rails (2.1.2)
177
+ railties (>= 4.0.0)
178
+ sassc (>= 2.0)
179
+ sprockets (> 3.0)
180
+ sprockets-rails
181
+ tilt
182
+ sexp_processor (4.15.2)
183
+ sprockets (4.0.2)
174
184
  concurrent-ruby (~> 1.0)
175
185
  rack (> 1, < 3)
176
186
  sprockets-rails (3.2.2)
177
187
  actionpack (>= 4.0)
178
188
  activesupport (>= 4.0)
179
189
  sprockets (>= 3.0.0)
190
+ sqlite3 (1.4.2)
180
191
  temple (0.8.2)
181
192
  thor (1.1.0)
182
193
  tilt (2.0.10)
@@ -184,6 +195,8 @@ GEM
184
195
  rails (>= 6.0.0)
185
196
  tzinfo (2.0.4)
186
197
  concurrent-ruby (~> 1.0)
198
+ warden (1.2.9)
199
+ rack (>= 2.0.9)
187
200
  websocket-driver (0.7.3)
188
201
  websocket-extensions (>= 0.1.0)
189
202
  websocket-extensions (0.1.5)
@@ -193,7 +206,11 @@ PLATFORMS
193
206
  ruby
194
207
 
195
208
  DEPENDENCIES
209
+ byebug
210
+ devise
196
211
  hot-glue!
212
+ rails (= 6.1)
213
+ sqlite3
197
214
 
198
215
  BUNDLED WITH
199
216
  2.1.4
data/README.md CHANGED
@@ -35,20 +35,29 @@ rails generate hot_glue:scaffold Thing
35
35
 
36
36
  ## TO INSTALL
37
37
 
38
- - Add Turbo-Rails to your Gemfile & bundle install, then install it with `rails turbo:install`
38
+ - Add Turbo-Rails to your Gemfile & bundle install
39
+
40
+ - Then install it with `rails turbo:install`
39
41
 
40
42
  - The Turbo install has switched your action cable settings from 'async' to Redis, so be sure to start a redis server
41
43
 
42
- - Add hot_glue to your Gemfile & bundle install, then install it with `rails hot_glue:install`
44
+ - Add `hot_glue` to your Gemfile & `bundle install`
45
+
46
+ - Then install it with `rails generate hot_glue:install`
47
+
48
+ - Add to your `application.html.erb`
49
+ ```
50
+ <%= render partial: 'layouts/flash_notices' %>
51
+ ```
43
52
 
44
53
  - Install Bootstrap (optional)
45
54
 
46
- with Webpack:
55
+ Bootstrap with Webpack:
47
56
  - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
48
57
  - `yarn add bootstrap`
49
- - create a new file at `app/javascript/css/site.scss` with this contents
58
+ - create a new file at `app/javascript/css/site.scss` with this content
50
59
  ```
51
- @import "~bootstrap/scss/bootstrap.scss
60
+ @import "~bootstrap/scss/bootstrap.scss";
52
61
  ```
53
62
 
54
63
  - add to `app/javascript/packs/application.js`
@@ -56,28 +65,31 @@ with Webpack:
56
65
  import 'css/site'
57
66
  ```
58
67
 
68
+ Bootstrap with Sprockets:
69
+ - use bootstrap-rails gem
59
70
 
60
71
 
61
72
  - Install Devise or implement your own authentication
62
73
 
74
+ - Also recommended: font-awesome-sass
63
75
 
64
76
 
65
- ## Options
77
+ ### First Argument
78
+ (no double slash)
66
79
 
67
- Note that the arguments are not preceded by dashes and are followed by equal sign and the input you are giving.
80
+ TitleCase class name of the thing you want to build a scaffoling for.
68
81
 
69
- Flags take two dashes (--) and do not take any value. Always pass options first, followed by the flags (or else your options won't work!)
70
82
 
71
- ### First Argument
83
+ ## Options With Arguments
72
84
 
73
- TitleCase class name of the thing you want to build a scaffoling for.
85
+ All options two dashes (--) and these take an `=` and a value
74
86
 
75
- ### `namespace=`
87
+ ### `--namespace=`
76
88
 
77
- pass `namespace=` as an option to denote a namespace to apply to the Rails path helpers
89
+ pass `--namespace=` as an option to denote a namespace to apply to the Rails path helpers
78
90
 
79
91
 
80
- `rails generate hot_glue:scaffold Thing namespace=dashboard`
92
+ `rails generate hot_glue:scaffold Thing --namespace=dashboard`
81
93
 
82
94
  This produces several views at `app/views/dashboard/things/` and a controller at`app/controllers/dashboard/things_controller.rb`
83
95
 
@@ -96,12 +108,12 @@ end
96
108
  ```
97
109
 
98
110
 
99
- ### `nest=`
111
+ ### `--nest=`
100
112
 
101
- pass `nest=` to denote a nested resources
113
+ pass `--nest=` to denote a nested resources
102
114
 
103
115
 
104
- `rails generate hot_glue:scaffold Line nest=invoice`
116
+ `rails generate hot_glue:scaffold Line --nest=invoice`
105
117
 
106
118
  In this example, it is presumed that the current user has_many :invoices, and that invoices have many :lines
107
119
 
@@ -120,7 +132,7 @@ In this example, it is presumed that the current user has_many :invoices, and th
120
132
 
121
133
 
122
134
  To generate scaffold:
123
- `rails generate hot_glue:scaffold Charge nest=invoice/line`
135
+ `rails generate hot_glue:scaffold Charge --nest=invoice/line`
124
136
 
125
137
  The order of the nest should match the nested resources you have in your own app. In particular, you auth root will be used as the starting point when loading the objects from the URL:
126
138
 
@@ -143,7 +155,7 @@ It works, but it isn't granular. As well, it isn't appropriate for a large app w
143
155
  Your customers can delete their own objects by default (may be a good idea or a bad idea for you). If you don't want that, you should strip out the delete actions off the controllers.
144
156
 
145
157
 
146
- ### `auth=`
158
+ ### `--auth=`
147
159
 
148
160
  By default, it will be assumed you have a `current_user` for your user authentication. This will be treated as the "authentication root" for the "poor man's auth" explained above.
149
161
 
@@ -157,7 +169,7 @@ If you use Devise, you probably already have a `current_user` method available i
157
169
 
158
170
  If you use a different object other than "User" for authentication, override using the `auth` option.
159
171
 
160
- `rails generate hot_glue:scaffold Thing auth=current_account`
172
+ `rails generate hot_glue:scaffold Thing --auth=current_account`
161
173
 
162
174
  You will note that in this example it is presumed that the Account object will have an association for `things`
163
175
 
@@ -168,7 +180,7 @@ If you supply nesting (see below), your nest chain will automatically begin with
168
180
 
169
181
 
170
182
 
171
- ### `auth_identifier=`
183
+ ### `--auth_identifier=`
172
184
 
173
185
  Your controller will call a method authenticate_ (AUTH IDENTIFIER) bang, like:
174
186
 
@@ -198,7 +210,7 @@ As well, the `after_sign_in_path_for(user)` here is a hook for Devise also that
198
210
  The default (do not pass `auth_identifier=`) will match the `auth` (So if you use 'account' as the auth, `authenticate_account!` will get invoked from your generated controller; the default is always 'user', so you can leave both auth and auth_identifier off if you want 'user')
199
211
 
200
212
 
201
- `rails generate hot_glue:scaffold Thing auth=current_account auth_identifier=login`
213
+ `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=login`
202
214
  In this example, the controller produced with:
203
215
  ```
204
216
  before_action :authenticate_login!
@@ -209,34 +221,55 @@ However, the object graph anchors would continue to start from current_account.
209
221
  ```
210
222
 
211
223
  Use empty string to **turn this method off**:
212
- `rails generate hot_glue:scaffold Thing auth=current_account auth_identifier=''`
224
+ `rails generate hot_glue:scaffold Thing --auth=current_account --auth_identifier=''`
213
225
 
214
226
  In this case a controller would be generated that would have NO before_action to authenticate the account, but it would still treat the current_account as the auth root for the purpose of loading the objects.
215
227
 
216
228
  Please note that this example would product non-functional code, so you would need to manually fix your controllers to make sure `current_account` is available to the controller.
217
229
 
218
230
 
219
- ### `plural=`
231
+ ### `--plural=`
220
232
 
221
- You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name)
233
+ You don't need this if the pluralized version is just + "s" of the singular version. Only use for non-standard plurlizations, and be sure to pass it as TitleCase (as if you pluralized the model name which is non-standard for Rails)
222
234
 
223
235
 
224
- ### `exclude=`
236
+ ### `--exclude=`
225
237
  (separate field names by COMMA)
226
238
 
227
239
  By default, all fields are included unless they are on the exclude list. (The default for the exclude list is `id`, `created_at`, and `updated_at` so you don't need to exclude those-- they are added.)
228
240
 
229
- If you specify an exclude list, those fields + id, created_at, and updated_at will be excluded.
241
+ If you specify an exclude list, those and the default excluded list will be excluded.
242
+
243
+
244
+ `rails generate hot_glue:scaffold Account --exclude=password`
245
+
246
+ (The default excluded list is: :id, :created_at, :updated_at, :encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email. If you want to edit any fields with the same name, you must use the include flag instead.)
247
+
230
248
 
249
+ ### `--include=`
250
+ (separate field names by COMMA)
251
+
252
+ You may not specify both include and exclude. If you specify an include list, it will be treated as a whitelist: no fields will be included unless specified on the include list.
253
+
254
+ `rails generate hot_glue:scaffold Account --include=first_name,last_name,company_name,created_at,kyc_verified_at`
255
+
256
+
257
+ ### `--show-only=`
258
+ (separate field names by COMMA)
259
+
260
+ Any fields only the 'show-only' list will appear as non-editable on the generate form. (visible only)
231
261
 
262
+ IMPORTANT: By default, all fields that begin with an underscore (`_`) are automatically show-only.
232
263
 
233
- ### `--god`
264
+ I would recommend this for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
234
265
 
235
- Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controoler.
266
+ ### `--god` or `--gd`
236
267
 
237
- For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag
268
+ Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controller.
238
269
 
239
- In God mode, the objects are loaded directly from the base class (these controllers have full access)
270
+ For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
271
+
272
+ In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
240
273
  ```
241
274
  def load_thing
242
275
  @thing = Thing.find(params[:id])
@@ -244,7 +277,8 @@ end
244
277
 
245
278
  ```
246
279
 
247
-
280
+ ## FLAGS (Options with no values)
281
+ These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
248
282
 
249
283
  ### `--specs-only`
250
284
 
@@ -261,9 +295,36 @@ Produces all the files except the spec file.
261
295
  Omits pagination. (All list views have pagination by default.)
262
296
 
263
297
 
298
+ ### `--no-create`
299
+
300
+ Omits create action.
301
+
302
+ ### `--no-delete`
303
+
304
+ Omits delete action.
305
+
306
+ ### `--big-edit`
307
+
308
+ If you do not want inline editing of your list items but instead to fall back to old fashioned new page behavior for your edit views, use `--big-edit`.
309
+
310
+
311
+
264
312
 
265
313
 
266
314
  # VERSION HISTORY
315
+
316
+ #### 2021-03-24 - v0.0.9 - fixes in the automatic field label detection; cleans up junk in spec output
317
+
318
+ #### 2021-03-21 - v0.0.8 - show only flag; more specific spec coverage in generator spec
319
+
320
+ #### 2021-03-20 - v0.0.7 - adds lots of spec coverage; cleans up generated cruft code on each run; adds no-delete, no-create; a working --big-edit with basic data-turbo false to disable inline editing
321
+
322
+ #### 2021-03-06 - v0.0.6 - internal specs test the error catches and cover basic code generation (dummy testing only)
323
+
324
+ #### 2021-03-01 - v0.0.5 - Validation magic; refactors the options to the correct Rails::Generators syntax
325
+
326
+ #### (yanked) - v0.0.4
327
+
267
328
  #### 2021-02-27 - v0.0.3 - several fixes for namespaces; adds pagination; adds exclude list to fields
268
329
 
269
330
  #### 2021-02-25 - v0.0.2 - bootstrapy
@@ -280,3 +341,34 @@ Omits pagination. (All list views have pagination by default.)
280
341
  I hope one day I will leave this Earth a poor man (like my code) owning only the most simple structure for the simple form of my existence. Thanks for having educated me in this wisdom goes to my former mentor [@trak3r](https://github.com/trak3r)!
281
342
 
282
343
 
344
+
345
+
346
+ # HOW THIS GEM IS TESTED
347
+
348
+ The testing of functionality-within-functionality is a little tricky and requires thinking outside the box.
349
+
350
+ We have two kinds of "sandboxes": a DUMMY sandbox, and also a STRAWMAN sandbox
351
+
352
+ The dummy sandbox is found at `spec/dummy`
353
+
354
+ The dummy lives as mostly checked- into the repository, except the folders where the generated code goes (`spec/dummy/app/views/`, `spec/dummy/app/controllers/`, `spec/dummy/specs/` are excluded from Git)
355
+
356
+ When you run the **internal specs**, which you can do **at the root of this repo** using the command `rspec`, a set of specs will run to assert the generators are erroring when they are supposed to and producing code when they are supposed to.
357
+
358
+
359
+ The DUMMY testing DOES NOT test the actual functionality of the output code (it just tests the functionality of the generation process).
360
+
361
+ For this reason, I've also added something I call STRAWMAN testing, which is a set of steps that does these things:
362
+
363
+ The Strawman isn't in the repository, but if you build it locally, it will create itself into
364
+
365
+ `spec/strawman/`
366
+
367
+ 1) Builds you a strawman sandbox app from scratch, using the native `rails new`
368
+ 2) Makes a few small modifications to the new app to support this gem
369
+ 3) Create two nonsense tables called OmnitableA and OmnitableB. Each omnitable has one of each kind of field (integer, text, string, date, time, etc)
370
+ 4) In this way, it is a "Noah's Arc" testing strategy: It will build you a fully functional app using all of the feature sets of the gem.
371
+ 5) The built app itself will contain its own specs
372
+ 6) You will then cd into `spec/strawman` and run `rspec`. This second test suite now runs to full test all of the *generated* code.
373
+
374
+