souls 0.8.6 → 0.8.7
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/.gitignore +1 -1
- data/.rubocop.yml +6 -1
- data/Gemfile.lock +1 -1
- data/exe/souls +4 -0
- data/lib/souls/init.rb +259 -27
- data/lib/souls/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46e7d4670ab49a147d4f62b0dbf14872051c8c30bf3bdc01f49cf30d48f91205
|
|
4
|
+
data.tar.gz: bb3be9fcb27284432fd0052c71769f131af513a1a606e201f21dc9601b97c043
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f906bfa46081147867fc125f8dc8dd3806cbf39fce4605f9454481d0299ecefa77e0faad71941f9d7ab3dd6d48225bde24d6998e79458ce8773274d2b42fd95
|
|
7
|
+
data.tar.gz: b84307ee1d465c28e6296a091a470b5fe3a8b8e8dd24d38ac773cb2de3b4bdb9c01f7b40c92b62e540441a3c2b7ee6f1ec775fb777c8b1b0ff444085a26c71f1
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
|
@@ -47,6 +47,8 @@ begin
|
|
|
47
47
|
puts Souls::VERSION
|
|
48
48
|
when "g", "generate"
|
|
49
49
|
case ARGV[1]
|
|
50
|
+
when "test"
|
|
51
|
+
Souls::Init.delete_mutation class_name: "article"
|
|
50
52
|
when "model"
|
|
51
53
|
Souls::Init.model class_name: ARGV[2]
|
|
52
54
|
when "mutation"
|
|
@@ -57,6 +59,8 @@ begin
|
|
|
57
59
|
Souls::Init.type class_name: ARGV[2]
|
|
58
60
|
when "migration"
|
|
59
61
|
Souls::Init.migration class_name: ARGV[2]
|
|
62
|
+
when "rspec_factory"
|
|
63
|
+
Souls::Init.rspec_factory class_name: ARGV[2]
|
|
60
64
|
when "rspec_model"
|
|
61
65
|
Souls::Init.rspec_model class_name: ARGV[2]
|
|
62
66
|
when "rspec_mutation"
|
data/lib/souls/init.rb
CHANGED
|
@@ -254,21 +254,71 @@ module Souls
|
|
|
254
254
|
puts "model #{class_name}.rb created!: `#{file_path}`"
|
|
255
255
|
end
|
|
256
256
|
|
|
257
|
-
def
|
|
257
|
+
def type_check type
|
|
258
|
+
{
|
|
259
|
+
bigint: "Integer",
|
|
260
|
+
string: "String",
|
|
261
|
+
text: "String",
|
|
262
|
+
datetime: "GraphQL::Types::ISO8601DateTime",
|
|
263
|
+
boolean: "Boolean",
|
|
264
|
+
integer: "Integer"
|
|
265
|
+
}[type.to_sym]
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def get_test_type type
|
|
269
|
+
{
|
|
270
|
+
bigint: 1,
|
|
271
|
+
string: '"MyString"',
|
|
272
|
+
text: '"MyString"',
|
|
273
|
+
datetime: "Time.now",
|
|
274
|
+
boolean: false,
|
|
275
|
+
integer: 1
|
|
276
|
+
}[type.to_sym]
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def table_check line: "", class_name: ""
|
|
280
|
+
if line.include?("create_table")
|
|
281
|
+
return true if line.split(" ")[1].gsub("\"", "").gsub(",", "") == "#{class_name}s"
|
|
282
|
+
end
|
|
283
|
+
false
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def create_mutation_head class_name: "souls"
|
|
258
287
|
file_path = "./app/graphql/mutations/create_#{class_name}.rb"
|
|
259
|
-
File.open(file_path, "w") do |
|
|
260
|
-
|
|
288
|
+
File.open(file_path, "w") do |new_line|
|
|
289
|
+
new_line.write <<~EOS
|
|
261
290
|
module Mutations
|
|
262
291
|
class Create#{class_name.capitalize} < BaseMutation
|
|
263
292
|
field :#{class_name}, Types::#{class_name.capitalize}Type, null: false
|
|
264
293
|
field :error, String, null: true
|
|
265
294
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
295
|
+
EOS
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def create_mutation_params class_name: "souls"
|
|
300
|
+
file_path = "./app/graphql/mutations/create_#{class_name}.rb"
|
|
301
|
+
path = "./db/schema.rb"
|
|
302
|
+
@on = false
|
|
303
|
+
File.open(file_path, "a") do |new_line|
|
|
304
|
+
File.open(path, "r") do |f|
|
|
305
|
+
f.each_line.with_index do |line, i|
|
|
306
|
+
if @on
|
|
307
|
+
break if line.include?("end") || line.include?("t.index")
|
|
308
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
309
|
+
field = type_check type
|
|
310
|
+
new_line.write " argument :#{name}, #{field}, required: false\n"
|
|
311
|
+
end
|
|
312
|
+
@on = true if table_check(line: line, class_name: class_name)
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def create_mutation_end class_name: "souls"
|
|
319
|
+
file_path = "./app/graphql/mutations/create_#{class_name}.rb"
|
|
320
|
+
File.open(file_path, "a") do |new_line|
|
|
321
|
+
new_line.write <<~EOS
|
|
272
322
|
|
|
273
323
|
def resolve **args
|
|
274
324
|
#{class_name} = #{class_name.capitalize}.new args
|
|
@@ -284,7 +334,94 @@ module Souls
|
|
|
284
334
|
end
|
|
285
335
|
EOS
|
|
286
336
|
end
|
|
287
|
-
puts "
|
|
337
|
+
puts "Mutation create_#{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def update_mutation_head class_name: "souls"
|
|
341
|
+
file_path = "./app/graphql/mutations/update_#{class_name}.rb"
|
|
342
|
+
File.open(file_path, "w") do |new_line|
|
|
343
|
+
new_line.write <<~EOS
|
|
344
|
+
module Mutations
|
|
345
|
+
class Update#{class_name.capitalize} < BaseMutation
|
|
346
|
+
field :#{class_name}, Types::#{class_name.capitalize}Type, null: false
|
|
347
|
+
|
|
348
|
+
EOS
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def update_mutation_params class_name: "souls"
|
|
353
|
+
file_path = "./app/graphql/mutations/update_#{class_name}.rb"
|
|
354
|
+
path = "./db/schema.rb"
|
|
355
|
+
@on = false
|
|
356
|
+
File.open(file_path, "a") do |new_line|
|
|
357
|
+
File.open(path, "r") do |f|
|
|
358
|
+
f.each_line.with_index do |line, i|
|
|
359
|
+
if @on
|
|
360
|
+
break if line.include?("end") || line.include?("t.index")
|
|
361
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
362
|
+
field = type_check type
|
|
363
|
+
new_line.write " argument :#{name}, #{field}, required: false\n"
|
|
364
|
+
end
|
|
365
|
+
@on = true if table_check(line: line, class_name: class_name)
|
|
366
|
+
end
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def update_mutation_end class_name: "souls"
|
|
372
|
+
file_path = "./app/graphql/mutations/update_#{class_name}.rb"
|
|
373
|
+
File.open(file_path, "a") do |new_line|
|
|
374
|
+
new_line.write <<~EOS
|
|
375
|
+
|
|
376
|
+
def resolve **args
|
|
377
|
+
#{class_name} = #{class_name.capitalize}.find args[:id]
|
|
378
|
+
#{class_name}.update args
|
|
379
|
+
{ #{class_name}: #{class_name.capitalize}.find(args[:id]) }
|
|
380
|
+
rescue StandardError => error
|
|
381
|
+
GraphQL::ExecutionError.new error
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
EOS
|
|
386
|
+
end
|
|
387
|
+
puts "Mutation update_#{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def update_mutation class_name: "souls"
|
|
391
|
+
update_mutation_head class_name: class_name
|
|
392
|
+
update_mutation_params class_name: class_name
|
|
393
|
+
update_mutation_end class_name: class_name
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def delete_mutation class_name: "souls"
|
|
397
|
+
file_path = "./app/graphql/mutations/delete_#{class_name}.rb"
|
|
398
|
+
File.open(file_path, "w") do |f|
|
|
399
|
+
f.write <<~EOS
|
|
400
|
+
module Mutations
|
|
401
|
+
class Delete#{class_name.capitalize} < BaseMutation
|
|
402
|
+
field :#{class_name}, Types::#{class_name.capitalize}Type, null: false
|
|
403
|
+
argument :id, Integer, required: true
|
|
404
|
+
|
|
405
|
+
def resolve id:
|
|
406
|
+
#{class_name} = #{class_name.capitalize}.find id
|
|
407
|
+
#{class_name}.destroy
|
|
408
|
+
{ #{class_name}: #{class_name} }
|
|
409
|
+
rescue StandardError => error
|
|
410
|
+
GraphQL::ExecutionError.new error
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
EOS
|
|
415
|
+
end
|
|
416
|
+
puts "Mutation create_#{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
def mutation class_name: "souls"
|
|
420
|
+
create_mutation_head class_name: class_name
|
|
421
|
+
create_mutation_params class_name: class_name
|
|
422
|
+
create_mutation_end class_name: class_name
|
|
423
|
+
update_mutation class_name: class_name
|
|
424
|
+
delete_mutation class_name: class_name
|
|
288
425
|
end
|
|
289
426
|
|
|
290
427
|
def query class_name: "souls"
|
|
@@ -325,29 +462,103 @@ module Souls
|
|
|
325
462
|
end
|
|
326
463
|
end
|
|
327
464
|
|
|
328
|
-
def
|
|
465
|
+
def create_type_head class_name: "souls"
|
|
466
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
|
467
|
+
File.open(file_path, "w") do |f|
|
|
468
|
+
f.write <<~EOS
|
|
469
|
+
module Types
|
|
470
|
+
class #{class_name.capitalize}Type < GraphQL::Schema::Object
|
|
471
|
+
implements GraphQL::Types::Relay::Node
|
|
472
|
+
|
|
473
|
+
EOS
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
def create_type_params class_name: "souls"
|
|
329
478
|
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
|
479
|
+
path = "./db/schema.rb"
|
|
480
|
+
@on = false
|
|
481
|
+
File.open(file_path, "a") do |new_line|
|
|
482
|
+
File.open(path, "r") do |f|
|
|
483
|
+
f.each_line.with_index do |line, i|
|
|
484
|
+
if @on
|
|
485
|
+
new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
|
|
486
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
487
|
+
field = type_check type
|
|
488
|
+
new_line.write " field :#{name}, #{field}, null: true\n"
|
|
489
|
+
end
|
|
490
|
+
if table_check(line: line, class_name: class_name)
|
|
491
|
+
@on = true
|
|
492
|
+
new_line.write " global_id_field :id\n"
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
def create_type_end class_name: "souls"
|
|
500
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
|
501
|
+
File.open(file_path, "a") do |f|
|
|
502
|
+
f.write <<~EOS
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
EOS
|
|
506
|
+
end
|
|
507
|
+
puts "Type #{class_name}_type.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
def type class_name: "souls"
|
|
511
|
+
create_type_head class_name: class_name
|
|
512
|
+
create_type_params class_name: class_name
|
|
513
|
+
create_type_end class_name: class_name
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
def rspec_factory_head class_name: "souls"
|
|
517
|
+
file_path = "./spec/factories/#{class_name}s.rb"
|
|
330
518
|
File.open(file_path, "w") do |f|
|
|
331
519
|
f.write <<~EOS
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
520
|
+
FactoryBot.define do
|
|
521
|
+
factory :#{class_name} do
|
|
522
|
+
EOS
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
def rspec_factory_params class_name: "souls"
|
|
527
|
+
file_path = "./spec/factories/#{class_name}s.rb"
|
|
528
|
+
path = "./db/schema.rb"
|
|
529
|
+
@on = false
|
|
530
|
+
File.open(file_path, "a") do |new_line|
|
|
531
|
+
File.open(path, "r") do |f|
|
|
532
|
+
f.each_line.with_index do |line, i|
|
|
533
|
+
if @on
|
|
534
|
+
new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
|
|
535
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
536
|
+
field = get_test_type type
|
|
537
|
+
new_line.write " #{name} { #{field} }\n"
|
|
538
|
+
end
|
|
539
|
+
if table_check(line: line, class_name: class_name)
|
|
540
|
+
@on = true
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def rspec_factory_end class_name: "souls"
|
|
548
|
+
file_path = "./spec/factories/#{class_name}s.rb"
|
|
549
|
+
File.open(file_path, "a") do |f|
|
|
550
|
+
f.write <<~EOS
|
|
346
551
|
end
|
|
347
552
|
end
|
|
348
553
|
EOS
|
|
349
554
|
end
|
|
350
|
-
puts "
|
|
555
|
+
puts "FactoryBot #{class_name}s.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
def rspec_factory class_name: "souls"
|
|
559
|
+
rspec_factory_head class_name: class_name
|
|
560
|
+
rspec_factory_params class_name: class_name
|
|
561
|
+
rspec_factory_end class_name: class_name
|
|
351
562
|
end
|
|
352
563
|
|
|
353
564
|
def rspec_model class_name: "souls"
|
|
@@ -370,22 +581,43 @@ module Souls
|
|
|
370
581
|
end
|
|
371
582
|
|
|
372
583
|
def rspec_mutation class_name: "souls"
|
|
584
|
+
# if needed
|
|
373
585
|
end
|
|
374
586
|
|
|
375
587
|
def rspec_query class_name: "souls"
|
|
588
|
+
# if needed
|
|
376
589
|
end
|
|
377
590
|
|
|
378
591
|
def rspec_type class_name: "souls"
|
|
592
|
+
# if needed
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
def get_end_point
|
|
596
|
+
file_path = "./app/graphql/types/mutation_type.rb"
|
|
597
|
+
File.open(file_path, "r") do |f|
|
|
598
|
+
f.each_line.with_index do |line, i|
|
|
599
|
+
return i if line.include?("end")
|
|
600
|
+
end
|
|
601
|
+
end
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
def add_mutation_type class_name: "souls"
|
|
605
|
+
# let's do this later
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
def add_query_type class_name: "souls"
|
|
609
|
+
# let's do this later
|
|
379
610
|
end
|
|
380
611
|
|
|
381
612
|
def migration class_name: "souls"
|
|
613
|
+
`rake db:migrate`
|
|
382
614
|
model class_name: class_name
|
|
383
615
|
mutation class_name: class_name
|
|
384
616
|
query class_name: class_name
|
|
385
617
|
type class_name: class_name
|
|
618
|
+
rspec_factory class_name: class_name
|
|
386
619
|
rspec_model class_name: class_name
|
|
387
620
|
end
|
|
388
|
-
|
|
389
621
|
end
|
|
390
622
|
end
|
|
391
623
|
end
|
data/lib/souls/version.rb
CHANGED
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.8.
|
|
4
|
+
version: 0.8.7
|
|
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-01-
|
|
13
|
+
date: 2021-01-21 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.
|