common_core_js 0.3.9 → 0.4.4
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 -0
- data/LICENSE +5 -2
- data/README.md +12 -5
- data/common_core_js.gemspec +3 -4
- data/lib/common_core_js/version.rb +1 -1
- data/lib/generators/common_core/scaffold_generator.rb +51 -12
- data/lib/generators/common_core/templates/controller_spec.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '001176705079f92886743669c3ec5fbabb0252f5097bbc85dd14998f3661cc7f'
|
4
|
+
data.tar.gz: 318956907259aebd72463055f35f4d6bba478871e725a6653fc59f4093276e96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc8ef855874387546e79427d1ae45901f8dd82288e0a391fa74b6e150b400278f95a62ff26ac0751c776855e53c03602e346ba05706575ba093d2e14467a0976
|
7
|
+
data.tar.gz: 1346253af16bb45ab95f1658a61cca9f80b37f2de895fbce21eefc890c18cf2b0cba54a47bd81472d0524819b7e0d442cb4dd5cafcc4b35562842afa80e893b6
|
data/.github/FUNDING.yml
ADDED
data/LICENSE
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
Permission is hereby granted to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
2
2
|
|
3
|
-
Any users of this software agree to work to
|
3
|
+
Any users of this software agree to work to
|
4
|
+
1) dismantle systemic racism;
|
5
|
+
2) seek justice for black, brown, transgender people, women, and
|
6
|
+
3) work towards LGBTQIAA+ representation and inclusion.
|
4
7
|
|
5
|
-
Organizations using this software agree to center the narratives of black, brown, and
|
8
|
+
Organizations using this software agree to center the narratives of black, brown, transgender, and non-advantaged people in the world.
|
6
9
|
|
7
10
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
11
|
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ rails generate common_core:scaffold Thing
|
|
50
50
|
|
51
51
|
Note that the arguments are not preceeded by dashes and are followed by equal sign and the input you are giving.
|
52
52
|
|
53
|
-
Flags take two dashes (--) and do not take any value.
|
53
|
+
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!)
|
54
54
|
|
55
55
|
### First Argument
|
56
56
|
|
@@ -58,7 +58,7 @@ TitleCase class name of the thing you want to build a scaffoling for.
|
|
58
58
|
|
59
59
|
### `namespace=`
|
60
60
|
|
61
|
-
pass `namespace=` as
|
61
|
+
pass `namespace=` as an option to denote a namespace to apply to the Rails path helpers
|
62
62
|
|
63
63
|
|
64
64
|
`rails generate common_core:scaffold Thing namespace=dashboard`
|
@@ -82,7 +82,7 @@ end
|
|
82
82
|
|
83
83
|
### `nest=`
|
84
84
|
|
85
|
-
pass `nest=`
|
85
|
+
pass `nest=` to denote a nested resources
|
86
86
|
|
87
87
|
|
88
88
|
`rails generate common_core:scaffold Line nest=invoice`
|
@@ -139,7 +139,7 @@ When you display anything built with the scaffolding, we assume the `current_use
|
|
139
139
|
|
140
140
|
If you use Devise, you probably already have a `current_user` method available in your controllers. If you don't use Devise, you can implement it in your ApplicationController.
|
141
141
|
|
142
|
-
If you use a different object other than "User" for authentication, override using the `auth`
|
142
|
+
If you use a different object other than "User" for authentication, override using the `auth` option.
|
143
143
|
|
144
144
|
`rails generate common_core:scaffold Thing auth=current_account`
|
145
145
|
|
@@ -209,7 +209,7 @@ You don't need this if the pluralized version is just + "s" of the singular vers
|
|
209
209
|
|
210
210
|
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.
|
211
211
|
|
212
|
-
For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use
|
212
|
+
For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag
|
213
213
|
|
214
214
|
In God mode, the objects are loaded directly from the base class (these controllers have full access)
|
215
215
|
```
|
@@ -293,3 +293,10 @@ environment.plugins.prepend('Provide',
|
|
293
293
|
module.exports = environment
|
294
294
|
|
295
295
|
```
|
296
|
+
|
297
|
+
|
298
|
+
# ACKNOWLEDGEMENTS
|
299
|
+
|
300
|
+
### "POOR MAN"
|
301
|
+
|
302
|
+
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)!
|
data/common_core_js.gemspec
CHANGED
@@ -7,8 +7,8 @@ require 'byebug'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "common_core_js"
|
9
9
|
spec.version = CommonCoreJs::VERSION
|
10
|
-
spec.license = '
|
11
|
-
spec.date = '2020-
|
10
|
+
spec.license = 'Commit to Social Justice'
|
11
|
+
spec.date = '2020-10-29'
|
12
12
|
spec.summary = "A gem build scaffolding."
|
13
13
|
spec.description = "Simple, plug & play Rails scaffolding with really simple Javascript"
|
14
14
|
spec.authors = ["Jason Fleetwood-Boldt"]
|
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
|
20
19
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
21
20
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
22
21
|
if spec.respond_to?(:metadata)
|
@@ -37,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
37
36
|
spec.metadata = { "source_code_uri" => "https://github.com/jasonfb/common_core_js",
|
38
37
|
"documentation_uri" => "https://github.com/jasonfb/common_core_js",
|
39
38
|
"homepage_uri" => 'https://blog.jasonfleetwoodboldt.com/common-core-js/',
|
40
|
-
|
39
|
+
"course_material_uri" => "https://jfb.teachable.com/p/jason-s-open-source-work/"
|
41
40
|
}
|
42
41
|
|
43
42
|
spec.add_runtime_dependency('kaminari')
|
@@ -68,6 +68,7 @@ module CommonCore
|
|
68
68
|
|
69
69
|
args[1..-1].each do |a|
|
70
70
|
var_name, var_value = a.split("=")
|
71
|
+
puts var_name
|
71
72
|
case (var_name)
|
72
73
|
|
73
74
|
when "plural"
|
@@ -137,21 +138,39 @@ module CommonCore
|
|
137
138
|
@object_owner_sym = @auth.gsub("current_", "").to_sym
|
138
139
|
@object_owner_eval = @auth
|
139
140
|
else
|
140
|
-
|
141
|
-
|
141
|
+
|
142
|
+
if @nested_args.any?
|
143
|
+
@object_owner_sym = @nested_args.last.to_sym
|
144
|
+
@object_owner_eval = "@#{@nested_args.last}"
|
145
|
+
else
|
146
|
+
@object_owner_sym = ""
|
147
|
+
@object_owner_eval = ""
|
148
|
+
end
|
142
149
|
end
|
143
150
|
|
144
151
|
|
145
152
|
|
146
153
|
# create the columns
|
147
|
-
|
148
|
-
|
149
|
-
|
154
|
+
if !@object_owner_sym.empty?
|
155
|
+
auth_assoc_field = auth_assoc + "_id"
|
156
|
+
assoc = eval("#{singular_class}.reflect_on_association(:#{@object_owner_sym})")
|
157
|
+
if assoc
|
158
|
+
ownership_field = assoc.name.to_s + "_id"
|
159
|
+
else
|
160
|
+
puts "Ooops... it looks like is no association for #{@object_owner_sym} on #{singular_class} "
|
161
|
+
exit
|
162
|
+
end
|
163
|
+
end
|
150
164
|
|
151
165
|
|
152
|
-
exclude_fields = [
|
166
|
+
exclude_fields = [ :id, :created_at, :updated_at, :encrypted_password, :reset_password_token,
|
153
167
|
:reset_password_sent_at, :remember_created_at, :confirmation_token, :confirmed_at,
|
154
168
|
:confirmation_sent_at, :unconfirmed_email]
|
169
|
+
|
170
|
+
exclude_fields << auth_assoc_field.to_sym if !auth_assoc_field.nil?
|
171
|
+
exclude_fields << ownership_field.to_sym if !ownership_field.nil?
|
172
|
+
|
173
|
+
|
155
174
|
begin
|
156
175
|
@columns = object.columns.map(&:name).map(&:to_sym).reject{|field| exclude_fields.include?(field) }
|
157
176
|
rescue StandardError => e
|
@@ -266,7 +285,7 @@ module CommonCore
|
|
266
285
|
end
|
267
286
|
|
268
287
|
def path_helper_args
|
269
|
-
[(@nested_args if @nested_args.any?).collect{|a| "@#{a}"} , singular].join(",")
|
288
|
+
[(@nested_args if @nested_args.any? || []).collect{|a| "@#{a}"} , singular].join(",")
|
270
289
|
end
|
271
290
|
|
272
291
|
def path_helper_singular
|
@@ -475,16 +494,27 @@ module CommonCore
|
|
475
494
|
when :datetime
|
476
495
|
".row
|
477
496
|
%div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
478
|
-
= datetime_field_localized(f, :#{col.to_s},
|
497
|
+
= datetime_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
|
479
498
|
when :date
|
480
499
|
".row
|
481
500
|
%div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
482
|
-
= date_field_localized(f, :#{col.to_s},
|
501
|
+
= date_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
|
483
502
|
when :time
|
484
503
|
".row
|
485
504
|
%div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
486
|
-
= time_field_localized(f, :#{col.to_s},
|
505
|
+
= time_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{col.to_s.humanize}', #{@auth ? @auth+'.timezone' : 'nil'})"
|
506
|
+
when :boolean
|
507
|
+
".row
|
508
|
+
%div{class: \"form-group col-md-4 \#{'alert-danger' if #{singular}.errors.details.keys.include?(:#{col.to_s})}\"}
|
509
|
+
%span
|
510
|
+
#{col.to_s.humanize}
|
511
|
+
= f.radio_button(:#{col.to_s}, '0', checked: #{singular}.#{col.to_s} ? '' : 'checked')
|
512
|
+
= f.label(:#{col.to_s}, value: 'No', for: '#{singular}_#{col.to_s}_0')
|
513
|
+
|
514
|
+
= f.radio_button(:#{col.to_s}, '1', checked: #{singular}.#{col.to_s} ? 'checked' : '')
|
515
|
+
= f.label(:#{col.to_s}, value: 'Yes', for: '#{singular}_#{col.to_s}_1')
|
487
516
|
|
517
|
+
"
|
488
518
|
end
|
489
519
|
|
490
520
|
}.join("\n")
|
@@ -530,7 +560,7 @@ module CommonCore
|
|
530
560
|
end
|
531
561
|
|
532
562
|
" %td
|
533
|
-
= #{singular}.#{assoc.name.to_s}
|
563
|
+
= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe"
|
534
564
|
|
535
565
|
else
|
536
566
|
" %td
|
@@ -567,7 +597,16 @@ module CommonCore
|
|
567
597
|
%span.alert-danger
|
568
598
|
MISSING
|
569
599
|
"
|
570
|
-
|
600
|
+
when :boolean
|
601
|
+
" %td
|
602
|
+
- if #{singular}.#{col}.nil?
|
603
|
+
%span.alert-danger
|
604
|
+
MISSING
|
605
|
+
- elsif #{singular}.#{col}
|
606
|
+
YES
|
607
|
+
- else
|
608
|
+
NO
|
609
|
+
"
|
571
610
|
end
|
572
611
|
}.join("\n")
|
573
612
|
return res
|
@@ -10,7 +10,7 @@ describe <%= controller_class_name %> do
|
|
10
10
|
before(:each) do
|
11
11
|
@request.env["devise.mapping"] = Devise.mappings[:account]
|
12
12
|
|
13
|
-
sign_in <%= @auth %>, scope: :<%= @
|
13
|
+
sign_in <%= @auth %>, scope: :<%= @auth %>
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "index" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_core_js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -129,6 +129,7 @@ extensions: []
|
|
129
129
|
extra_rdoc_files: []
|
130
130
|
files:
|
131
131
|
- ".generators"
|
132
|
+
- ".github/FUNDING.yml"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".rakeTasks"
|
134
135
|
- FUNDING.yml
|
@@ -192,12 +193,12 @@ files:
|
|
192
193
|
- lib/tasks/common_core_js_tasks.rake
|
193
194
|
homepage: https://blog.jasonfleetwoodboldt.com/common-core-js/
|
194
195
|
licenses:
|
195
|
-
-
|
196
|
+
- Commit to Social Justice
|
196
197
|
metadata:
|
197
198
|
source_code_uri: https://github.com/jasonfb/common_core_js
|
198
199
|
documentation_uri: https://github.com/jasonfb/common_core_js
|
199
200
|
homepage_uri: https://blog.jasonfleetwoodboldt.com/common-core-js/
|
200
|
-
|
201
|
+
course_material_uri: https://jfb.teachable.com/p/jason-s-open-source-work/
|
201
202
|
post_install_message: |
|
202
203
|
---------------------------------------------
|
203
204
|
Welcome to Common Core
|
@@ -229,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
230
|
- !ruby/object:Gem::Version
|
230
231
|
version: '0'
|
231
232
|
requirements: []
|
232
|
-
rubygems_version: 3.0.
|
233
|
-
signing_key:
|
233
|
+
rubygems_version: 3.0.8
|
234
|
+
signing_key:
|
234
235
|
specification_version: 4
|
235
236
|
summary: A gem build scaffolding.
|
236
237
|
test_files: []
|