souls 0.9.9 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/souls/init.rb +20 -11
- 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: e75a809266d43f9c1f712c89d8d20f8156bf7c535de57a61e708920e75bfd044
|
4
|
+
data.tar.gz: cd0fc519cd00283704edb8cb8892fe4eecf4329553435d8a7b8c36fe2588ae3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee85b4b713494dc0ad4ffe7407e4f713184416cb164d4ff7d90e68862c5058924ebbfedb7fc1d51a3b9fd7f68e0ec7b9fd4ac6f86473aeff0b43b2d036ad12fe
|
7
|
+
data.tar.gz: 8792bf31bf2803ad97f7f58f7c3ce71b2ba49b28b433e5fdfbd37a001b3d5c37844c995b200cc81cbb80aed15e16af82f78ddece504388830241a241ded90116
|
data/Gemfile.lock
CHANGED
data/lib/souls/init.rb
CHANGED
@@ -244,7 +244,7 @@ module Souls
|
|
244
244
|
end
|
245
245
|
|
246
246
|
def model class_name: "souls"
|
247
|
-
file_path = "./app/models/#{class_name}.rb"
|
247
|
+
file_path = "./app/models/#{class_name.singularize}.rb"
|
248
248
|
File.open(file_path, "w") do |f|
|
249
249
|
f.write <<~EOS
|
250
250
|
class #{class_name.camelize} < ActiveRecord::Base
|
@@ -332,7 +332,7 @@ module Souls
|
|
332
332
|
new_line.write <<~EOS
|
333
333
|
|
334
334
|
def resolve **args
|
335
|
-
#{class_name} =
|
335
|
+
#{class_name} = ::#{class_name.camelize}.new args
|
336
336
|
if #{class_name}.save
|
337
337
|
{ #{class_name}: #{class_name} }
|
338
338
|
else
|
@@ -393,9 +393,9 @@ module Souls
|
|
393
393
|
new_line.write <<~EOS
|
394
394
|
|
395
395
|
def resolve **args
|
396
|
-
#{class_name} =
|
396
|
+
#{class_name} = ::#{class_name.camelize}.find args[:id]
|
397
397
|
#{class_name}.update args
|
398
|
-
{ #{class_name}:
|
398
|
+
{ #{class_name}: ::#{class_name.camelize}.find(args[:id]) }
|
399
399
|
rescue StandardError => error
|
400
400
|
GraphQL::ExecutionError.new error
|
401
401
|
end
|
@@ -424,7 +424,7 @@ module Souls
|
|
424
424
|
argument :id, Integer, required: true
|
425
425
|
|
426
426
|
def resolve id:
|
427
|
-
#{class_name} =
|
427
|
+
#{class_name} = ::#{class_name.camelize}.find id
|
428
428
|
#{class_name}.destroy
|
429
429
|
{ #{class_name}: #{class_name} }
|
430
430
|
rescue StandardError => error
|
@@ -438,17 +438,17 @@ module Souls
|
|
438
438
|
file_path
|
439
439
|
end
|
440
440
|
|
441
|
-
def create_confirm
|
442
|
-
puts "Directory already exists, Overwrite?? (Y/N)"
|
441
|
+
def create_confirm dir_path: ""
|
442
|
+
puts "Directory already exists, Overwrite?? (Y/N)\n#{dir_path}"
|
443
443
|
input = STDIN.gets.chomp
|
444
444
|
return true if input == "Y"
|
445
|
-
raise StandardError.new "Directory Already Exist
|
445
|
+
raise StandardError.new "Directory Already Exist!\n#{dir_path}"
|
446
446
|
end
|
447
447
|
|
448
448
|
def mutation class_name: "souls"
|
449
449
|
singularized_class_name = class_name.singularize
|
450
450
|
if Dir.exist? "./app/graphql/mutations/#{singularized_class_name}"
|
451
|
-
|
451
|
+
create_confirm dir_path: "./app/graphql/mutations/#{singularized_class_name}"
|
452
452
|
FileUtils.rm_r("./app/graphql/mutations/#{singularized_class_name}")
|
453
453
|
end
|
454
454
|
Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
|
@@ -665,7 +665,6 @@ module Souls
|
|
665
665
|
end
|
666
666
|
|
667
667
|
def migrate class_name: "souls"
|
668
|
-
# `rake db:migrate`
|
669
668
|
singularized_class_name = class_name.singularize
|
670
669
|
model_paths = model class_name: singularized_class_name
|
671
670
|
type_paths = type class_name: singularized_class_name
|
@@ -694,8 +693,9 @@ module Souls
|
|
694
693
|
|
695
694
|
def migrate_all
|
696
695
|
puts "◆◆◆ Let's Auto Generate CRUD API ◆◆◆\n"
|
696
|
+
`rake db:migrate`
|
697
697
|
paths = get_tables.map do |class_name|
|
698
|
-
migrate class_name: class_name
|
698
|
+
migrate class_name: class_name.singularize
|
699
699
|
end
|
700
700
|
puts "\n============== Model ======================\n\n"
|
701
701
|
paths.each do |class_name|
|
@@ -745,6 +745,15 @@ module Souls
|
|
745
745
|
path[:add_query_type].each { |line| puts line }
|
746
746
|
end
|
747
747
|
end
|
748
|
+
puts "\n\n##Connection Type\n\n"
|
749
|
+
get_tables.each do |class_name|
|
750
|
+
puts <<~EOS
|
751
|
+
def #{class_name.pluralize}
|
752
|
+
#{class_name.camelize}.all.order(id: :desc)
|
753
|
+
end
|
754
|
+
\n
|
755
|
+
EOS
|
756
|
+
end
|
748
757
|
puts "\n#############################################################\n"
|
749
758
|
puts "# #\n"
|
750
759
|
puts "# Add These Lines at ./app/graphql/types/mutation_type.rb #\n"
|
data/lib/souls/version.rb
CHANGED