souls 0.10.7 → 0.11.2
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 +142 -17
- 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: e4ee7091ee3b3710a439d778f389997e2c97d9bce2a8a26bf67cd5024d365666
|
|
4
|
+
data.tar.gz: 0fe0a2633ffdd26a56d5b41a090917d792e4e4af742dda24106fc9e0e51c89ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 442fb56b727b1e13a25b437302b81b8913c0d3498a52b8196e849a57b40149194e10159569d46dff6686df6569cc3168f8cc57f3269ba384c0b08e871f5955bc
|
|
7
|
+
data.tar.gz: f7d5f4fafff936beb6da5de3d083a67d377b92a841f7d74765dabfda58dd4016cf4f4bdd213d9e101aa6953add2dd43793f59c6ee80f99366a6fa3b9106ab5da
|
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
|
|
@@ -685,6 +684,7 @@ module Souls
|
|
|
685
684
|
if @on
|
|
686
685
|
if line.include?("end") || line.include?("t.index")
|
|
687
686
|
new_line.write <<-EOS
|
|
687
|
+
}
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
690
|
)
|
|
@@ -697,7 +697,7 @@ module Souls
|
|
|
697
697
|
it "return #{class_name.camelize} Data" do
|
|
698
698
|
a1 = result.dig("data", "create#{class_name.camelize}", "#{class_name.singularize}")
|
|
699
699
|
expect(a1).to include(
|
|
700
|
-
"id" => be_a(
|
|
700
|
+
"id" => be_a(String),
|
|
701
701
|
EOS
|
|
702
702
|
break
|
|
703
703
|
end
|
|
@@ -706,7 +706,7 @@ module Souls
|
|
|
706
706
|
when "created_at", "updated_at"
|
|
707
707
|
next
|
|
708
708
|
else
|
|
709
|
-
new_line.write " #{name.camelize(:lower)}\n"
|
|
709
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
|
710
710
|
end
|
|
711
711
|
end
|
|
712
712
|
if table_check(line: line, class_name: class_name)
|
|
@@ -760,6 +760,7 @@ end
|
|
|
760
760
|
end
|
|
761
761
|
end
|
|
762
762
|
end
|
|
763
|
+
[file_path]
|
|
763
764
|
end
|
|
764
765
|
|
|
765
766
|
def rspec_mutation class_name: "souls"
|
|
@@ -770,8 +771,116 @@ end
|
|
|
770
771
|
rspec_mutation_end class_name: singularized_class_name
|
|
771
772
|
end
|
|
772
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
|
+
let!(:#{class_name.singularize.underscore}_id) { Base64.encode64 "User:\#{user.id}" }
|
|
782
|
+
|
|
783
|
+
let(:query) do
|
|
784
|
+
%(query {
|
|
785
|
+
#{class_name.singularize.underscore}(id: \#{#{class_name.singularize.underscore}_id}) {
|
|
786
|
+
id
|
|
787
|
+
EOS
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
def rspec_query_params class_name: "souls"
|
|
792
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
|
793
|
+
path = "./db/schema.rb"
|
|
794
|
+
@on = false
|
|
795
|
+
File.open(file_path, "a") do |new_line|
|
|
796
|
+
File.open(path, "r") do |f|
|
|
797
|
+
f.each_line.with_index do |line, i|
|
|
798
|
+
if @on
|
|
799
|
+
if line.include?("end") || line.include?("t.index")
|
|
800
|
+
new_line.write <<-EOS
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
)
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
subject(:result) do
|
|
807
|
+
SoulsApiSchema.execute(query).as_json
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
it "return #{class_name.camelize} Data" do
|
|
811
|
+
a1 = result.dig("data", "#{class_name.singularize.underscore}")
|
|
812
|
+
expect(a1).to include(
|
|
813
|
+
"id" => be_a(String),
|
|
814
|
+
EOS
|
|
815
|
+
break
|
|
816
|
+
end
|
|
817
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
818
|
+
case name
|
|
819
|
+
when "created_at", "updated_at"
|
|
820
|
+
next
|
|
821
|
+
else
|
|
822
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
|
823
|
+
end
|
|
824
|
+
end
|
|
825
|
+
if table_check(line: line, class_name: class_name)
|
|
826
|
+
@on = true
|
|
827
|
+
end
|
|
828
|
+
end
|
|
829
|
+
end
|
|
830
|
+
end
|
|
831
|
+
end
|
|
832
|
+
|
|
833
|
+
def rspec_query_end class_name: "souls"
|
|
834
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
|
835
|
+
path = "./db/schema.rb"
|
|
836
|
+
@on = false
|
|
837
|
+
File.open(file_path, "a") do |new_line|
|
|
838
|
+
File.open(path, "r") do |f|
|
|
839
|
+
f.each_line.with_index do |line, i|
|
|
840
|
+
if @on
|
|
841
|
+
if line.include?("end") || line.include?("t.index")
|
|
842
|
+
new_line.write <<-EOS
|
|
843
|
+
)
|
|
844
|
+
end
|
|
845
|
+
end
|
|
846
|
+
end
|
|
847
|
+
EOS
|
|
848
|
+
break
|
|
849
|
+
end
|
|
850
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
851
|
+
field ||= type_check type
|
|
852
|
+
array_true = line.include?("array: true")
|
|
853
|
+
case name
|
|
854
|
+
when "created_at", "updated_at"
|
|
855
|
+
next
|
|
856
|
+
else
|
|
857
|
+
case type
|
|
858
|
+
when "text"
|
|
859
|
+
if array_true
|
|
860
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
|
|
861
|
+
end
|
|
862
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
|
863
|
+
when "string", "bigint", "integer", "float", "boolean"
|
|
864
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
|
865
|
+
when "date", "datetime"
|
|
866
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(DateTime),\n"
|
|
867
|
+
end
|
|
868
|
+
end
|
|
869
|
+
end
|
|
870
|
+
if table_check(line: line, class_name: class_name)
|
|
871
|
+
@on = true
|
|
872
|
+
end
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
end
|
|
876
|
+
[file_path]
|
|
877
|
+
end
|
|
878
|
+
|
|
773
879
|
def rspec_query class_name: "souls"
|
|
774
|
-
|
|
880
|
+
singularized_class_name = class_name.singularize
|
|
881
|
+
rspec_query_head class_name: singularized_class_name
|
|
882
|
+
rspec_query_params class_name: singularized_class_name
|
|
883
|
+
rspec_query_end class_name: singularized_class_name
|
|
775
884
|
end
|
|
776
885
|
|
|
777
886
|
def get_end_point
|
|
@@ -808,6 +917,8 @@ end
|
|
|
808
917
|
type_paths = type class_name: singularized_class_name
|
|
809
918
|
rspec_factory_paths = rspec_factory class_name: singularized_class_name
|
|
810
919
|
rspec_model_paths = rspec_model class_name: singularized_class_name
|
|
920
|
+
rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
|
|
921
|
+
rspec_query_paths = rspec_query class_name: singularized_class_name
|
|
811
922
|
query_path = query class_name: singularized_class_name
|
|
812
923
|
mutation_path = mutation class_name: singularized_class_name
|
|
813
924
|
[
|
|
@@ -815,6 +926,8 @@ end
|
|
|
815
926
|
type: type_paths,
|
|
816
927
|
rspec_factory: rspec_factory_paths,
|
|
817
928
|
rspec_model: rspec_model_paths,
|
|
929
|
+
rspec_mutation: rspec_mutation_paths,
|
|
930
|
+
rspec_query: rspec_query_paths,
|
|
818
931
|
query: query_path,
|
|
819
932
|
mutation: mutation_path,
|
|
820
933
|
add_query_type: [
|
|
@@ -859,6 +972,18 @@ end
|
|
|
859
972
|
path[:rspec_model].each { |line| puts line }
|
|
860
973
|
end
|
|
861
974
|
end
|
|
975
|
+
puts "\n============== RspecMutation =================\n\n"
|
|
976
|
+
paths.each do |class_name|
|
|
977
|
+
class_name.each do |path|
|
|
978
|
+
path[:rspec_mutation].each { |line| puts line }
|
|
979
|
+
end
|
|
980
|
+
end
|
|
981
|
+
puts "\n============== RspecQuery =================\n\n"
|
|
982
|
+
paths.each do |class_name|
|
|
983
|
+
class_name.each do |path|
|
|
984
|
+
path[:rspec_query].each { |line| puts line }
|
|
985
|
+
end
|
|
986
|
+
end
|
|
862
987
|
puts "\n============== Query ======================\n\n"
|
|
863
988
|
paths.each do |class_name|
|
|
864
989
|
class_name.each do |path|
|
data/lib/souls/version.rb
CHANGED