souls 0.8.7 → 0.8.8
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 +1 -0
- data/Gemfile.lock +2 -1
- data/lib/souls.rb +1 -0
- data/lib/souls/init.rb +51 -33
- 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: f5859735f56d7954ebc4b65d76b8961050dd13ce6b9e5572efc0feb08ddde21d
|
|
4
|
+
data.tar.gz: 95bc765b4a97393f94d53f5b08f34dc893482f5e266fb4a514429f2f40a39f3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4fc5d3918a769fdfc7b67bf4466d65536b97a380e3504f736982889c0ae5a92cff0584e924bdd296049c91c260213954d5bfd22298570fab5ca26edda94eeab3
|
|
7
|
+
data.tar.gz: 14b3e574b8aed7a8563726edeca5c827bf0c37011d2a7d6c7f6de6a2456466a402c9172c1a5c21e684f0ef5a093d9db6ce8169a55d80ae3c5b3b40f5f96c38ad
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
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
|
|
@@ -424,16 +434,16 @@ module Souls
|
|
|
424
434
|
delete_mutation class_name: class_name
|
|
425
435
|
end
|
|
426
436
|
|
|
427
|
-
def
|
|
428
|
-
file_path = "./app/graphql/queries/#{class_name}
|
|
437
|
+
def create_query class_name: "souls"
|
|
438
|
+
file_path = "./app/graphql/queries/#{class_name.pluralize}.rb"
|
|
429
439
|
File.open(file_path, "w") do |f|
|
|
430
440
|
f.write <<~EOS
|
|
431
441
|
module Queries
|
|
432
|
-
class #{class_name.
|
|
433
|
-
type [Types::#{class_name.
|
|
442
|
+
class #{class_name.camelize.pluralize} < Queries::BaseQuery
|
|
443
|
+
type [Types::#{class_name.camelize}Type], null: false
|
|
434
444
|
|
|
435
445
|
def resolve
|
|
436
|
-
::#{class_name.
|
|
446
|
+
::#{class_name.camelize}.all
|
|
437
447
|
rescue StandardError => error
|
|
438
448
|
GraphQL::ExecutionError.new error
|
|
439
449
|
end
|
|
@@ -441,33 +451,41 @@ module Souls
|
|
|
441
451
|
end
|
|
442
452
|
EOS
|
|
443
453
|
end
|
|
444
|
-
puts "
|
|
454
|
+
puts "Query #{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def create_queries class_name: "souls"
|
|
445
458
|
file_path = "./app/graphql/queries/#{class_name}.rb"
|
|
446
459
|
File.open(file_path, "w") do |f|
|
|
447
460
|
f.write <<~EOS
|
|
448
461
|
module Queries
|
|
449
|
-
class #{class_name.
|
|
450
|
-
type Types::#{class_name.
|
|
462
|
+
class #{class_name.camelize} < Queries::BaseQuery
|
|
463
|
+
type Types::#{class_name.camelize}Type, null: false
|
|
451
464
|
argument :id, Integer, required: true
|
|
452
465
|
|
|
453
466
|
def resolve id:
|
|
454
|
-
::#{class_name.
|
|
467
|
+
::#{class_name.camelize}.find(id)
|
|
455
468
|
rescue StandardError => error
|
|
456
469
|
GraphQL::ExecutionError.new error
|
|
457
470
|
end
|
|
458
471
|
end
|
|
459
472
|
end
|
|
460
473
|
EOS
|
|
461
|
-
puts "
|
|
474
|
+
puts "Query #{class_name.pluralize}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
462
475
|
end
|
|
463
476
|
end
|
|
464
477
|
|
|
478
|
+
def query class_name: "souls"
|
|
479
|
+
create_query class_name: class_name
|
|
480
|
+
create_queries class_name: class_name
|
|
481
|
+
end
|
|
482
|
+
|
|
465
483
|
def create_type_head class_name: "souls"
|
|
466
484
|
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
|
467
485
|
File.open(file_path, "w") do |f|
|
|
468
486
|
f.write <<~EOS
|
|
469
487
|
module Types
|
|
470
|
-
class #{class_name.
|
|
488
|
+
class #{class_name.camelize}Type < GraphQL::Schema::Object
|
|
471
489
|
implements GraphQL::Types::Relay::Node
|
|
472
490
|
|
|
473
491
|
EOS
|
|
@@ -514,7 +532,7 @@ module Souls
|
|
|
514
532
|
end
|
|
515
533
|
|
|
516
534
|
def rspec_factory_head class_name: "souls"
|
|
517
|
-
file_path = "./spec/factories/#{class_name}
|
|
535
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
518
536
|
File.open(file_path, "w") do |f|
|
|
519
537
|
f.write <<~EOS
|
|
520
538
|
FactoryBot.define do
|
|
@@ -524,7 +542,7 @@ module Souls
|
|
|
524
542
|
end
|
|
525
543
|
|
|
526
544
|
def rspec_factory_params class_name: "souls"
|
|
527
|
-
file_path = "./spec/factories/#{class_name}
|
|
545
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
528
546
|
path = "./db/schema.rb"
|
|
529
547
|
@on = false
|
|
530
548
|
File.open(file_path, "a") do |new_line|
|
|
@@ -545,14 +563,14 @@ module Souls
|
|
|
545
563
|
end
|
|
546
564
|
|
|
547
565
|
def rspec_factory_end class_name: "souls"
|
|
548
|
-
file_path = "./spec/factories/#{class_name}
|
|
566
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
|
549
567
|
File.open(file_path, "a") do |f|
|
|
550
568
|
f.write <<~EOS
|
|
551
569
|
end
|
|
552
570
|
end
|
|
553
571
|
EOS
|
|
554
572
|
end
|
|
555
|
-
puts "FactoryBot #{class_name}
|
|
573
|
+
puts "FactoryBot #{class_name.pluralize}.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
556
574
|
end
|
|
557
575
|
|
|
558
576
|
def rspec_factory class_name: "souls"
|
|
@@ -565,7 +583,7 @@ module Souls
|
|
|
565
583
|
file_path = "./spec/models/#{class_name}_spec.rb"
|
|
566
584
|
File.open(file_path, "w") do |f|
|
|
567
585
|
f.write <<~EOS
|
|
568
|
-
RSpec.describe #{class_name.
|
|
586
|
+
RSpec.describe #{class_name.camelize}, type: :model do
|
|
569
587
|
it "作成する" do
|
|
570
588
|
expect(FactoryBot.build(:#{class_name})).to be_valid
|
|
571
589
|
end
|
|
@@ -577,7 +595,7 @@ module Souls
|
|
|
577
595
|
end
|
|
578
596
|
EOS
|
|
579
597
|
end
|
|
580
|
-
puts "
|
|
598
|
+
puts "Rspec #{class_name}_spec.rb Auto Generated from schema.rb!: `#{file_path}`"
|
|
581
599
|
end
|
|
582
600
|
|
|
583
601
|
def rspec_mutation class_name: "souls"
|
|
@@ -610,7 +628,7 @@ module Souls
|
|
|
610
628
|
end
|
|
611
629
|
|
|
612
630
|
def migration class_name: "souls"
|
|
613
|
-
`rake db:migrate`
|
|
631
|
+
# `rake db:migrate`
|
|
614
632
|
model class_name: class_name
|
|
615
633
|
mutation class_name: class_name
|
|
616
634
|
query class_name: class_name
|
data/lib/souls/version.rb
CHANGED