souls 0.13.6 → 0.14.1
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.lock +1 -1
- data/exe/souls +7 -7
- data/lib/souls/init.rb +274 -180
- data/lib/souls/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fdf94732ef2ecdb223a4941565373da8745b191a7b80aed563ad6779cfcdbe64
         | 
| 4 | 
            +
              data.tar.gz: 5c0556e3cbfcbc050834a91038e7cc4b73ebddce08f0fb17c1b8827f5a5b3f01
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fc1b10c295d6e00585f013bde4c589bd5135bc47417548901f7f45a4268cbeff628d1aa18780f1fa3224040dbad2a9c4cb95e09f9b03306ac0d388f4d921d25c
         | 
| 7 | 
            +
              data.tar.gz: d23b7557595cffca27e78f80f3a6a78c11e3a31fa365b20a0e0502968140bfd374f2c6cce2205495f1c1506eac1250af9b9675480c6dbd036e0dc93f6df97fb9
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/exe/souls
    CHANGED
    
    | @@ -13,27 +13,27 @@ begin | |
| 13 13 | 
             
                  puts "you need to specify your app name \n `souls new app_name`"
         | 
| 14 14 | 
             
                  exit
         | 
| 15 15 | 
             
                end
         | 
| 16 | 
            -
                puts "Which framework:   \n 1. SOULS  | 
| 16 | 
            +
                puts "Which framework:   \n 1. SOULS GraphQL API \n 2. SOULS GraphQL API gRPC compatible \n 3. SOULS gRPC Service \n 4. SOULS Media Web \n 5. SOULS Admin Web \n Enter Number: "
         | 
| 17 17 | 
             
                strain = STDIN.gets.chomp.to_i
         | 
| 18 18 | 
             
                (1..5).include?(strain) ? puts("Generating Souls.. \n") : raise(StandardError, "Choose Number 1..5")
         | 
| 19 19 | 
             
                Souls::Init.create_souls strain: strain, app_name: ARGV[1]
         | 
| 20 20 | 
             
              when "s", "server"
         | 
| 21 21 | 
             
                strain = Souls.configuration.strain
         | 
| 22 22 | 
             
                case strain
         | 
| 23 | 
            -
                when " | 
| 24 | 
            -
                  system " | 
| 23 | 
            +
                when "media", "admin"
         | 
| 24 | 
            +
                  system "yarn dev"
         | 
| 25 25 | 
             
                when "service"
         | 
| 26 26 | 
             
                  system "bundle exec rake run_server"
         | 
| 27 27 | 
             
                else
         | 
| 28 | 
            -
                  system " | 
| 28 | 
            +
                  system "bundle exec puma -p 3000"
         | 
| 29 29 | 
             
                end
         | 
| 30 30 | 
             
              when "c", "console"
         | 
| 31 31 | 
             
                strain = Souls.configuration.strain
         | 
| 32 32 | 
             
                case strain
         | 
| 33 | 
            -
                when " | 
| 34 | 
            -
                  system "bundle exec irb"
         | 
| 35 | 
            -
                else
         | 
| 33 | 
            +
                when "media", "admin"
         | 
| 36 34 | 
             
                  system "yarn dev"
         | 
| 35 | 
            +
                else
         | 
| 36 | 
            +
                  system "bundle exec irb"
         | 
| 37 37 | 
             
                end
         | 
| 38 38 | 
             
              when "i", "infra"
         | 
| 39 39 | 
             
                Souls.send ARGV[1]
         | 
    
        data/lib/souls/init.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            module Souls
         | 
| 2 | 
            -
              STRAINS = [" | 
| 2 | 
            +
              STRAINS = ["graph", "api", "service", "media", "admin"]
         | 
| 3 3 | 
             
              module Init
         | 
| 4 4 | 
             
                class << self
         | 
| 5 5 | 
             
                  def create_souls strain: 1, app_name: "souls"
         | 
| @@ -723,67 +723,115 @@ module Souls | |
| 723 723 | 
             
                      f.write <<~EOS
         | 
| 724 724 | 
             
                        RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
         | 
| 725 725 | 
             
                          describe "#{class_name.camelize} データを登録する" do
         | 
| 726 | 
            -
                            let(:#{class_name.singularize.underscore}) { FactoryBot.attributes_for(:#{class_name.singularize.underscore}) }
         | 
| 727 | 
            -
             | 
| 728 | 
            -
                            let(:mutation) do
         | 
| 729 | 
            -
                              %(mutation {
         | 
| 730 | 
            -
                                create#{class_name.camelize}(input: {
         | 
| 731 726 | 
             
                      EOS
         | 
| 732 727 | 
             
                    end
         | 
| 733 728 | 
             
                  end
         | 
| 734 729 |  | 
| 735 | 
            -
             | 
| 736 | 
            -
             | 
| 737 | 
            -
             | 
| 738 | 
            -
             | 
| 739 | 
            -
             | 
| 740 | 
            -
             | 
| 741 | 
            -
             | 
| 742 | 
            -
             | 
| 743 | 
            -
             | 
| 744 | 
            -
             | 
| 745 | 
            -
             | 
| 746 | 
            -
             | 
| 747 | 
            -
             | 
| 748 | 
            -
             | 
| 749 | 
            -
             | 
| 750 | 
            -
             | 
| 751 | 
            -
             | 
| 752 | 
            -
             | 
| 753 | 
            -
             | 
| 754 | 
            -
                                @user_exist = true
         | 
| 730 | 
            +
                  def rspec_mutation_after_head class_name: "souls"
         | 
| 731 | 
            +
                    file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
         | 
| 732 | 
            +
                    path = "./db/schema.rb"
         | 
| 733 | 
            +
                    @on = false
         | 
| 734 | 
            +
                    @user_exist = false
         | 
| 735 | 
            +
                    @relation_params = []
         | 
| 736 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 737 | 
            +
                      File.open(path, "r") do |f|
         | 
| 738 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 739 | 
            +
                          if @on
         | 
| 740 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 741 | 
            +
                              if @relation_params.empty?
         | 
| 742 | 
            +
                                new_line.write <<-EOS
         | 
| 743 | 
            +
                let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}) }
         | 
| 744 | 
            +
             | 
| 745 | 
            +
                let(:mutation) do
         | 
| 746 | 
            +
                  %(mutation {
         | 
| 747 | 
            +
                    create#{class_name.camelize}(input: {
         | 
| 748 | 
            +
                                EOS
         | 
| 755 749 | 
             
                              else
         | 
| 756 | 
            -
                                 | 
| 757 | 
            -
             | 
| 758 | 
            -
             | 
| 759 | 
            -
             | 
| 760 | 
            -
             | 
| 761 | 
            -
             | 
| 762 | 
            -
             | 
| 763 | 
            -
             | 
| 764 | 
            -
             | 
| 765 | 
            -
                                end
         | 
| 750 | 
            +
                                new_line.write <<-EOS
         | 
| 751 | 
            +
                  
         | 
| 752 | 
            +
                get_global_key = proc { |class_name, id| Base64.encode64(\"\#{class_name}:\#{id}\") }
         | 
| 753 | 
            +
                let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(", ")}) }
         | 
| 754 | 
            +
             | 
| 755 | 
            +
                let(:mutation) do
         | 
| 756 | 
            +
                  %(mutation {
         | 
| 757 | 
            +
                    create#{class_name.camelize}(input: {
         | 
| 758 | 
            +
                                EOS
         | 
| 766 759 | 
             
                              end
         | 
| 760 | 
            +
                              break
         | 
| 767 761 | 
             
                            end
         | 
| 768 | 
            -
                             | 
| 769 | 
            -
             | 
| 762 | 
            +
                            _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 763 | 
            +
                            case name
         | 
| 764 | 
            +
                            when "user_id"
         | 
| 765 | 
            +
                              relation_col = name.gsub("_id", "")
         | 
| 766 | 
            +
                              new_line.write "    let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
         | 
| 767 | 
            +
                            when /$*_id\z/
         | 
| 768 | 
            +
                              relation_col = name.gsub("_id", "")
         | 
| 769 | 
            +
                              @relation_params << "#{name}: get_global_key.call(\"#{name.singularize.camelize.gsub("Id", "")}\", #{relation_col}.id)"
         | 
| 770 | 
            +
                              new_line.write "    let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
         | 
| 770 771 | 
             
                            end
         | 
| 771 772 | 
             
                          end
         | 
| 773 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 774 | 
            +
                            @on = true
         | 
| 775 | 
            +
                          end
         | 
| 772 776 | 
             
                        end
         | 
| 773 777 | 
             
                      end
         | 
| 774 778 | 
             
                    end
         | 
| 779 | 
            +
                  end
         | 
| 775 780 |  | 
| 776 | 
            -
             | 
| 777 | 
            -
             | 
| 778 | 
            -
             | 
| 779 | 
            -
             | 
| 780 | 
            -
             | 
| 781 | 
            -
             | 
| 782 | 
            -
             | 
| 783 | 
            -
             | 
| 784 | 
            -
             | 
| 785 | 
            -
             | 
| 786 | 
            -
             | 
| 781 | 
            +
                  def rspec_mutation_params class_name: "souls"
         | 
| 782 | 
            +
                    file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
         | 
| 783 | 
            +
                    path = "./db/schema.rb"
         | 
| 784 | 
            +
                    @on = false
         | 
| 785 | 
            +
                    @user_exist = false
         | 
| 786 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 787 | 
            +
                      File.open(path, "r") do |f|
         | 
| 788 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 789 | 
            +
                          if @on
         | 
| 790 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 791 | 
            +
                              new_line.write "        }) {\n            #{class_name.singularize.camelize(:lower)} {\n              id\n"
         | 
| 792 | 
            +
                              break
         | 
| 793 | 
            +
                            end
         | 
| 794 | 
            +
                            type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 795 | 
            +
                            array_true = line.include?("array: true")
         | 
| 796 | 
            +
                            case name
         | 
| 797 | 
            +
                            when "created_at", "updated_at"
         | 
| 798 | 
            +
                              next
         | 
| 799 | 
            +
                            when "user_id"
         | 
| 800 | 
            +
                              @user_exist = true
         | 
| 801 | 
            +
                            when /$*_id\z/
         | 
| 802 | 
            +
                              new_line.write "          #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
         | 
| 803 | 
            +
                            else
         | 
| 804 | 
            +
                              case type
         | 
| 805 | 
            +
                              when "string", "text", "date", "datetime"
         | 
| 806 | 
            +
                                if array_true
         | 
| 807 | 
            +
                                  new_line.write "          #{name.pluralize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
         | 
| 808 | 
            +
                                else
         | 
| 809 | 
            +
                                  new_line.write "          #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
         | 
| 810 | 
            +
                                end
         | 
| 811 | 
            +
                              when "bigint", "integer", "float", "boolean"
         | 
| 812 | 
            +
                                new_line.write "          #{name.singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
         | 
| 813 | 
            +
                              end
         | 
| 814 | 
            +
                            end
         | 
| 815 | 
            +
                          end
         | 
| 816 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 817 | 
            +
                            @on = true
         | 
| 818 | 
            +
                          end
         | 
| 819 | 
            +
                        end
         | 
| 820 | 
            +
                      end
         | 
| 821 | 
            +
                    end
         | 
| 822 | 
            +
                  end
         | 
| 823 | 
            +
             | 
| 824 | 
            +
                  def rspec_mutation_params_response class_name: "souls"
         | 
| 825 | 
            +
                    file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
         | 
| 826 | 
            +
                    path = "./db/schema.rb"
         | 
| 827 | 
            +
                    @on = false
         | 
| 828 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 829 | 
            +
                      File.open(path, "r") do |f|
         | 
| 830 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 831 | 
            +
                          if @on
         | 
| 832 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 833 | 
            +
                              if @user_exist
         | 
| 834 | 
            +
                                new_line.write <<-EOS
         | 
| 787 835 | 
             
                        }
         | 
| 788 836 | 
             
                      }
         | 
| 789 837 | 
             
                    }
         | 
| @@ -801,9 +849,9 @@ module Souls | |
| 801 849 | 
             
                  a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}")
         | 
| 802 850 | 
             
                  expect(a1).to include(
         | 
| 803 851 | 
             
                    "id" => be_a(String),
         | 
| 804 | 
            -
             | 
| 805 | 
            -
             | 
| 806 | 
            -
             | 
| 852 | 
            +
                                EOS
         | 
| 853 | 
            +
                              else
         | 
| 854 | 
            +
                                new_line.write <<-EOS
         | 
| 807 855 | 
             
                        }
         | 
| 808 856 | 
             
                      }
         | 
| 809 857 | 
             
                    }
         | 
| @@ -818,81 +866,82 @@ module Souls | |
| 818 866 | 
             
                  a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}")
         | 
| 819 867 | 
             
                  expect(a1).to include(
         | 
| 820 868 | 
             
                    "id" => be_a(String),
         | 
| 821 | 
            -
             | 
| 822 | 
            -
                                end
         | 
| 823 | 
            -
                                break
         | 
| 869 | 
            +
                                EOS
         | 
| 824 870 | 
             
                              end
         | 
| 825 | 
            -
                               | 
| 826 | 
            -
             | 
| 827 | 
            -
             | 
| 828 | 
            -
             | 
| 829 | 
            -
             | 
| 871 | 
            +
                              break
         | 
| 872 | 
            +
                            end
         | 
| 873 | 
            +
                            _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 874 | 
            +
                            array_true = line.include?("array: true")
         | 
| 875 | 
            +
                            case name
         | 
| 876 | 
            +
                            when "user_id", "created_at", "updated_at", /$*_id\z/
         | 
| 877 | 
            +
                              next
         | 
| 878 | 
            +
                            else
         | 
| 879 | 
            +
                              if array_true
         | 
| 880 | 
            +
                                new_line.write "              #{name.pluralize.camelize(:lower)}\n"
         | 
| 830 881 | 
             
                              else
         | 
| 831 | 
            -
                                 | 
| 832 | 
            -
                                  new_line.write "              #{name.pluralize.camelize(:lower)}\n"
         | 
| 833 | 
            -
                                else
         | 
| 834 | 
            -
                                  new_line.write "              #{name.singularize.camelize(:lower)}\n"
         | 
| 835 | 
            -
                                end
         | 
| 882 | 
            +
                                new_line.write "              #{name.singularize.camelize(:lower)}\n"
         | 
| 836 883 | 
             
                              end
         | 
| 837 884 | 
             
                            end
         | 
| 838 | 
            -
             | 
| 839 | 
            -
             | 
| 840 | 
            -
                             | 
| 885 | 
            +
                          end
         | 
| 886 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 887 | 
            +
                            @on = true
         | 
| 841 888 | 
             
                          end
         | 
| 842 889 | 
             
                        end
         | 
| 843 890 | 
             
                      end
         | 
| 844 891 | 
             
                    end
         | 
| 892 | 
            +
                  end
         | 
| 845 893 |  | 
| 846 | 
            -
             | 
| 847 | 
            -
             | 
| 848 | 
            -
             | 
| 849 | 
            -
             | 
| 850 | 
            -
             | 
| 851 | 
            -
             | 
| 852 | 
            -
             | 
| 853 | 
            -
             | 
| 854 | 
            -
             | 
| 855 | 
            -
             | 
| 856 | 
            -
             | 
| 857 | 
            -
                                          end
         | 
| 894 | 
            +
                  def rspec_mutation_end class_name: "souls"
         | 
| 895 | 
            +
                    file_path = "./spec/mutations/#{class_name.singularize}_spec.rb"
         | 
| 896 | 
            +
                    path = "./db/schema.rb"
         | 
| 897 | 
            +
                    @on = false
         | 
| 898 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 899 | 
            +
                      File.open(path, "r") do |f|
         | 
| 900 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 901 | 
            +
                          if @on 
         | 
| 902 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 903 | 
            +
                              new_line.write <<~EOS
         | 
| 904 | 
            +
                                            )
         | 
| 858 905 | 
             
                                        end
         | 
| 859 906 | 
             
                                      end
         | 
| 860 | 
            -
                                EOS
         | 
| 861 | 
            -
                                break
         | 
| 862 | 
            -
                              end
         | 
| 863 | 
            -
                              type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 864 | 
            -
                              field ||= type_check type
         | 
| 865 | 
            -
                              array_true = line.include?("array: true")
         | 
| 866 | 
            -
                              case name
         | 
| 867 | 
            -
                              when "user_id", "created_at", "updated_at"
         | 
| 868 | 
            -
                                next
         | 
| 869 | 
            -
                              else
         | 
| 870 | 
            -
                                case type
         | 
| 871 | 
            -
                                when "text", "date", "datetime"
         | 
| 872 | 
            -
                                    if array_true
         | 
| 873 | 
            -
                                      new_line.write "        \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n"
         | 
| 874 | 
            -
                                    else
         | 
| 875 | 
            -
                                      new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
         | 
| 876 907 | 
             
                                    end
         | 
| 877 | 
            -
             | 
| 878 | 
            -
             | 
| 879 | 
            -
                                when "string", "bigint", "integer", "float"
         | 
| 880 | 
            -
                                  new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
         | 
| 881 | 
            -
                                end
         | 
| 882 | 
            -
                              end
         | 
| 908 | 
            +
                              EOS
         | 
| 909 | 
            +
                              break
         | 
| 883 910 | 
             
                            end
         | 
| 884 | 
            -
                             | 
| 885 | 
            -
             | 
| 911 | 
            +
                            type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 912 | 
            +
                            field ||= type_check type
         | 
| 913 | 
            +
                            array_true = line.include?("array: true")
         | 
| 914 | 
            +
                            case name
         | 
| 915 | 
            +
                            when "user_id", "created_at", "updated_at", /$*_id\z/
         | 
| 916 | 
            +
                              next
         | 
| 917 | 
            +
                            else
         | 
| 918 | 
            +
                              case type
         | 
| 919 | 
            +
                              when "text", "date", "datetime"
         | 
| 920 | 
            +
                                  if array_true
         | 
| 921 | 
            +
                                    new_line.write "        \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n"
         | 
| 922 | 
            +
                                  else
         | 
| 923 | 
            +
                                    new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
         | 
| 924 | 
            +
                                  end
         | 
| 925 | 
            +
                              when "boolean"
         | 
| 926 | 
            +
                                new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
         | 
| 927 | 
            +
                              when "string", "bigint", "integer", "float"
         | 
| 928 | 
            +
                                new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
         | 
| 929 | 
            +
                              end
         | 
| 886 930 | 
             
                            end
         | 
| 887 931 | 
             
                          end
         | 
| 932 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 933 | 
            +
                            @on = true
         | 
| 934 | 
            +
                          end
         | 
| 888 935 | 
             
                        end
         | 
| 889 936 | 
             
                      end
         | 
| 890 | 
            -
                      [file_path]
         | 
| 891 937 | 
             
                    end
         | 
| 938 | 
            +
                    [file_path]
         | 
| 939 | 
            +
                  end
         | 
| 892 940 |  | 
| 893 941 | 
             
                  def rspec_mutation class_name: "souls"
         | 
| 894 942 | 
             
                    singularized_class_name = class_name.singularize
         | 
| 895 943 | 
             
                    rspec_mutation_head class_name: singularized_class_name
         | 
| 944 | 
            +
                    rspec_mutation_after_head class_name: singularized_class_name
         | 
| 896 945 | 
             
                    rspec_mutation_params class_name: singularized_class_name
         | 
| 897 946 | 
             
                    rspec_mutation_params_response class_name: singularized_class_name
         | 
| 898 947 | 
             
                    rspec_mutation_end class_name: singularized_class_name
         | 
| @@ -904,109 +953,154 @@ module Souls | |
| 904 953 | 
             
                      f.write <<~EOS
         | 
| 905 954 | 
             
                        RSpec.describe \"#{class_name.camelize} Query テスト\" do
         | 
| 906 955 | 
             
                          describe "#{class_name.camelize} データを取得する" do
         | 
| 907 | 
            -
                            let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
         | 
| 908 | 
            -
             | 
| 909 | 
            -
                            let(:query) do
         | 
| 910 | 
            -
                              data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
         | 
| 911 | 
            -
                              %(query {
         | 
| 912 | 
            -
                                #{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
         | 
| 913 | 
            -
                                  id
         | 
| 914 956 | 
             
                      EOS
         | 
| 915 957 | 
             
                    end
         | 
| 916 958 | 
             
                  end
         | 
| 917 959 |  | 
| 918 | 
            -
             | 
| 919 | 
            -
             | 
| 920 | 
            -
             | 
| 921 | 
            -
             | 
| 922 | 
            -
             | 
| 923 | 
            -
             | 
| 924 | 
            -
             | 
| 925 | 
            -
             | 
| 926 | 
            -
             | 
| 927 | 
            -
             | 
| 928 | 
            -
             | 
| 960 | 
            +
                  def rspec_query_after_head class_name: "souls"
         | 
| 961 | 
            +
                    file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
         | 
| 962 | 
            +
                    path = "./db/schema.rb"
         | 
| 963 | 
            +
                    @on = false
         | 
| 964 | 
            +
                    @user_exist = false
         | 
| 965 | 
            +
                    @relation_params = []
         | 
| 966 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 967 | 
            +
                      File.open(path, "r") do |f|
         | 
| 968 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 969 | 
            +
                          if @on
         | 
| 970 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 971 | 
            +
                              if @relation_params.empty?
         | 
| 972 | 
            +
                              new_line.write <<-EOS
         | 
| 973 | 
            +
                let(:#{class_name}) { FactoryBot.create(:#{class_name}) }
         | 
| 974 | 
            +
             | 
| 975 | 
            +
                let(:query) do
         | 
| 976 | 
            +
                  data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
         | 
| 977 | 
            +
                  %(query {
         | 
| 978 | 
            +
                    #{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
         | 
| 979 | 
            +
                      id
         | 
| 980 | 
            +
                              EOS
         | 
| 981 | 
            +
                              break
         | 
| 982 | 
            +
                              else
         | 
| 983 | 
            +
                              new_line.write <<-EOS
         | 
| 984 | 
            +
                let(:#{class_name}) { FactoryBot.create(:#{class_name}, #{@relation_params.join(", ")}) }
         | 
| 985 | 
            +
             | 
| 986 | 
            +
                let(:query) do
         | 
| 987 | 
            +
                  data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
         | 
| 988 | 
            +
                  %(query {
         | 
| 989 | 
            +
                    #{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
         | 
| 990 | 
            +
                      id
         | 
| 991 | 
            +
                              EOS
         | 
| 992 | 
            +
                              break
         | 
| 993 | 
            +
                              end
         | 
| 994 | 
            +
                            end
         | 
| 995 | 
            +
                            _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 996 | 
            +
                            case name
         | 
| 997 | 
            +
                            when /$*_id\z/
         | 
| 998 | 
            +
                              relation_col = name.gsub("_id", "")
         | 
| 999 | 
            +
                              @relation_params << "#{name}: #{relation_col}.id"
         | 
| 1000 | 
            +
                              new_line.write "    let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
         | 
| 1001 | 
            +
                            end
         | 
| 1002 | 
            +
                          end
         | 
| 1003 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 1004 | 
            +
                            @on = true
         | 
| 1005 | 
            +
                          end
         | 
| 1006 | 
            +
                        end
         | 
| 1007 | 
            +
                      end
         | 
| 1008 | 
            +
                    end
         | 
| 1009 | 
            +
                  end
         | 
| 1010 | 
            +
             | 
| 1011 | 
            +
                  def rspec_query_params class_name: "souls"
         | 
| 1012 | 
            +
                    file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
         | 
| 1013 | 
            +
                    path = "./db/schema.rb"
         | 
| 1014 | 
            +
                    @on = false
         | 
| 1015 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 1016 | 
            +
                      File.open(path, "r") do |f|
         | 
| 1017 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 1018 | 
            +
                          if @on 
         | 
| 1019 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 1020 | 
            +
                              new_line.write <<-EOS
         | 
| 929 1021 | 
             
                    }
         | 
| 930 | 
            -
                   | 
| 931 | 
            -
                 | 
| 1022 | 
            +
                  }
         | 
| 1023 | 
            +
                )
         | 
| 1024 | 
            +
              end
         | 
| 932 1025 |  | 
| 933 | 
            -
             | 
| 934 | 
            -
             | 
| 935 | 
            -
             | 
| 1026 | 
            +
              subject(:result) do
         | 
| 1027 | 
            +
                SoulsApiSchema.execute(query).as_json
         | 
| 1028 | 
            +
              end
         | 
| 936 1029 |  | 
| 937 | 
            -
             | 
| 938 | 
            -
             | 
| 939 | 
            -
             | 
| 940 | 
            -
             | 
| 941 | 
            -
             | 
| 942 | 
            -
             | 
| 943 | 
            -
                              end
         | 
| 944 | 
            -
                              _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 945 | 
            -
                              case name
         | 
| 946 | 
            -
                              when "user_id", "created_at", "updated_at"
         | 
| 947 | 
            -
                                next
         | 
| 948 | 
            -
                              else
         | 
| 949 | 
            -
                                new_line.write "          #{name.singularize.camelize(:lower)}\n"
         | 
| 950 | 
            -
                              end
         | 
| 1030 | 
            +
              it "return #{class_name.camelize} Data" do
         | 
| 1031 | 
            +
                a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}")
         | 
| 1032 | 
            +
                expect(a1).to include(
         | 
| 1033 | 
            +
                  "id" => be_a(String),
         | 
| 1034 | 
            +
                              EOS
         | 
| 1035 | 
            +
                              break
         | 
| 951 1036 | 
             
                            end
         | 
| 952 | 
            -
                             | 
| 953 | 
            -
             | 
| 1037 | 
            +
                            _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 1038 | 
            +
                            case name
         | 
| 1039 | 
            +
                            when "user_id", "created_at", "updated_at", /$*_id\z/
         | 
| 1040 | 
            +
                              next
         | 
| 1041 | 
            +
                            else
         | 
| 1042 | 
            +
                              new_line.write "          #{name.camelize(:lower)}\n"
         | 
| 954 1043 | 
             
                            end
         | 
| 955 1044 | 
             
                          end
         | 
| 1045 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 1046 | 
            +
                            @on = true
         | 
| 1047 | 
            +
                          end
         | 
| 956 1048 | 
             
                        end
         | 
| 957 1049 | 
             
                      end
         | 
| 958 1050 | 
             
                    end
         | 
| 1051 | 
            +
                  end
         | 
| 959 1052 |  | 
| 960 | 
            -
             | 
| 961 | 
            -
             | 
| 962 | 
            -
             | 
| 963 | 
            -
             | 
| 964 | 
            -
             | 
| 965 | 
            -
             | 
| 966 | 
            -
             | 
| 967 | 
            -
             | 
| 968 | 
            -
             | 
| 969 | 
            -
             | 
| 1053 | 
            +
                  def rspec_query_end class_name: "souls"
         | 
| 1054 | 
            +
                    file_path = "./spec/queries/#{class_name.singularize}_spec.rb"
         | 
| 1055 | 
            +
                    path = "./db/schema.rb"
         | 
| 1056 | 
            +
                    @on = false
         | 
| 1057 | 
            +
                    File.open(file_path, "a") do |new_line|
         | 
| 1058 | 
            +
                      File.open(path, "r") do |f|
         | 
| 1059 | 
            +
                        f.each_line.with_index do |line, i|
         | 
| 1060 | 
            +
                          if @on 
         | 
| 1061 | 
            +
                            if line.include?("end") || line.include?("t.index")
         | 
| 1062 | 
            +
                              new_line.write <<-EOS
         | 
| 970 1063 | 
             
                    )
         | 
| 971 1064 | 
             
                end
         | 
| 972 1065 | 
             
              end
         | 
| 973 1066 | 
             
            end
         | 
| 974 | 
            -
             | 
| 975 | 
            -
             | 
| 976 | 
            -
                              end
         | 
| 977 | 
            -
                              type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 978 | 
            -
                              field ||= type_check type
         | 
| 979 | 
            -
                              array_true = line.include?("array: true")
         | 
| 980 | 
            -
                              case name
         | 
| 981 | 
            -
                              when "user_id", "created_at", "updated_at"
         | 
| 982 | 
            -
                                next
         | 
| 983 | 
            -
                              else
         | 
| 984 | 
            -
                                case type
         | 
| 985 | 
            -
                                when "text", "date", "datetime"
         | 
| 986 | 
            -
                                    if array_true
         | 
| 987 | 
            -
                                      new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
         | 
| 988 | 
            -
                                    else
         | 
| 989 | 
            -
                                      new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n"
         | 
| 990 | 
            -
                                    end
         | 
| 991 | 
            -
                                when "boolean"
         | 
| 992 | 
            -
                                  new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
         | 
| 993 | 
            -
                                when "string", "bigint", "integer", "float"
         | 
| 994 | 
            -
                                  new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
         | 
| 995 | 
            -
                                end
         | 
| 996 | 
            -
                              end
         | 
| 1067 | 
            +
                              EOS
         | 
| 1068 | 
            +
                              break
         | 
| 997 1069 | 
             
                            end
         | 
| 998 | 
            -
                             | 
| 999 | 
            -
             | 
| 1070 | 
            +
                            type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
         | 
| 1071 | 
            +
                            field ||= type_check type
         | 
| 1072 | 
            +
                            array_true = line.include?("array: true")
         | 
| 1073 | 
            +
                            case name
         | 
| 1074 | 
            +
                            when "user_id", "created_at", "updated_at", /$*_id\z/
         | 
| 1075 | 
            +
                              next
         | 
| 1076 | 
            +
                            else
         | 
| 1077 | 
            +
                              case type
         | 
| 1078 | 
            +
                              when "text", "date", "datetime"
         | 
| 1079 | 
            +
                                  if array_true
         | 
| 1080 | 
            +
                                    new_line.write "        \"#{name.camelize(:lower)}\" => be_all(String),\n"
         | 
| 1081 | 
            +
                                  else
         | 
| 1082 | 
            +
                                    new_line.write "        \"#{name.camelize(:lower)}\" => be_a(String),\n"
         | 
| 1083 | 
            +
                                  end
         | 
| 1084 | 
            +
                              when "boolean"
         | 
| 1085 | 
            +
                                new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
         | 
| 1086 | 
            +
                              when "string", "bigint", "integer", "float"
         | 
| 1087 | 
            +
                                new_line.write "        \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
         | 
| 1088 | 
            +
                              end
         | 
| 1000 1089 | 
             
                            end
         | 
| 1001 1090 | 
             
                          end
         | 
| 1091 | 
            +
                          if table_check(line: line, class_name: class_name)
         | 
| 1092 | 
            +
                            @on = true
         | 
| 1093 | 
            +
                          end
         | 
| 1002 1094 | 
             
                        end
         | 
| 1003 1095 | 
             
                      end
         | 
| 1004 | 
            -
                      [file_path]
         | 
| 1005 1096 | 
             
                    end
         | 
| 1097 | 
            +
                    [file_path]
         | 
| 1098 | 
            +
                  end
         | 
| 1006 1099 |  | 
| 1007 1100 | 
             
                  def rspec_query class_name: "souls"
         | 
| 1008 1101 | 
             
                    singularized_class_name = class_name.singularize
         | 
| 1009 1102 | 
             
                    rspec_query_head class_name: singularized_class_name
         | 
| 1103 | 
            +
                    rspec_query_after_head class_name: singularized_class_name
         | 
| 1010 1104 | 
             
                    rspec_query_params class_name: singularized_class_name
         | 
| 1011 1105 | 
             
                    rspec_query_end class_name: singularized_class_name
         | 
| 1012 1106 | 
             
                  end
         | 
    
        data/lib/souls/version.rb
    CHANGED
    
    
    
        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. | 
| 4 | 
            +
              version: 0.14.1
         | 
| 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- | 
| 13 | 
            +
            date: 2021-02-02 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. | 
| 72 | 
            +
            rubygems_version: 3.2.3
         | 
| 73 73 | 
             
            signing_key:
         | 
| 74 74 | 
             
            specification_version: 4
         | 
| 75 75 | 
             
            summary: SOULS is a GraphQL Based Web Application Framework for Microservices on Multi
         |