souls 0.10.6 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6509bef1c404da5a8fd24bdca10de869c1b1c04235efde007698457ab8276a2e
4
- data.tar.gz: dd7d5536a3df51475f1521bc24025052e1840772fd52702fa0e2cb7d77996cf6
3
+ metadata.gz: 7c64bef1b432a5f2480396310ec48cd750fc14e8a8f967e93562be1a80427b8f
4
+ data.tar.gz: a7d0a7583c9ab2b58b681ea9a98bde609ce1c416497453493396572124883c5c
5
5
  SHA512:
6
- metadata.gz: f2ac59232c0ba1af44e80ec08a47201a94c1515f32e22c354de23482946c28f538d1e5edf94e5a91e784221eaf4e74cb4ac9b8b35e066c3badf9130e5af41db3
7
- data.tar.gz: a6297e166a94bb704e263c7c75c3e80d71a453e0415458b1fa074e8f63505aa569f03ef556af336daa6790e398b5eea2f56f38dc95cc408fb29c90e336114397
6
+ metadata.gz: ce644c04d72c80221459cae9687395bf8ef7e72616d941fde20ebc0cf54405966556db30a50babd779792012317c1e904f0dc491535de6a076d80742b58d57f6
7
+ data.tar.gz: 468e1d6118ba79e01c24eba45339e76090f566eddd2969bbb71edff51c02304db981cd54fa8c111420115b545d15d41239be59a05e74814ca2d6e3e1655a2da1
@@ -205,4 +205,6 @@ Layout/HeredocIndentation:
205
205
  Exclude:
206
206
  - "lib/souls/init.rb"
207
207
  Style/RaiseArgs:
208
- Enabled: false
208
+ Enabled: false
209
+ Metrics/BlockNesting:
210
+ Enable: false
data/exe/souls CHANGED
@@ -46,7 +46,7 @@ begin
46
46
  when "g", "generate"
47
47
  case ARGV[1]
48
48
  when "test"
49
- Souls::Init.get_tables
49
+ Souls::Init.rspec_mutation class_name: "user"
50
50
  when "model"
51
51
  Souls::Init.model class_name: ARGV[2]
52
52
  when "mutation"
@@ -378,7 +378,7 @@ module Souls
378
378
  -e POSTGRES_PASSWORD=postgres \
379
379
  -e POSTGRES_DB=souls_test \
380
380
  postgres:13-alpine`
381
- `docker ps`
381
+ puts `docker ps`
382
382
  end
383
383
 
384
384
  def run_awake
@@ -623,15 +623,154 @@ module Souls
623
623
  [file_path]
624
624
  end
625
625
 
626
- def rspec_mutation class_name: "souls"
627
- # if needed
626
+ def rspec_mutation_head class_name: "souls"
627
+ file_path = "./spec/mutations/#{class_name.pluralize}.rb"
628
+ File.open(file_path, "w") do |f|
629
+ f.write <<~EOS
630
+ RSpec.describe #{class_name.camelize} Mutation do
631
+ describe "#{class_name.camelize} を作成する" do
632
+ let!(:#{class_name.singularize.downcase}) { FactoryBot.create(:#{class_name.singularize.downcase}) }
633
+
634
+ let(:mutation) do
635
+ %(mutation {
636
+ create#{class_name.camelize}(input: {
637
+ EOS
638
+ end
628
639
  end
629
640
 
630
- def rspec_query class_name: "souls"
631
- # if needed
641
+ def rspec_mutation_params class_name: "souls"
642
+ file_path = "./spec/mutations/#{class_name.pluralize}.rb"
643
+ path = "./db/schema.rb"
644
+ @on = false
645
+ File.open(file_path, "a") do |new_line|
646
+ File.open(path, "r") do |f|
647
+ f.each_line.with_index do |line, i|
648
+ if @on
649
+ if line.include?("end") || line.include?("t.index")
650
+ new_line.write " }) {\n user {\n id\n"
651
+ break
652
+ end
653
+ field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
654
+ type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
655
+ field ||= get_test_type type
656
+ case name
657
+ when "created_at", "updated_at"
658
+ next
659
+ else
660
+ case type
661
+ when "string", "text"
662
+ new_line.write " #{name.camelize(:lower)}: \"\#{#{class_name.singularize}.#{name.underscore}}\"\n"
663
+ when "bigint", "integer", "float", "boolean"
664
+ new_line.write " #{name.camelize(:lower)}: \#{#{class_name.singularize}.#{name.underscore}}\n"
665
+ when "date", "datetime"
666
+ new_line.write " #{name.camelize(:lower)}: \#{Time.now}\n"
667
+ end
668
+ end
669
+ end
670
+ if table_check(line: line, class_name: class_name)
671
+ @on = true
672
+ end
673
+ end
674
+ end
675
+ end
676
+ end
677
+
678
+ def rspec_mutation_params_response class_name: "souls"
679
+ file_path = "./spec/mutations/#{class_name.pluralize}.rb"
680
+ path = "./db/schema.rb"
681
+ @on = false
682
+ File.open(file_path, "a") do |new_line|
683
+ File.open(path, "r") do |f|
684
+ f.each_line.with_index do |line, i|
685
+ if @on
686
+ if line.include?("end") || line.include?("t.index")
687
+ new_line.write <<-EOS
688
+ }
689
+ }
690
+ )
691
+ end
692
+
693
+ subject(:result) do
694
+ SoulsApiSchema.execute(mutation).as_json
695
+ end
696
+
697
+ it "return #{class_name.camelize} Data" do
698
+ a1 = result.dig("data", "create#{class_name.camelize}", "#{class_name.singularize}")
699
+ expect(a1).to include(
700
+ "id" => be_a(Integer),
701
+ EOS
702
+ break
703
+ end
704
+ _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
705
+ case name
706
+ when "created_at", "updated_at"
707
+ next
708
+ else
709
+ new_line.write " #{name.camelize(:lower)}\n"
710
+ end
711
+ end
712
+ if table_check(line: line, class_name: class_name)
713
+ @on = true
714
+ end
715
+ end
716
+ end
717
+ end
718
+ end
719
+
720
+ def rspec_mutation_end class_name: "souls"
721
+ file_path = "./spec/mutations/#{class_name.pluralize}.rb"
722
+ path = "./db/schema.rb"
723
+ @on = false
724
+ File.open(file_path, "a") do |new_line|
725
+ File.open(path, "r") do |f|
726
+ f.each_line.with_index do |line, i|
727
+ if @on
728
+ if line.include?("end") || line.include?("t.index")
729
+ new_line.write <<-EOS
730
+ )
731
+ end
732
+ end
733
+ end
734
+ EOS
735
+ break
736
+ end
737
+ type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
738
+ field ||= type_check type
739
+ array_true = line.include?("array: true")
740
+ case name
741
+ when "created_at", "updated_at"
742
+ next
743
+ else
744
+ case type
745
+ when "text"
746
+ if array_true
747
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
748
+ end
749
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
750
+ when "string", "bigint", "integer", "float", "boolean"
751
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
752
+ when "date", "datetime"
753
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(DateTime),\n"
754
+ end
755
+ end
756
+ end
757
+ if table_check(line: line, class_name: class_name)
758
+ @on = true
759
+ end
760
+ end
761
+ end
762
+ end
763
+ end
764
+
765
+ def rspec_mutation class_name: "souls"
766
+ singularized_class_name = class_name.singularize
767
+ rspec_mutation_head class_name: singularized_class_name
768
+ rspec_mutation_params class_name: singularized_class_name
769
+ rspec_mutation_params_response class_name: singularized_class_name
770
+ rspec_mutation_end class_name: singularized_class_name
632
771
  end
633
772
 
634
- def rspec_type class_name: "souls"
773
+ def rspec_query class_name: "souls"
635
774
  # if needed
636
775
  end
637
776
 
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.10.6"
2
+ VERSION = "0.10.7"
3
3
  end
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.10.6
4
+ version: 0.10.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-24 00:00:00.000000000 Z
13
+ date: 2021-01-26 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.
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.2.4
72
+ rubygems_version: 3.2.3
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: SOULS is a Web Application Framework for Microservices on Multi Cloud Platform