souls 0.8.7 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +19 -1
- data/exe/souls +4 -2
- data/lib/souls.rb +1 -0
- data/lib/souls/init.rb +65 -43
- data/lib/souls/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75064881212497375ac7f55321f3fdc9c795b51b0d7b3cd17964efa744acf8a9
|
|
4
|
+
data.tar.gz: 14fd24e84cd0bd2062bc3644eb543e542dbe89d60c51c18e657e2f32d02866c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 141abafb886a0edd0b4b98a76f13547974244c9847fa028553617c730098bcec839a653dbc84e1e78a025cda4cd5e8f09cc9d3dafdce4bbdff4a6af02897dfe5
|
|
7
|
+
data.tar.gz: edd609ace5b59bd45a92245dc481ab14289cf5d4a234883af8533bef6176ce4ce156b056af7aaedcfe853796ac30665755ef313c223c45eeb1c02e5eacba7f72
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
souls (0.
|
|
4
|
+
souls (0.9.1)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -26,6 +26,7 @@ GEM
|
|
|
26
26
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
27
27
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
28
28
|
minitest (5.14.2)
|
|
29
|
+
parallel (1.20.1)
|
|
29
30
|
parser (2.7.2.0)
|
|
30
31
|
ast (~> 2.4.1)
|
|
31
32
|
rainbow (3.0.0)
|
|
@@ -34,6 +35,8 @@ GEM
|
|
|
34
35
|
rb-inotify (0.10.1)
|
|
35
36
|
ffi (~> 1.0)
|
|
36
37
|
rbs (1.0.0)
|
|
38
|
+
regexp_parser (2.0.3)
|
|
39
|
+
rexml (3.2.4)
|
|
37
40
|
rspec (3.1.0)
|
|
38
41
|
rspec-core (~> 3.1.0)
|
|
39
42
|
rspec-expectations (~> 3.1.0)
|
|
@@ -46,6 +49,18 @@ GEM
|
|
|
46
49
|
rspec-mocks (3.1.3)
|
|
47
50
|
rspec-support (~> 3.1.0)
|
|
48
51
|
rspec-support (3.1.2)
|
|
52
|
+
rubocop (1.7.0)
|
|
53
|
+
parallel (~> 1.10)
|
|
54
|
+
parser (>= 2.7.1.5)
|
|
55
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
56
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
57
|
+
rexml
|
|
58
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
59
|
+
ruby-progressbar (~> 1.7)
|
|
60
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
61
|
+
rubocop-ast (1.4.0)
|
|
62
|
+
parser (>= 2.7.1.5)
|
|
63
|
+
ruby-progressbar (1.11.0)
|
|
49
64
|
steep (0.39.0)
|
|
50
65
|
activesupport (>= 5.1)
|
|
51
66
|
ast_utils (~> 0.3.0)
|
|
@@ -57,14 +72,17 @@ GEM
|
|
|
57
72
|
thor (1.0.1)
|
|
58
73
|
tzinfo (2.0.4)
|
|
59
74
|
concurrent-ruby (~> 1.0)
|
|
75
|
+
unicode-display_width (1.7.0)
|
|
60
76
|
zeitwerk (2.4.2)
|
|
61
77
|
|
|
62
78
|
PLATFORMS
|
|
63
79
|
ruby
|
|
64
80
|
|
|
65
81
|
DEPENDENCIES
|
|
82
|
+
activesupport (= 6.1.0)
|
|
66
83
|
rake (= 13.0.3)
|
|
67
84
|
rspec (= 3.1.0)
|
|
85
|
+
rubocop (= 1.7.0)
|
|
68
86
|
souls!
|
|
69
87
|
steep (= 0.39.0)
|
|
70
88
|
|
data/exe/souls
CHANGED
|
@@ -57,8 +57,10 @@ begin
|
|
|
57
57
|
Souls::Init.query class_name: ARGV[2]
|
|
58
58
|
when "type"
|
|
59
59
|
Souls::Init.type class_name: ARGV[2]
|
|
60
|
-
when "
|
|
60
|
+
when "migrate"
|
|
61
61
|
Souls::Init.migration class_name: ARGV[2]
|
|
62
|
+
when "migration"
|
|
63
|
+
`rake db:create_migration NAME=#{ARGV[3]}`
|
|
62
64
|
when "rspec_factory"
|
|
63
65
|
Souls::Init.rspec_factory class_name: ARGV[2]
|
|
64
66
|
when "rspec_model"
|
|
@@ -78,7 +80,7 @@ begin
|
|
|
78
80
|
when "-s"
|
|
79
81
|
`bundle exec steep check`
|
|
80
82
|
else
|
|
81
|
-
`
|
|
83
|
+
`rubocop`
|
|
82
84
|
`bundle exec rspec`
|
|
83
85
|
end
|
|
84
86
|
when "deploy"
|
data/lib/souls.rb
CHANGED
data/lib/souls/init.rb
CHANGED
|
@@ -247,11 +247,11 @@ module Souls
|
|
|
247
247
|
file_path = "./app/models/#{class_name}.rb"
|
|
248
248
|
File.open(file_path, "w") do |f|
|
|
249
249
|
f.write <<~EOS
|
|
250
|
-
class #{class_name.
|
|
250
|
+
class #{class_name.camelize} < ActiveRecord::Base
|
|
251
251
|
end
|
|
252
252
|
EOS
|
|
253
253
|
end
|
|
254
|
-
puts "
|
|
254
|
+
puts "Model #{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
def type_check type
|
|
@@ -278,7 +278,7 @@ module Souls
|
|
|
278
278
|
|
|
279
279
|
def table_check line: "", class_name: ""
|
|
280
280
|
if line.include?("create_table")
|
|
281
|
-
return true if line.split(" ")[1].gsub("\"", "").gsub(",", "") == "#{class_name}
|
|
281
|
+
return true if line.split(" ")[1].gsub("\"", "").gsub(",", "") == "#{class_name.pluralize}"
|
|
282
282
|
end
|
|
283
283
|
false
|
|
284
284
|
end
|
|
@@ -288,8 +288,8 @@ module Souls
|
|
|
288
288
|
File.open(file_path, "w") do |new_line|
|
|
289
289
|
new_line.write <<~EOS
|
|
290
290
|
module Mutations
|
|
291
|
-
class Create#{class_name.
|
|
292
|
-
field :#{class_name}, Types::#{class_name.
|
|
291
|
+
class Create#{class_name.camelize} < BaseMutation
|
|
292
|
+
field :#{class_name}, Types::#{class_name.camelize}Type, null: false
|
|
293
293
|
field :error, String, null: true
|
|
294
294
|
|
|
295
295
|
EOS
|
|
@@ -307,7 +307,12 @@ module Souls
|
|
|
307
307
|
break if line.include?("end") || line.include?("t.index")
|
|
308
308
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
309
309
|
field = type_check type
|
|
310
|
-
|
|
310
|
+
case name
|
|
311
|
+
when "created_at", "updated_at"
|
|
312
|
+
next
|
|
313
|
+
else
|
|
314
|
+
new_line.write " argument :#{name}, #{field}, required: false\n"
|
|
315
|
+
end
|
|
311
316
|
end
|
|
312
317
|
@on = true if table_check(line: line, class_name: class_name)
|
|
313
318
|
end
|
|
@@ -321,7 +326,7 @@ module Souls
|
|
|
321
326
|
new_line.write <<~EOS
|
|
322
327
|
|
|
323
328
|
def resolve **args
|
|
324
|
-
#{class_name} = #{class_name.
|
|
329
|
+
#{class_name} = #{class_name.camelize}.new args
|
|
325
330
|
if #{class_name}.save
|
|
326
331
|
{ #{class_name}: #{class_name} }
|
|
327
332
|
else
|
|
@@ -342,8 +347,8 @@ module Souls
|
|
|
342
347
|
File.open(file_path, "w") do |new_line|
|
|
343
348
|
new_line.write <<~EOS
|
|
344
349
|
module Mutations
|
|
345
|
-
class Update#{class_name.
|
|
346
|
-
field :#{class_name}, Types::#{class_name.
|
|
350
|
+
class Update#{class_name.camelize} < BaseMutation
|
|
351
|
+
field :#{class_name}, Types::#{class_name.camelize}Type, null: false
|
|
347
352
|
|
|
348
353
|
EOS
|
|
349
354
|
end
|
|
@@ -360,7 +365,12 @@ module Souls
|
|
|
360
365
|
break if line.include?("end") || line.include?("t.index")
|
|
361
366
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
362
367
|
field = type_check type
|
|
363
|
-
|
|
368
|
+
case name
|
|
369
|
+
when "created_at", "updated_at"
|
|
370
|
+
next
|
|
371
|
+
else
|
|
372
|
+
new_line.write " argument :#{name}, #{field}, required: false\n"
|
|
373
|
+
end
|
|
364
374
|
end
|
|
365
375
|
@on = true if table_check(line: line, class_name: class_name)
|
|
366
376
|
end
|
|
@@ -374,9 +384,9 @@ module Souls
|
|
|
374
384
|
new_line.write <<~EOS
|
|
375
385
|
|
|
376
386
|
def resolve **args
|
|
377
|
-
#{class_name} = #{class_name.
|
|
387
|
+
#{class_name} = #{class_name.camelize}.find args[:id]
|
|
378
388
|
#{class_name}.update args
|
|
379
|
-
{ #{class_name}: #{class_name.
|
|
389
|
+
{ #{class_name}: #{class_name.camelize}.find(args[:id]) }
|
|
380
390
|
rescue StandardError => error
|
|
381
391
|
GraphQL::ExecutionError.new error
|
|
382
392
|
end
|
|
@@ -398,12 +408,12 @@ module Souls
|
|
|
398
408
|
File.open(file_path, "w") do |f|
|
|
399
409
|
f.write <<~EOS
|
|
400
410
|
module Mutations
|
|
401
|
-
class Delete#{class_name.
|
|
402
|
-
field :#{class_name}, Types::#{class_name.
|
|
411
|
+
class Delete#{class_name.camelize} < BaseMutation
|
|
412
|
+
field :#{class_name}, Types::#{class_name.camelize}Type, null: false
|
|
403
413
|
argument :id, Integer, required: true
|
|
404
414
|
|
|
405
415
|
def resolve id:
|
|
406
|
-
#{class_name} = #{class_name.
|
|
416
|
+
#{class_name} = #{class_name.camelize}.find id
|
|
407
417
|
#{class_name}.destroy
|
|
408
418
|
{ #{class_name}: #{class_name} }
|
|
409
419
|
rescue StandardError => error
|
|
@@ -417,23 +427,24 @@ module Souls
|
|
|
417
427
|
end
|
|
418
428
|
|
|
419
429
|
def mutation class_name: "souls"
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
430
|
+
singularized_class_name = class_name.singularize
|
|
431
|
+
create_mutation_head class_name: singularized_class_name
|
|
432
|
+
create_mutation_params class_name: singularized_class_name
|
|
433
|
+
create_mutation_end class_name: singularized_class_name
|
|
434
|
+
update_mutation class_name: singularized_class_name
|
|
435
|
+
delete_mutation class_name: singularized_class_name
|
|
425
436
|
end
|
|
426
437
|
|
|
427
|
-
def
|
|
428
|
-
file_path = "./app/graphql/queries/#{class_name}
|
|
438
|
+
def create_query class_name: "souls"
|
|
439
|
+
file_path = "./app/graphql/queries/#{class_name.pluralize}.rb"
|
|
429
440
|
File.open(file_path, "w") do |f|
|
|
430
441
|
f.write <<~EOS
|
|
431
442
|
module Queries
|
|
432
|
-
class #{class_name.
|
|
433
|
-
type [Types::#{class_name.
|
|
443
|
+
class #{class_name.camelize.pluralize} < Queries::BaseQuery
|
|
444
|
+
type [Types::#{class_name.camelize}Type], null: false
|
|
434
445
|
|
|
435
446
|
def resolve
|
|
436
|
-
::#{class_name.
|
|
447
|
+
::#{class_name.camelize}.all
|
|
437
448
|
rescue StandardError => error
|
|
438
449
|
GraphQL::ExecutionError.new error
|
|
439
450
|
end
|
|
@@ -441,33 +452,42 @@ module Souls
|
|
|
441
452
|
end
|
|
442
453
|
EOS
|
|
443
454
|
end
|
|
444
|
-
puts "
|
|
455
|
+
puts "Query #{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def create_queries class_name: "souls"
|
|
445
459
|
file_path = "./app/graphql/queries/#{class_name}.rb"
|
|
446
460
|
File.open(file_path, "w") do |f|
|
|
447
461
|
f.write <<~EOS
|
|
448
462
|
module Queries
|
|
449
|
-
class #{class_name.
|
|
450
|
-
type Types::#{class_name.
|
|
463
|
+
class #{class_name.camelize} < Queries::BaseQuery
|
|
464
|
+
type Types::#{class_name.camelize}Type, null: false
|
|
451
465
|
argument :id, Integer, required: true
|
|
452
466
|
|
|
453
467
|
def resolve id:
|
|
454
|
-
::#{class_name.
|
|
468
|
+
::#{class_name.camelize}.find(id)
|
|
455
469
|
rescue StandardError => error
|
|
456
470
|
GraphQL::ExecutionError.new error
|
|
457
471
|
end
|
|
458
472
|
end
|
|
459
473
|
end
|
|
460
474
|
EOS
|
|
461
|
-
puts "
|
|
475
|
+
puts "Query #{class_name.pluralize}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
462
476
|
end
|
|
463
477
|
end
|
|
464
478
|
|
|
479
|
+
def query class_name: "souls"
|
|
480
|
+
singularized_class_name = class_name.singularize
|
|
481
|
+
create_query class_name: singularized_class_name
|
|
482
|
+
create_queries class_name: singularized_class_name
|
|
483
|
+
end
|
|
484
|
+
|
|
465
485
|
def create_type_head class_name: "souls"
|
|
466
486
|
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
|
467
487
|
File.open(file_path, "w") do |f|
|
|
468
488
|
f.write <<~EOS
|
|
469
489
|
module Types
|
|
470
|
-
class #{class_name.
|
|
490
|
+
class #{class_name.camelize}Type < GraphQL::Schema::Object
|
|
471
491
|
implements GraphQL::Types::Relay::Node
|
|
472
492
|
|
|
473
493
|
EOS
|
|
@@ -508,13 +528,14 @@ module Souls
|
|
|
508
528
|
end
|
|
509
529
|
|
|
510
530
|
def type class_name: "souls"
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
531
|
+
singularized_class_name = class_name.singularize
|
|
532
|
+
create_type_head class_name: singularized_class_name
|
|
533
|
+
create_type_params class_name: singularized_class_name
|
|
534
|
+
create_type_end class_name: singularized_class_name
|
|
514
535
|
end
|
|
515
536
|
|
|
516
537
|
def rspec_factory_head class_name: "souls"
|
|
517
|
-
file_path = "./spec/factories/#{class_name}
|
|
538
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
518
539
|
File.open(file_path, "w") do |f|
|
|
519
540
|
f.write <<~EOS
|
|
520
541
|
FactoryBot.define do
|
|
@@ -524,7 +545,7 @@ module Souls
|
|
|
524
545
|
end
|
|
525
546
|
|
|
526
547
|
def rspec_factory_params class_name: "souls"
|
|
527
|
-
file_path = "./spec/factories/#{class_name}
|
|
548
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
528
549
|
path = "./db/schema.rb"
|
|
529
550
|
@on = false
|
|
530
551
|
File.open(file_path, "a") do |new_line|
|
|
@@ -545,27 +566,28 @@ module Souls
|
|
|
545
566
|
end
|
|
546
567
|
|
|
547
568
|
def rspec_factory_end class_name: "souls"
|
|
548
|
-
file_path = "./spec/factories/#{class_name}
|
|
569
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
549
570
|
File.open(file_path, "a") do |f|
|
|
550
571
|
f.write <<~EOS
|
|
551
572
|
end
|
|
552
573
|
end
|
|
553
574
|
EOS
|
|
554
575
|
end
|
|
555
|
-
puts "FactoryBot #{class_name}
|
|
576
|
+
puts "FactoryBot #{class_name.pluralize}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
556
577
|
end
|
|
557
578
|
|
|
558
579
|
def rspec_factory class_name: "souls"
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
580
|
+
singularized_class_name = class_name.singularize
|
|
581
|
+
rspec_factory_head class_name: singularized_class_name
|
|
582
|
+
rspec_factory_params class_name: singularized_class_name
|
|
583
|
+
rspec_factory_end class_name: singularized_class_name
|
|
562
584
|
end
|
|
563
585
|
|
|
564
586
|
def rspec_model class_name: "souls"
|
|
565
587
|
file_path = "./spec/models/#{class_name}_spec.rb"
|
|
566
588
|
File.open(file_path, "w") do |f|
|
|
567
589
|
f.write <<~EOS
|
|
568
|
-
RSpec.describe #{class_name.
|
|
590
|
+
RSpec.describe #{class_name.camelize}, type: :model do
|
|
569
591
|
it "作成する" do
|
|
570
592
|
expect(FactoryBot.build(:#{class_name})).to be_valid
|
|
571
593
|
end
|
|
@@ -577,7 +599,7 @@ module Souls
|
|
|
577
599
|
end
|
|
578
600
|
EOS
|
|
579
601
|
end
|
|
580
|
-
puts "
|
|
602
|
+
puts "Rspec #{class_name}_spec.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
581
603
|
end
|
|
582
604
|
|
|
583
605
|
def rspec_mutation class_name: "souls"
|
data/lib/souls/version.rb
CHANGED