souls 0.13.4 → 0.13.9
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.lock +8 -8
- data/exe/souls +9 -7
- data/lib/souls/init.rb +391 -186
- data/lib/souls/version.rb +1 -1
- data/souls.gemspec +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbcbcf33c2d8228114814ed5964c6cca8aba01902b953908081fe83cd2a1bdbb
|
4
|
+
data.tar.gz: 449d4d9de9382a3887464ef61c90858bf46c0e20cfd25bd44eef3c5e278a0b8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9241c9826bbd18c5d2d27501de5ce55236ecab6099949d0725fd3147028276cf98bec9f775278e263960e20c402a85d80368982d3a49141eae181eec1b0dc6a4
|
7
|
+
data.tar.gz: cfa3dbb3166216147d3e4cce41d2a0ee78c7c3b40ba74df241393b8b2e41c691cd0961a04e834f84d71ffd65ce78dc32f04d81188f2ffcd0365189ccdb27dacd
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
souls (0.13.
|
4
|
+
souls (0.13.8)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -12,20 +12,20 @@ GEM
|
|
12
12
|
minitest (>= 5.1)
|
13
13
|
tzinfo (~> 2.0)
|
14
14
|
zeitwerk (~> 2.3)
|
15
|
-
ast (2.4.
|
15
|
+
ast (2.4.2)
|
16
16
|
ast_utils (0.3.0)
|
17
17
|
parser (~> 2.4)
|
18
18
|
thor (>= 0.19)
|
19
|
-
concurrent-ruby (1.1.
|
19
|
+
concurrent-ruby (1.1.8)
|
20
20
|
diff-lcs (1.4.4)
|
21
21
|
ffi (1.14.2)
|
22
22
|
i18n (1.8.7)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
24
|
language_server-protocol (3.15.0.1)
|
25
|
-
listen (3.4.
|
25
|
+
listen (3.4.1)
|
26
26
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
27
27
|
rb-inotify (~> 0.9, >= 0.9.10)
|
28
|
-
minitest (5.14.
|
28
|
+
minitest (5.14.3)
|
29
29
|
parallel (1.20.1)
|
30
30
|
parser (2.7.2.0)
|
31
31
|
ast (~> 2.4.1)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
rb-fsevent (0.10.4)
|
35
35
|
rb-inotify (0.10.1)
|
36
36
|
ffi (~> 1.0)
|
37
|
-
rbs (1.0.
|
37
|
+
rbs (1.0.4)
|
38
38
|
regexp_parser (2.0.3)
|
39
39
|
rexml (3.2.4)
|
40
40
|
rspec (3.1.0)
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
rubocop-ast (>= 1.2.0, < 2.0)
|
59
59
|
ruby-progressbar (~> 1.7)
|
60
60
|
unicode-display_width (>= 1.4.0, < 2.0)
|
61
|
-
rubocop-ast (1.4.
|
61
|
+
rubocop-ast (1.4.1)
|
62
62
|
parser (>= 2.7.1.5)
|
63
63
|
ruby-progressbar (1.11.0)
|
64
64
|
steep (0.39.0)
|
@@ -69,7 +69,7 @@ GEM
|
|
69
69
|
parser (~> 2.7.0)
|
70
70
|
rainbow (>= 2.2.2, < 4.0)
|
71
71
|
rbs (~> 1.0.0)
|
72
|
-
thor (1.0
|
72
|
+
thor (1.1.0)
|
73
73
|
tzinfo (2.0.4)
|
74
74
|
concurrent-ruby (~> 1.0)
|
75
75
|
unicode-display_width (1.7.0)
|
data/exe/souls
CHANGED
@@ -13,27 +13,27 @@ begin
|
|
13
13
|
puts "you need to specify your app name \n `souls new app_name`"
|
14
14
|
exit
|
15
15
|
end
|
16
|
-
puts "Which framework: \n 1. SOULS
|
16
|
+
puts "Which framework: \n 1. SOULS GraphQL API \n 2. SOULS GraphQL API gRPC compatible \n 3. SOULS gRPC Service \n 4. SOULS Media Web \n 5. SOULS Admin Web \n Enter Number: "
|
17
17
|
strain = STDIN.gets.chomp.to_i
|
18
18
|
(1..5).include?(strain) ? puts("Generating Souls.. \n") : raise(StandardError, "Choose Number 1..5")
|
19
19
|
Souls::Init.create_souls strain: strain, app_name: ARGV[1]
|
20
20
|
when "s", "server"
|
21
21
|
strain = Souls.configuration.strain
|
22
22
|
case strain
|
23
|
-
when "
|
24
|
-
system "
|
23
|
+
when "media", "admin"
|
24
|
+
system "yarn dev"
|
25
25
|
when "service"
|
26
26
|
system "bundle exec rake run_server"
|
27
27
|
else
|
28
|
-
system "
|
28
|
+
system "bundle exec puma -p 3000"
|
29
29
|
end
|
30
30
|
when "c", "console"
|
31
31
|
strain = Souls.configuration.strain
|
32
32
|
case strain
|
33
|
-
when "
|
34
|
-
system "bundle exec irb"
|
35
|
-
else
|
33
|
+
when "media", "admin"
|
36
34
|
system "yarn dev"
|
35
|
+
else
|
36
|
+
system "bundle exec irb"
|
37
37
|
end
|
38
38
|
when "i", "infra"
|
39
39
|
Souls.send ARGV[1]
|
@@ -45,6 +45,8 @@ begin
|
|
45
45
|
puts Souls::VERSION
|
46
46
|
when "g", "generate"
|
47
47
|
case ARGV[1]
|
48
|
+
when "test_dir"
|
49
|
+
Souls::Init.test_dir
|
48
50
|
when "test"
|
49
51
|
Souls::Init.single_migrate class_name: "user"
|
50
52
|
when "model"
|
data/lib/souls/init.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
STRAINS = ["
|
2
|
+
STRAINS = ["graph", "api", "service", "media", "admin"]
|
3
3
|
module Init
|
4
4
|
class << self
|
5
5
|
def create_souls strain: 1, app_name: "souls"
|
@@ -253,6 +253,19 @@ module Souls
|
|
253
253
|
[file_path]
|
254
254
|
end
|
255
255
|
|
256
|
+
def test_dir
|
257
|
+
FileUtils.mkdir_p "./app/graphql/mutations"
|
258
|
+
FileUtils.mkdir_p "./app/graphql/queries"
|
259
|
+
FileUtils.mkdir_p "./app/graphql/types"
|
260
|
+
FileUtils.mkdir_p "./spec/factories"
|
261
|
+
FileUtils.mkdir_p "./spec/queries"
|
262
|
+
FileUtils.mkdir_p "./spec/mutations"
|
263
|
+
FileUtils.mkdir_p "./spec/models"
|
264
|
+
FileUtils.mkdir_p "./db/"
|
265
|
+
FileUtils.touch "./db/schema.rb"
|
266
|
+
puts "test dir created!"
|
267
|
+
end
|
268
|
+
|
256
269
|
def type_check type
|
257
270
|
{
|
258
271
|
bigint: "Integer",
|
@@ -304,15 +317,36 @@ module Souls
|
|
304
317
|
file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
|
305
318
|
path = "./db/schema.rb"
|
306
319
|
@on = false
|
320
|
+
@user_exist = false
|
321
|
+
@relation_params = []
|
307
322
|
File.open(file_path, "a") do |new_line|
|
308
323
|
File.open(path, "r") do |f|
|
309
324
|
f.each_line.with_index do |line, i|
|
310
325
|
if @on
|
311
|
-
|
326
|
+
if line.include?("end") || line.include?("t.index")
|
327
|
+
if @user_exist
|
328
|
+
new_line.write <<-EOS
|
329
|
+
|
330
|
+
def resolve **args
|
331
|
+
args[:user_id] = context[:user].id
|
332
|
+
EOS
|
333
|
+
else
|
334
|
+
new_line.write <<-EOS
|
335
|
+
|
336
|
+
def resolve **args
|
337
|
+
EOS
|
338
|
+
end
|
339
|
+
break
|
340
|
+
end
|
312
341
|
field = "[String]" if line.include?("array: true")
|
313
342
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
314
343
|
field ||= type_check type
|
315
344
|
case name
|
345
|
+
when "user_id"
|
346
|
+
@user_exist = true
|
347
|
+
when /$*_id\z/
|
348
|
+
@relation_params << name
|
349
|
+
new_line.write " argument :#{name}, String, required: false\n"
|
316
350
|
when "created_at", "updated_at"
|
317
351
|
next
|
318
352
|
else
|
@@ -323,14 +357,24 @@ module Souls
|
|
323
357
|
end
|
324
358
|
end
|
325
359
|
end
|
360
|
+
@relation_params
|
361
|
+
end
|
362
|
+
|
363
|
+
def create_mutation_after_params class_name: "article", relation_params: []
|
364
|
+
return false if relation_params.empty?
|
365
|
+
file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
|
366
|
+
relation_params.each do |params_name|
|
367
|
+
File.open(file_path, "a") do |new_line|
|
368
|
+
new_line.write " _, args[:#{params_name}] = SoulsApiSchema.from_global_id(args[:#{params_name}])\n"
|
369
|
+
end
|
370
|
+
end
|
371
|
+
true
|
326
372
|
end
|
327
373
|
|
328
374
|
def create_mutation_end class_name: "souls"
|
329
375
|
file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
|
330
376
|
File.open(file_path, "a") do |new_line|
|
331
377
|
new_line.write <<~EOS
|
332
|
-
|
333
|
-
def resolve **args
|
334
378
|
#{class_name} = ::#{class_name.camelize}.new args
|
335
379
|
if #{class_name}.save
|
336
380
|
{ #{class_name}: #{class_name} }
|
@@ -357,6 +401,7 @@ module Souls
|
|
357
401
|
class Update#{class_name.camelize} < BaseMutation
|
358
402
|
field :#{class_name}, Types::#{class_name.camelize}Type, null: false
|
359
403
|
|
404
|
+
argument :id, String, required: true
|
360
405
|
EOS
|
361
406
|
end
|
362
407
|
end
|
@@ -365,15 +410,38 @@ module Souls
|
|
365
410
|
file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
|
366
411
|
path = "./db/schema.rb"
|
367
412
|
@on = false
|
413
|
+
@user_exist = false
|
414
|
+
@relation_params = []
|
368
415
|
File.open(file_path, "a") do |new_line|
|
369
416
|
File.open(path, "r") do |f|
|
370
417
|
f.each_line.with_index do |line, i|
|
371
418
|
if @on
|
372
|
-
|
419
|
+
if line.include?("end") || line.include?("t.index")
|
420
|
+
if @user_exist
|
421
|
+
new_line.write <<-EOS
|
422
|
+
|
423
|
+
def resolve **args
|
424
|
+
args[:user_id] = context[:user].id
|
425
|
+
_, args[:id] = SoulsApiSchema.from_global_id(args[:id])
|
426
|
+
EOS
|
427
|
+
else
|
428
|
+
new_line.write <<-EOS
|
429
|
+
|
430
|
+
def resolve **args
|
431
|
+
_, args[:id] = SoulsApiSchema.from_global_id(args[:id])
|
432
|
+
EOS
|
433
|
+
end
|
434
|
+
break
|
435
|
+
end
|
373
436
|
field = "[String]" if line.include?("array: true")
|
374
437
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
375
438
|
field ||= type_check type
|
376
439
|
case name
|
440
|
+
when "user_id"
|
441
|
+
@user_exist = true
|
442
|
+
when /$*_id\z/
|
443
|
+
@relation_params << name
|
444
|
+
new_line.write " argument :#{name}, String, required: false\n"
|
377
445
|
when "created_at", "updated_at"
|
378
446
|
next
|
379
447
|
else
|
@@ -384,14 +452,24 @@ module Souls
|
|
384
452
|
end
|
385
453
|
end
|
386
454
|
end
|
455
|
+
@relation_params
|
456
|
+
end
|
457
|
+
|
458
|
+
def update_mutation_after_params class_name: "article", relation_params: []
|
459
|
+
return false if relation_params.empty?
|
460
|
+
file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
|
461
|
+
relation_params.each do |params_name|
|
462
|
+
File.open(file_path, "a") do |new_line|
|
463
|
+
new_line.write " _, args[:#{params_name}] = SoulsApiSchema.from_global_id(args[:#{params_name}])\n"
|
464
|
+
end
|
465
|
+
end
|
466
|
+
true
|
387
467
|
end
|
388
468
|
|
389
469
|
def update_mutation_end class_name: "souls"
|
390
470
|
file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
|
391
471
|
File.open(file_path, "a") do |new_line|
|
392
472
|
new_line.write <<~EOS
|
393
|
-
|
394
|
-
def resolve **args
|
395
473
|
#{class_name} = ::#{class_name.camelize}.find args[:id]
|
396
474
|
#{class_name}.update args
|
397
475
|
{ #{class_name}: ::#{class_name.camelize}.find(args[:id]) }
|
@@ -408,7 +486,8 @@ module Souls
|
|
408
486
|
|
409
487
|
def update_mutation class_name: "souls"
|
410
488
|
update_mutation_head class_name: class_name
|
411
|
-
update_mutation_params class_name: class_name
|
489
|
+
relation_params = update_mutation_params class_name: class_name
|
490
|
+
update_mutation_after_params class_name: class_name, relation_params: relation_params
|
412
491
|
update_mutation_end class_name: class_name
|
413
492
|
end
|
414
493
|
|
@@ -420,10 +499,11 @@ module Souls
|
|
420
499
|
module #{class_name.camelize}
|
421
500
|
class Delete#{class_name.camelize} < BaseMutation
|
422
501
|
field :#{class_name}, Types::#{class_name.camelize}Type, null: false
|
423
|
-
argument :id,
|
502
|
+
argument :id, String, required: true
|
424
503
|
|
425
|
-
def resolve
|
426
|
-
|
504
|
+
def resolve **args
|
505
|
+
_, data_id = SoulsApiSchema.from_global_id args[:id]
|
506
|
+
#{class_name} = ::#{class_name.camelize}.find data_id
|
427
507
|
#{class_name}.destroy
|
428
508
|
{ #{class_name}: #{class_name} }
|
429
509
|
rescue StandardError => error
|
@@ -452,7 +532,8 @@ module Souls
|
|
452
532
|
Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
|
453
533
|
end
|
454
534
|
create_mutation_head class_name: singularized_class_name
|
455
|
-
create_mutation_params class_name: singularized_class_name
|
535
|
+
relation_params = create_mutation_params class_name: singularized_class_name
|
536
|
+
create_mutation_after_params class_name: singularized_class_name, relation_params: relation_params
|
456
537
|
[
|
457
538
|
create_mutation_end(class_name: singularized_class_name),
|
458
539
|
update_mutation(class_name: singularized_class_name),
|
@@ -490,8 +571,8 @@ module Souls
|
|
490
571
|
argument :id, String, required: true
|
491
572
|
|
492
573
|
def resolve **args
|
493
|
-
_,
|
494
|
-
::#{class_name.camelize}.find(
|
574
|
+
_, data_id = SoulsApiSchema.from_global_id args[:id]
|
575
|
+
::#{class_name.camelize}.find(data_id)
|
495
576
|
rescue StandardError => error
|
496
577
|
GraphQL::ExecutionError.new error
|
497
578
|
end
|
@@ -531,7 +612,12 @@ module Souls
|
|
531
612
|
field = "[String]" if line.include?("array: true")
|
532
613
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
533
614
|
field ||= type_check type
|
534
|
-
|
615
|
+
case name
|
616
|
+
when /$*_id\z/
|
617
|
+
new_line.write " field :#{name.gsub("_id", "")}, Types::#{name.gsub("_id", "").singularize.camelize}Type, null: false\n"
|
618
|
+
else
|
619
|
+
new_line.write " field :#{name}, #{field}, null: true\n"
|
620
|
+
end
|
535
621
|
end
|
536
622
|
if table_check(line: line, class_name: class_name)
|
537
623
|
@on = true
|
@@ -637,62 +723,134 @@ module Souls
|
|
637
723
|
f.write <<~EOS
|
638
724
|
RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
|
639
725
|
describe "#{class_name.camelize} データを登録する" do
|
640
|
-
let(:#{class_name.singularize.underscore}) { FactoryBot.attributes_for(:#{class_name.singularize.underscore}) }
|
641
|
-
|
642
|
-
let(:mutation) do
|
643
|
-
%(mutation {
|
644
|
-
create#{class_name.camelize}(input: {
|
645
726
|
EOS
|
646
727
|
end
|
647
728
|
end
|
648
729
|
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
730
|
+
def rspec_mutation_after_head class_name: "souls"
|
731
|
+
file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
|
732
|
+
path = "./db/schema.rb"
|
733
|
+
@on = false
|
734
|
+
@user_exist = false
|
735
|
+
@relation_params = []
|
736
|
+
File.open(file_path, "a") do |new_line|
|
737
|
+
File.open(path, "r") do |f|
|
738
|
+
f.each_line.with_index do |line, i|
|
739
|
+
if @on
|
740
|
+
if line.include?("end") || line.include?("t.index")
|
741
|
+
if @relation_params.empty?
|
742
|
+
new_line.write <<-EOS
|
743
|
+
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}) }
|
744
|
+
|
745
|
+
let(:mutation) do
|
746
|
+
%(mutation {
|
747
|
+
create#{class_name.camelize}(input: {
|
748
|
+
EOS
|
666
749
|
else
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
end
|
750
|
+
new_line.write <<-EOS
|
751
|
+
|
752
|
+
get_global_key = proc { |class_name, id| Base64.encode64(\"\#{class_name}:\#{id}\") }
|
753
|
+
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(", ")}) }
|
754
|
+
|
755
|
+
let(:mutation) do
|
756
|
+
%(mutation {
|
757
|
+
create#{class_name.camelize}(input: {
|
758
|
+
EOS
|
677
759
|
end
|
760
|
+
break
|
678
761
|
end
|
679
|
-
|
680
|
-
|
762
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
763
|
+
case name
|
764
|
+
when "user_id"
|
765
|
+
relation_col = name.gsub("_id", "")
|
766
|
+
new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
|
767
|
+
when /$*_id\z/
|
768
|
+
relation_col = name.gsub("_id", "")
|
769
|
+
@relation_params << "#{name}: get_global_key.call(\"#{name.singularize.camelize.gsub("Id", "")}\", #{relation_col}.id)"
|
770
|
+
new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
|
681
771
|
end
|
682
772
|
end
|
773
|
+
if table_check(line: line, class_name: class_name)
|
774
|
+
@on = true
|
775
|
+
end
|
683
776
|
end
|
684
777
|
end
|
685
778
|
end
|
779
|
+
end
|
686
780
|
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
781
|
+
def rspec_mutation_params class_name: "souls"
|
782
|
+
file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
|
783
|
+
path = "./db/schema.rb"
|
784
|
+
@on = false
|
785
|
+
@user_exist = false
|
786
|
+
File.open(file_path, "a") do |new_line|
|
787
|
+
File.open(path, "r") do |f|
|
788
|
+
f.each_line.with_index do |line, i|
|
789
|
+
if @on
|
790
|
+
if line.include?("end") || line.include?("t.index")
|
791
|
+
new_line.write " }) {\n #{class_name.singularize.camelize(:lower)} {\n id\n"
|
792
|
+
break
|
793
|
+
end
|
794
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
795
|
+
array_true = line.include?("array: true")
|
796
|
+
case name
|
797
|
+
when "created_at", "updated_at"
|
798
|
+
next
|
799
|
+
when "user_id"
|
800
|
+
@user_exist = true
|
801
|
+
when /$*_id\z/
|
802
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
803
|
+
else
|
804
|
+
case type
|
805
|
+
when "string", "text", "date", "datetime"
|
806
|
+
if array_true
|
807
|
+
new_line.write " #{name.pluralize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
|
808
|
+
else
|
809
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
810
|
+
end
|
811
|
+
when "bigint", "integer", "float", "boolean"
|
812
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
813
|
+
end
|
814
|
+
end
|
815
|
+
end
|
816
|
+
if table_check(line: line, class_name: class_name)
|
817
|
+
@on = true
|
818
|
+
end
|
819
|
+
end
|
820
|
+
end
|
821
|
+
end
|
822
|
+
end
|
823
|
+
|
824
|
+
def rspec_mutation_params_response class_name: "souls"
|
825
|
+
file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
|
826
|
+
path = "./db/schema.rb"
|
827
|
+
@on = false
|
828
|
+
File.open(file_path, "a") do |new_line|
|
829
|
+
File.open(path, "r") do |f|
|
830
|
+
f.each_line.with_index do |line, i|
|
831
|
+
if @on
|
832
|
+
if line.include?("end") || line.include?("t.index")
|
833
|
+
if @user_exist
|
834
|
+
new_line.write <<-EOS
|
835
|
+
}
|
836
|
+
}
|
837
|
+
}
|
838
|
+
)
|
839
|
+
end
|
840
|
+
|
841
|
+
subject(:result) do
|
842
|
+
context = {
|
843
|
+
user: user
|
844
|
+
}
|
845
|
+
SoulsApiSchema.execute(mutation, context: context).as_json
|
846
|
+
end
|
847
|
+
|
848
|
+
it "return #{class_name.camelize} Data" do
|
849
|
+
a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}")
|
850
|
+
expect(a1).to include(
|
851
|
+
"id" => be_a(String),
|
852
|
+
EOS
|
853
|
+
else
|
696
854
|
new_line.write <<-EOS
|
697
855
|
}
|
698
856
|
}
|
@@ -709,79 +867,81 @@ module Souls
|
|
709
867
|
expect(a1).to include(
|
710
868
|
"id" => be_a(String),
|
711
869
|
EOS
|
712
|
-
break
|
713
870
|
end
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
871
|
+
break
|
872
|
+
end
|
873
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
874
|
+
array_true = line.include?("array: true")
|
875
|
+
case name
|
876
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
877
|
+
next
|
878
|
+
else
|
879
|
+
if array_true
|
880
|
+
new_line.write " #{name.pluralize.camelize(:lower)}\n"
|
719
881
|
else
|
720
|
-
|
721
|
-
new_line.write " #{name.pluralize.camelize(:lower)}\n"
|
722
|
-
else
|
723
|
-
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
724
|
-
end
|
882
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
725
883
|
end
|
726
884
|
end
|
727
|
-
|
728
|
-
|
729
|
-
|
885
|
+
end
|
886
|
+
if table_check(line: line, class_name: class_name)
|
887
|
+
@on = true
|
730
888
|
end
|
731
889
|
end
|
732
890
|
end
|
733
891
|
end
|
892
|
+
end
|
734
893
|
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
end
|
749
|
-
EOS
|
750
|
-
break
|
751
|
-
end
|
752
|
-
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
753
|
-
field ||= type_check type
|
754
|
-
array_true = line.include?("array: true")
|
755
|
-
case name
|
756
|
-
when "created_at", "updated_at"
|
757
|
-
next
|
758
|
-
else
|
759
|
-
case type
|
760
|
-
when "text", "date", "datetime"
|
761
|
-
if array_true
|
762
|
-
new_line.write " \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n"
|
763
|
-
else
|
764
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
|
894
|
+
def rspec_mutation_end class_name: "souls"
|
895
|
+
file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
|
896
|
+
path = "./db/schema.rb"
|
897
|
+
@on = false
|
898
|
+
File.open(file_path, "a") do |new_line|
|
899
|
+
File.open(path, "r") do |f|
|
900
|
+
f.each_line.with_index do |line, i|
|
901
|
+
if @on
|
902
|
+
if line.include?("end") || line.include?("t.index")
|
903
|
+
new_line.write <<~EOS
|
904
|
+
)
|
905
|
+
end
|
906
|
+
end
|
765
907
|
end
|
766
|
-
|
767
|
-
|
768
|
-
when "string", "bigint", "integer", "float"
|
769
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
770
|
-
end
|
771
|
-
end
|
908
|
+
EOS
|
909
|
+
break
|
772
910
|
end
|
773
|
-
|
774
|
-
|
911
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
912
|
+
field ||= type_check type
|
913
|
+
array_true = line.include?("array: true")
|
914
|
+
case name
|
915
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
916
|
+
next
|
917
|
+
else
|
918
|
+
case type
|
919
|
+
when "text", "date", "datetime"
|
920
|
+
if array_true
|
921
|
+
new_line.write " \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n"
|
922
|
+
else
|
923
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
|
924
|
+
end
|
925
|
+
when "boolean"
|
926
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
|
927
|
+
when "string", "bigint", "integer", "float"
|
928
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
929
|
+
end
|
775
930
|
end
|
776
931
|
end
|
932
|
+
if table_check(line: line, class_name: class_name)
|
933
|
+
@on = true
|
934
|
+
end
|
777
935
|
end
|
778
936
|
end
|
779
|
-
[file_path]
|
780
937
|
end
|
938
|
+
[file_path]
|
939
|
+
end
|
781
940
|
|
782
941
|
def rspec_mutation class_name: "souls"
|
783
942
|
singularized_class_name = class_name.singularize
|
784
943
|
rspec_mutation_head class_name: singularized_class_name
|
944
|
+
rspec_mutation_after_head class_name: singularized_class_name
|
785
945
|
rspec_mutation_params class_name: singularized_class_name
|
786
946
|
rspec_mutation_params_response class_name: singularized_class_name
|
787
947
|
rspec_mutation_end class_name: singularized_class_name
|
@@ -793,109 +953,154 @@ end
|
|
793
953
|
f.write <<~EOS
|
794
954
|
RSpec.describe \"#{class_name.camelize} Query テスト\" do
|
795
955
|
describe "#{class_name.camelize} データを取得する" do
|
796
|
-
let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
|
797
|
-
|
798
|
-
let(:query) do
|
799
|
-
data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
|
800
|
-
%(query {
|
801
|
-
#{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
|
802
|
-
id
|
803
956
|
EOS
|
804
957
|
end
|
805
958
|
end
|
806
959
|
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
960
|
+
def rspec_query_after_head class_name: "souls"
|
961
|
+
file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
|
962
|
+
path = "./db/schema.rb"
|
963
|
+
@on = false
|
964
|
+
@user_exist = false
|
965
|
+
@relation_params = []
|
966
|
+
File.open(file_path, "a") do |new_line|
|
967
|
+
File.open(path, "r") do |f|
|
968
|
+
f.each_line.with_index do |line, i|
|
969
|
+
if @on
|
970
|
+
if line.include?("end") || line.include?("t.index")
|
971
|
+
if @relation_params.empty?
|
972
|
+
new_line.write <<-EOS
|
973
|
+
let(:#{class_name}) { FactoryBot.create(:#{class_name} }
|
974
|
+
|
975
|
+
let(:query) do
|
976
|
+
data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
|
977
|
+
%(query {
|
978
|
+
#{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
|
979
|
+
id
|
980
|
+
EOS
|
981
|
+
break
|
982
|
+
else
|
983
|
+
new_line.write <<-EOS
|
984
|
+
let(:#{class_name}) { FactoryBot.create(:#{class_name}, #{@relation_params.join(", ")}) }
|
985
|
+
|
986
|
+
let(:query) do
|
987
|
+
data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
|
988
|
+
%(query {
|
989
|
+
#{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
|
990
|
+
id
|
991
|
+
EOS
|
992
|
+
break
|
993
|
+
end
|
994
|
+
end
|
995
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
996
|
+
case name
|
997
|
+
when /$*_id\z/
|
998
|
+
relation_col = name.gsub("_id", "")
|
999
|
+
@relation_params << "#{name}: #{relation_col}.id"
|
1000
|
+
new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
if table_check(line: line, class_name: class_name)
|
1004
|
+
@on = true
|
1005
|
+
end
|
1006
|
+
end
|
1007
|
+
end
|
1008
|
+
end
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
def rspec_query_params class_name: "souls"
|
1012
|
+
file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
|
1013
|
+
path = "./db/schema.rb"
|
1014
|
+
@on = false
|
1015
|
+
File.open(file_path, "a") do |new_line|
|
1016
|
+
File.open(path, "r") do |f|
|
1017
|
+
f.each_line.with_index do |line, i|
|
1018
|
+
if @on
|
1019
|
+
if line.include?("end") || line.include?("t.index")
|
1020
|
+
new_line.write <<-EOS
|
818
1021
|
}
|
819
|
-
|
820
|
-
|
1022
|
+
}
|
1023
|
+
)
|
1024
|
+
end
|
821
1025
|
|
822
|
-
|
823
|
-
|
824
|
-
|
1026
|
+
subject(:result) do
|
1027
|
+
SoulsApiSchema.execute(query).as_json
|
1028
|
+
end
|
825
1029
|
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
end
|
833
|
-
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
834
|
-
case name
|
835
|
-
when "created_at", "updated_at"
|
836
|
-
next
|
837
|
-
else
|
838
|
-
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
839
|
-
end
|
1030
|
+
it "return #{class_name.camelize} Data" do
|
1031
|
+
a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}")
|
1032
|
+
expect(a1).to include(
|
1033
|
+
"id" => be_a(String),
|
1034
|
+
EOS
|
1035
|
+
break
|
840
1036
|
end
|
841
|
-
|
842
|
-
|
1037
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
1038
|
+
case name
|
1039
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
1040
|
+
next
|
1041
|
+
else
|
1042
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
843
1043
|
end
|
844
1044
|
end
|
1045
|
+
if table_check(line: line, class_name: class_name)
|
1046
|
+
@on = true
|
1047
|
+
end
|
845
1048
|
end
|
846
1049
|
end
|
847
1050
|
end
|
1051
|
+
end
|
848
1052
|
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
1053
|
+
def rspec_query_end class_name: "souls"
|
1054
|
+
file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
|
1055
|
+
path = "./db/schema.rb"
|
1056
|
+
@on = false
|
1057
|
+
File.open(file_path, "a") do |new_line|
|
1058
|
+
File.open(path, "r") do |f|
|
1059
|
+
f.each_line.with_index do |line, i|
|
1060
|
+
if @on
|
1061
|
+
if line.include?("end") || line.include?("t.index")
|
1062
|
+
new_line.write <<-EOS
|
859
1063
|
)
|
860
1064
|
end
|
861
1065
|
end
|
862
1066
|
end
|
863
|
-
|
864
|
-
|
865
|
-
end
|
866
|
-
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
867
|
-
field ||= type_check type
|
868
|
-
array_true = line.include?("array: true")
|
869
|
-
case name
|
870
|
-
when "created_at", "updated_at"
|
871
|
-
next
|
872
|
-
else
|
873
|
-
case type
|
874
|
-
when "text", "date", "datetime"
|
875
|
-
if array_true
|
876
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
|
877
|
-
else
|
878
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
|
879
|
-
end
|
880
|
-
when "boolean"
|
881
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
|
882
|
-
when "string", "bigint", "integer", "float"
|
883
|
-
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
884
|
-
end
|
885
|
-
end
|
1067
|
+
EOS
|
1068
|
+
break
|
886
1069
|
end
|
887
|
-
|
888
|
-
|
1070
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
1071
|
+
field ||= type_check type
|
1072
|
+
array_true = line.include?("array: true")
|
1073
|
+
case name
|
1074
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
1075
|
+
next
|
1076
|
+
else
|
1077
|
+
case type
|
1078
|
+
when "text", "date", "datetime"
|
1079
|
+
if array_true
|
1080
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
|
1081
|
+
else
|
1082
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
|
1083
|
+
end
|
1084
|
+
when "boolean"
|
1085
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
|
1086
|
+
when "string", "bigint", "integer", "float"
|
1087
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
1088
|
+
end
|
889
1089
|
end
|
890
1090
|
end
|
1091
|
+
if table_check(line: line, class_name: class_name)
|
1092
|
+
@on = true
|
1093
|
+
end
|
891
1094
|
end
|
892
1095
|
end
|
893
|
-
[file_path]
|
894
1096
|
end
|
1097
|
+
[file_path]
|
1098
|
+
end
|
895
1099
|
|
896
1100
|
def rspec_query class_name: "souls"
|
897
1101
|
singularized_class_name = class_name.singularize
|
898
1102
|
rspec_query_head class_name: singularized_class_name
|
1103
|
+
rspec_query_after_head class_name: singularized_class_name
|
899
1104
|
rspec_query_params class_name: singularized_class_name
|
900
1105
|
rspec_query_end class_name: singularized_class_name
|
901
1106
|
end
|
data/lib/souls/version.rb
CHANGED
data/souls.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/souls/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "souls"
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["POPPIN-FUMI", "KishiTheMechanic", "James Neve"]
|
7
7
|
spec.email = ["fumitake.kawasaki@el-soul.com", "shota.kishi@el-soul.com", "jamesoneve@gmail.com"]
|
8
8
|
|
9
|
-
spec.summary = "SOULS is a Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
|
9
|
+
spec.summary = "SOULS is a GraphQL Based Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
|
10
10
|
spec.description = "SOULS is a Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
|
11
11
|
spec.homepage = "https://github.com/elsoul/souls"
|
12
12
|
spec.license = "Apache-2.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SOULS is a Web Application Framework for Microservices on Multi Cloud
|
16
16
|
Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|
@@ -72,7 +72,8 @@ requirements: []
|
|
72
72
|
rubygems_version: 3.2.3
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
|
-
summary: SOULS is a Web Application Framework for Microservices on Multi
|
76
|
-
such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|
77
|
-
with scalable condition. You can focus on business logic. No more infra
|
75
|
+
summary: SOULS is a GraphQL Based Web Application Framework for Microservices on Multi
|
76
|
+
Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|
77
|
+
Auto deploy with scalable condition. You can focus on business logic. No more infra
|
78
|
+
problems.
|
78
79
|
test_files: []
|