souls 0.10.8 → 0.11.3
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/exe/souls +1 -1
- data/lib/souls/init.rb +139 -16
- 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: ac62e7ceab027e6712c2f49a1006467634b695c94277532d995abfe8b84b06d5
|
|
4
|
+
data.tar.gz: b9a7d9be1893112f1ed88c10246addcf65b1324fbe38c88341ea165e1dbfeb95
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8d541ba1c46c4419c0599a38be3ad060c3630e50768ac19d598d4324b9ed38c80be49e67aacb307179f091a0543c64853d1563a51b0bdaeefa1f2d3b4d9cf99
|
|
7
|
+
data.tar.gz: 2be11c59ff026d0cd1a33d897772e03a8e1839feba4d0b01ffb44f7ec8b37ac5b6d3e76dc7a7c2bdd8bd1edfc4bafa6fd5f039875d6b9aa5d9f204a2f8f639d2
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
data/lib/souls/init.rb
CHANGED
|
@@ -460,7 +460,7 @@ module Souls
|
|
|
460
460
|
]
|
|
461
461
|
end
|
|
462
462
|
|
|
463
|
-
def
|
|
463
|
+
def create_queries class_name: "souls"
|
|
464
464
|
file_path = "./app/graphql/queries/#{class_name.pluralize}.rb"
|
|
465
465
|
File.open(file_path, "w") do |f|
|
|
466
466
|
f.write <<~EOS
|
|
@@ -480,17 +480,18 @@ module Souls
|
|
|
480
480
|
file_path
|
|
481
481
|
end
|
|
482
482
|
|
|
483
|
-
def
|
|
483
|
+
def create_query class_name: "souls"
|
|
484
484
|
file_path = "./app/graphql/queries/#{class_name}.rb"
|
|
485
485
|
File.open(file_path, "w") do |f|
|
|
486
486
|
f.write <<~EOS
|
|
487
487
|
module Queries
|
|
488
488
|
class #{class_name.camelize} < Queries::BaseQuery
|
|
489
489
|
type Types::#{class_name.camelize}Type, null: false
|
|
490
|
-
argument :id,
|
|
490
|
+
argument :id, String, required: true
|
|
491
491
|
|
|
492
|
-
def resolve
|
|
493
|
-
|
|
492
|
+
def resolve **args
|
|
493
|
+
_, #{class_name.singularize.underscore}_id = SoulsApiSchema.from_global_id args[:id]
|
|
494
|
+
::#{class_name.camelize}.find(#{class_name.singularize.underscore}_id)
|
|
494
495
|
rescue StandardError => error
|
|
495
496
|
GraphQL::ExecutionError.new error
|
|
496
497
|
end
|
|
@@ -627,9 +628,9 @@ module Souls
|
|
|
627
628
|
file_path = "./spec/mutations/#{class_name.pluralize}.rb"
|
|
628
629
|
File.open(file_path, "w") do |f|
|
|
629
630
|
f.write <<~EOS
|
|
630
|
-
RSpec.describe #{class_name.camelize} Mutation do
|
|
631
|
-
describe "#{class_name.camelize}
|
|
632
|
-
let!(:#{class_name.singularize.
|
|
631
|
+
RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
|
|
632
|
+
describe "#{class_name.camelize} データを登録する" do
|
|
633
|
+
let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
|
|
633
634
|
|
|
634
635
|
let(:mutation) do
|
|
635
636
|
%(mutation {
|
|
@@ -647,23 +648,21 @@ module Souls
|
|
|
647
648
|
f.each_line.with_index do |line, i|
|
|
648
649
|
if @on
|
|
649
650
|
if line.include?("end") || line.include?("t.index")
|
|
650
|
-
new_line.write " }) {\n
|
|
651
|
+
new_line.write " }) {\n #{class_name.singularize.camelize} {\n id\n"
|
|
651
652
|
break
|
|
652
653
|
end
|
|
653
|
-
field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
|
|
654
654
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
655
|
-
field ||= get_test_type type
|
|
656
655
|
case name
|
|
657
656
|
when "created_at", "updated_at"
|
|
658
657
|
next
|
|
659
658
|
else
|
|
660
659
|
case type
|
|
661
660
|
when "string", "text"
|
|
662
|
-
new_line.write " #{name.camelize(:lower)}: \"\#{#{class_name.singularize}.#{name.underscore}}\"\n"
|
|
661
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}.#{name.singularize.underscore}}\"\n"
|
|
663
662
|
when "bigint", "integer", "float", "boolean"
|
|
664
|
-
new_line.write " #{name.camelize(:lower)}: \#{#{class_name.singularize}.#{name.underscore}}\n"
|
|
663
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \#{#{class_name.singularize}.#{name.singularize.underscore}}\n"
|
|
665
664
|
when "date", "datetime"
|
|
666
|
-
new_line.write " #{name.camelize(:lower)}: \#{Time.now}\n"
|
|
665
|
+
new_line.write " #{name.singularize.camelize(:lower)}: \#{Time.now}\n"
|
|
667
666
|
end
|
|
668
667
|
end
|
|
669
668
|
end
|
|
@@ -707,7 +706,7 @@ module Souls
|
|
|
707
706
|
when "created_at", "updated_at"
|
|
708
707
|
next
|
|
709
708
|
else
|
|
710
|
-
new_line.write " #{name.camelize(:lower)}\n"
|
|
709
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
|
711
710
|
end
|
|
712
711
|
end
|
|
713
712
|
if table_check(line: line, class_name: class_name)
|
|
@@ -761,6 +760,7 @@ end
|
|
|
761
760
|
end
|
|
762
761
|
end
|
|
763
762
|
end
|
|
763
|
+
[file_path]
|
|
764
764
|
end
|
|
765
765
|
|
|
766
766
|
def rspec_mutation class_name: "souls"
|
|
@@ -771,8 +771,115 @@ end
|
|
|
771
771
|
rspec_mutation_end class_name: singularized_class_name
|
|
772
772
|
end
|
|
773
773
|
|
|
774
|
+
def rspec_query_head class_name: "souls"
|
|
775
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
|
776
|
+
File.open(file_path, "w") do |f|
|
|
777
|
+
f.write <<~EOS
|
|
778
|
+
RSpec.describe \"#{class_name.camelize} Query テスト\" do
|
|
779
|
+
describe "#{class_name.camelize} データを取得する" do
|
|
780
|
+
let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
|
|
781
|
+
|
|
782
|
+
let(:query) do
|
|
783
|
+
%(query {
|
|
784
|
+
#{class_name.singularize.underscore}(id: \#{Base64.encode64("#{class_name.camelize}:\#{user.id}")}) {
|
|
785
|
+
id
|
|
786
|
+
EOS
|
|
787
|
+
end
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
def rspec_query_params class_name: "souls"
|
|
791
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
|
792
|
+
path = "./db/schema.rb"
|
|
793
|
+
@on = false
|
|
794
|
+
File.open(file_path, "a") do |new_line|
|
|
795
|
+
File.open(path, "r") do |f|
|
|
796
|
+
f.each_line.with_index do |line, i|
|
|
797
|
+
if @on
|
|
798
|
+
if line.include?("end") || line.include?("t.index")
|
|
799
|
+
new_line.write <<-EOS
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
)
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
subject(:result) do
|
|
806
|
+
SoulsApiSchema.execute(query).as_json
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
it "return #{class_name.camelize} Data" do
|
|
810
|
+
a1 = result.dig("data", "#{class_name.singularize.underscore}")
|
|
811
|
+
expect(a1).to include(
|
|
812
|
+
"id" => be_a(String),
|
|
813
|
+
EOS
|
|
814
|
+
break
|
|
815
|
+
end
|
|
816
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
817
|
+
case name
|
|
818
|
+
when "created_at", "updated_at"
|
|
819
|
+
next
|
|
820
|
+
else
|
|
821
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
|
822
|
+
end
|
|
823
|
+
end
|
|
824
|
+
if table_check(line: line, class_name: class_name)
|
|
825
|
+
@on = true
|
|
826
|
+
end
|
|
827
|
+
end
|
|
828
|
+
end
|
|
829
|
+
end
|
|
830
|
+
end
|
|
831
|
+
|
|
832
|
+
def rspec_query_end class_name: "souls"
|
|
833
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
|
834
|
+
path = "./db/schema.rb"
|
|
835
|
+
@on = false
|
|
836
|
+
File.open(file_path, "a") do |new_line|
|
|
837
|
+
File.open(path, "r") do |f|
|
|
838
|
+
f.each_line.with_index do |line, i|
|
|
839
|
+
if @on
|
|
840
|
+
if line.include?("end") || line.include?("t.index")
|
|
841
|
+
new_line.write <<-EOS
|
|
842
|
+
)
|
|
843
|
+
end
|
|
844
|
+
end
|
|
845
|
+
end
|
|
846
|
+
EOS
|
|
847
|
+
break
|
|
848
|
+
end
|
|
849
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
850
|
+
field ||= type_check type
|
|
851
|
+
array_true = line.include?("array: true")
|
|
852
|
+
case name
|
|
853
|
+
when "created_at", "updated_at"
|
|
854
|
+
next
|
|
855
|
+
else
|
|
856
|
+
case type
|
|
857
|
+
when "text"
|
|
858
|
+
if array_true
|
|
859
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
|
|
860
|
+
end
|
|
861
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
|
862
|
+
when "string", "bigint", "integer", "float", "boolean"
|
|
863
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
|
864
|
+
when "date", "datetime"
|
|
865
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(DateTime),\n"
|
|
866
|
+
end
|
|
867
|
+
end
|
|
868
|
+
end
|
|
869
|
+
if table_check(line: line, class_name: class_name)
|
|
870
|
+
@on = true
|
|
871
|
+
end
|
|
872
|
+
end
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
[file_path]
|
|
876
|
+
end
|
|
877
|
+
|
|
774
878
|
def rspec_query class_name: "souls"
|
|
775
|
-
|
|
879
|
+
singularized_class_name = class_name.singularize
|
|
880
|
+
rspec_query_head class_name: singularized_class_name
|
|
881
|
+
rspec_query_params class_name: singularized_class_name
|
|
882
|
+
rspec_query_end class_name: singularized_class_name
|
|
776
883
|
end
|
|
777
884
|
|
|
778
885
|
def get_end_point
|
|
@@ -809,6 +916,8 @@ end
|
|
|
809
916
|
type_paths = type class_name: singularized_class_name
|
|
810
917
|
rspec_factory_paths = rspec_factory class_name: singularized_class_name
|
|
811
918
|
rspec_model_paths = rspec_model class_name: singularized_class_name
|
|
919
|
+
rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
|
|
920
|
+
rspec_query_paths = rspec_query class_name: singularized_class_name
|
|
812
921
|
query_path = query class_name: singularized_class_name
|
|
813
922
|
mutation_path = mutation class_name: singularized_class_name
|
|
814
923
|
[
|
|
@@ -816,6 +925,8 @@ end
|
|
|
816
925
|
type: type_paths,
|
|
817
926
|
rspec_factory: rspec_factory_paths,
|
|
818
927
|
rspec_model: rspec_model_paths,
|
|
928
|
+
rspec_mutation: rspec_mutation_paths,
|
|
929
|
+
rspec_query: rspec_query_paths,
|
|
819
930
|
query: query_path,
|
|
820
931
|
mutation: mutation_path,
|
|
821
932
|
add_query_type: [
|
|
@@ -860,6 +971,18 @@ end
|
|
|
860
971
|
path[:rspec_model].each { |line| puts line }
|
|
861
972
|
end
|
|
862
973
|
end
|
|
974
|
+
puts "\n============== RspecMutation =================\n\n"
|
|
975
|
+
paths.each do |class_name|
|
|
976
|
+
class_name.each do |path|
|
|
977
|
+
path[:rspec_mutation].each { |line| puts line }
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
puts "\n============== RspecQuery =================\n\n"
|
|
981
|
+
paths.each do |class_name|
|
|
982
|
+
class_name.each do |path|
|
|
983
|
+
path[:rspec_query].each { |line| puts line }
|
|
984
|
+
end
|
|
985
|
+
end
|
|
863
986
|
puts "\n============== Query ======================\n\n"
|
|
864
987
|
paths.each do |class_name|
|
|
865
988
|
class_name.each do |path|
|
data/lib/souls/version.rb
CHANGED