souls 0.23.5 → 0.23.6
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 +73 -138
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -2
- data/exe/souls +68 -68
- data/lib/souls.rb +153 -141
- data/lib/souls/gcloud/compute.rb +61 -51
- data/lib/souls/gcloud/iam.rb +22 -24
- data/lib/souls/generate/application.rb +160 -160
- data/lib/souls/generate/connection.rb +13 -15
- data/lib/souls/generate/edge.rb +13 -15
- data/lib/souls/generate/model.rb +16 -17
- data/lib/souls/generate/mutation.rb +225 -221
- data/lib/souls/generate/policy.rb +44 -45
- data/lib/souls/generate/query.rb +49 -49
- data/lib/souls/generate/resolver.rb +121 -124
- data/lib/souls/generate/rspec_factory.rb +49 -52
- data/lib/souls/generate/rspec_model.rb +17 -18
- data/lib/souls/generate/rspec_mutation.rb +193 -199
- data/lib/souls/generate/rspec_policy.rb +38 -39
- data/lib/souls/generate/rspec_query.rb +133 -140
- data/lib/souls/generate/rspec_resolver.rb +147 -154
- data/lib/souls/generate/type.rb +34 -25
- data/lib/souls/init.rb +51 -50
- data/lib/souls/version.rb +2 -1
- data/souls.gemspec +12 -7
- metadata +5 -5
| @@ -1,52 +1,51 @@ | |
| 1 1 | 
             
            module Souls
         | 
| 2 2 | 
             
              module Generate
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            -
                   | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
                          end
         | 
| 3 | 
            +
                ## Generate Policy
         | 
| 4 | 
            +
                def self.policy(class_name: "souls")
         | 
| 5 | 
            +
                  dir_name = "./app/policies"
         | 
| 6 | 
            +
                  FileUtils.mkdir_p(dir_name) unless Dir.exist?(dir_name)
         | 
| 7 | 
            +
                  file_path = "#{dir_name}/#{class_name.singularize}_policy.rb"
         | 
| 8 | 
            +
                  return "Policy already exist! #{file_path}" if File.exist?(file_path)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  File.open(file_path, "w") do |f|
         | 
| 11 | 
            +
                    f.write(<<~TEXT)
         | 
| 12 | 
            +
                      class #{class_name.camelize}Policy < ApplicationPolicy
         | 
| 13 | 
            +
                        def show?
         | 
| 14 | 
            +
                          true
         | 
| 15 | 
            +
                        end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                        def index?
         | 
| 18 | 
            +
                          true
         | 
| 19 | 
            +
                        end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                        def create?
         | 
| 22 | 
            +
                          user_permissions?
         | 
| 23 | 
            +
                        end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                        def update?
         | 
| 26 | 
            +
                          user_permissions?
         | 
| 27 | 
            +
                        end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                        def delete?
         | 
| 30 | 
            +
                          admin_permissions?
         | 
| 31 | 
            +
                        end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                        private
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                        def user_permissions?
         | 
| 36 | 
            +
                          @user.master? or @user.admin? or @user.user?
         | 
| 37 | 
            +
                        end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                        def admin_permissions?
         | 
| 40 | 
            +
                          @user.master? or @user.admin?
         | 
| 42 41 | 
             
                        end
         | 
| 43 | 
            -
                       | 
| 44 | 
            -
                     | 
| 45 | 
            -
                    puts Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }]
         | 
| 46 | 
            -
                    file_path
         | 
| 47 | 
            -
                  rescue StandardError => e
         | 
| 48 | 
            -
                    raise StandardError, e
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
                    TEXT
         | 
| 49 44 | 
             
                  end
         | 
| 45 | 
            +
                  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
         | 
| 46 | 
            +
                  file_path
         | 
| 47 | 
            +
                rescue StandardError => e
         | 
| 48 | 
            +
                  raise(StandardError, e)
         | 
| 50 49 | 
             
                end
         | 
| 51 50 | 
             
              end
         | 
| 52 51 | 
             
            end
         | 
    
        data/lib/souls/generate/query.rb
    CHANGED
    
    | @@ -1,64 +1,64 @@ | |
| 1 1 | 
             
            module Souls
         | 
| 2 2 | 
             
              module Generate
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            -
                   | 
| 6 | 
            -
             | 
| 7 | 
            -
                    return "Query already exist! #{file_path}" if File.exist? file_path
         | 
| 8 | 
            -
                    File.open(file_path, "w") do |f|
         | 
| 9 | 
            -
                      f.write <<~EOS
         | 
| 10 | 
            -
                        module Queries
         | 
| 11 | 
            -
                          class #{class_name.camelize.pluralize} < Queries::BaseQuery
         | 
| 12 | 
            -
                            type [Types::#{class_name.camelize}Type], null: false
         | 
| 3 | 
            +
                ## Generate Query / Queries
         | 
| 4 | 
            +
                def self.create_queries(class_name: "souls")
         | 
| 5 | 
            +
                  file_path = "./app/graphql/queries/#{class_name.pluralize}.rb"
         | 
| 6 | 
            +
                  return "Query already exist! #{file_path}" if File.exist?(file_path)
         | 
| 13 7 |  | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 8 | 
            +
                  File.open(file_path, "w") do |f|
         | 
| 9 | 
            +
                    f.write(<<~TEXT)
         | 
| 10 | 
            +
                      module Queries
         | 
| 11 | 
            +
                        class #{class_name.camelize.pluralize} < Queries::BaseQuery
         | 
| 12 | 
            +
                          type [Types::#{class_name.camelize}Type], null: false
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                          def resolve
         | 
| 15 | 
            +
                            ::#{class_name.camelize}.all
         | 
| 16 | 
            +
                          rescue StandardError => error
         | 
| 17 | 
            +
                            GraphQL::ExecutionError.new error
         | 
| 19 18 | 
             
                          end
         | 
| 20 19 | 
             
                        end
         | 
| 21 | 
            -
                       | 
| 22 | 
            -
                     | 
| 23 | 
            -
                    puts Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }]
         | 
| 24 | 
            -
                    file_path
         | 
| 25 | 
            -
                  rescue StandardError => e
         | 
| 26 | 
            -
                    raise StandardError, e
         | 
| 20 | 
            +
                      end
         | 
| 21 | 
            +
                    TEXT
         | 
| 27 22 | 
             
                  end
         | 
| 23 | 
            +
                  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
         | 
| 24 | 
            +
                  file_path
         | 
| 25 | 
            +
                rescue StandardError => e
         | 
| 26 | 
            +
                  raise(StandardError, e)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def self.create_query(class_name: "souls")
         | 
| 30 | 
            +
                  file_path = "./app/graphql/queries/#{class_name}.rb"
         | 
| 31 | 
            +
                  return "Query already exist! #{file_path}" if File.exist?(file_path)
         | 
| 28 32 |  | 
| 29 | 
            -
                   | 
| 30 | 
            -
                     | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                          class #{class_name.camelize} < Queries::BaseQuery
         | 
| 36 | 
            -
                            type Types::#{class_name.camelize}Type, null: false
         | 
| 37 | 
            -
                            argument :id, String, required: true
         | 
| 33 | 
            +
                  File.open(file_path, "w") do |f|
         | 
| 34 | 
            +
                    f.write(<<~TEXT)
         | 
| 35 | 
            +
                      module Queries
         | 
| 36 | 
            +
                        class #{class_name.camelize} < Queries::BaseQuery
         | 
| 37 | 
            +
                          type Types::#{class_name.camelize}Type, null: false
         | 
| 38 | 
            +
                          argument :id, String, required: true
         | 
| 38 39 |  | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
                            end
         | 
| 40 | 
            +
                          def resolve **args
         | 
| 41 | 
            +
                            _, data_id = SoulsApiSchema.from_global_id args[:id]
         | 
| 42 | 
            +
                            ::#{class_name.camelize}.find(data_id)
         | 
| 43 | 
            +
                          rescue StandardError => error
         | 
| 44 | 
            +
                            GraphQL::ExecutionError.new error
         | 
| 45 45 | 
             
                          end
         | 
| 46 46 | 
             
                        end
         | 
| 47 | 
            -
                       | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
                     | 
| 51 | 
            -
                      raise StandardError, e
         | 
| 52 | 
            -
                    end
         | 
| 53 | 
            -
                  end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                  def query class_name: "souls"
         | 
| 56 | 
            -
                    singularized_class_name = class_name.singularize
         | 
| 57 | 
            -
                    create_query(class_name: singularized_class_name)
         | 
| 58 | 
            -
                    create_queries(class_name: singularized_class_name)
         | 
| 47 | 
            +
                      end
         | 
| 48 | 
            +
                    TEXT
         | 
| 49 | 
            +
                    puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
         | 
| 50 | 
            +
                    file_path
         | 
| 59 51 | 
             
                  rescue StandardError => e
         | 
| 60 | 
            -
                    raise | 
| 52 | 
            +
                    raise(StandardError, e)
         | 
| 61 53 | 
             
                  end
         | 
| 62 54 | 
             
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def self.query(class_name: "souls")
         | 
| 57 | 
            +
                  singularized_class_name = class_name.singularize
         | 
| 58 | 
            +
                  create_query(class_name: singularized_class_name)
         | 
| 59 | 
            +
                  create_queries(class_name: singularized_class_name)
         | 
| 60 | 
            +
                rescue StandardError => e
         | 
| 61 | 
            +
                  raise(StandardError, e)
         | 
| 62 | 
            +
                end
         | 
| 63 63 | 
             
              end
         | 
| 64 64 | 
             
            end
         | 
| @@ -1,155 +1,152 @@ | |
| 1 1 | 
             
            module Souls
         | 
| 2 2 | 
             
              module Generate
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            -
                   | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
                     | 
| 10 | 
            -
                       | 
| 11 | 
            -
                         | 
| 12 | 
            -
                           | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                            description "Search #{class_name.camelize}"
         | 
| 3 | 
            +
                ## Generate Resolver
         | 
| 4 | 
            +
                def self.resolver_head(class_name: "souls")
         | 
| 5 | 
            +
                  FileUtils.mkdir_p("./app/graphql/resolvers") unless Dir.exist?("./app/graphql/resolvers")
         | 
| 6 | 
            +
                  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 7 | 
            +
                  @relation_params = []
         | 
| 8 | 
            +
                  File.open(file_path, "w") do |f|
         | 
| 9 | 
            +
                    f.write(<<~TEXT)
         | 
| 10 | 
            +
                      module Resolvers
         | 
| 11 | 
            +
                        class #{class_name.camelize}Search < Base
         | 
| 12 | 
            +
                          include SearchObject.module(:graphql)
         | 
| 13 | 
            +
                          scope { ::#{class_name.camelize}.all }
         | 
| 14 | 
            +
                          type Types::#{class_name.camelize}Type.connection_type, null: false
         | 
| 15 | 
            +
                          description "Search #{class_name.camelize}"
         | 
| 17 16 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                    end
         | 
| 17 | 
            +
                          class #{class_name.camelize}Filter < ::Types::BaseInputObject
         | 
| 18 | 
            +
                            argument :OR, [self], required: false
         | 
| 19 | 
            +
                    TEXT
         | 
| 22 20 | 
             
                  end
         | 
| 21 | 
            +
                end
         | 
| 23 22 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
                             | 
| 42 | 
            -
             | 
| 43 | 
            -
                             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
                             | 
| 47 | 
            -
             | 
| 48 | 
            -
                             | 
| 49 | 
            -
                              new_line.write "      argument :#{name}, #{field}, required: false\n"
         | 
| 50 | 
            -
                            end
         | 
| 23 | 
            +
                def self.resolver_params(class_name: "souls")
         | 
| 24 | 
            +
                  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 25 | 
            +
                  path = "./db/schema.rb"
         | 
| 26 | 
            +
                  @on = false
         | 
| 27 | 
            +
                  @user_exist = false
         | 
| 28 | 
            +
                  @relation_params = []
         | 
| 29 | 
            +
                  File.open(file_path, "a") do |new_line|
         | 
| 30 | 
            +
                    File.open(path, "r") do |f|
         | 
| 31 | 
            +
                      f.each_line.with_index do |line, _i|
         | 
| 32 | 
            +
                        if @on
         | 
| 33 | 
            +
                          break if line.include?("end") || line.include?("t.index")
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                          field = "[String]" if line.include?("array: true")
         | 
| 36 | 
            +
                          type, name = get_type_and_name(line)
         | 
| 37 | 
            +
                          field ||= type_check(type)
         | 
| 38 | 
            +
                          case name
         | 
| 39 | 
            +
                          when "user_id"
         | 
| 40 | 
            +
                            @user_exist = true
         | 
| 41 | 
            +
                          when /$*_id\z/
         | 
| 42 | 
            +
                            @relation_params << name
         | 
| 43 | 
            +
                            new_line.write("      argument :#{name}, String, required: false\n")
         | 
| 44 | 
            +
                          when "created_at", "updated_at"
         | 
| 45 | 
            +
                            next
         | 
| 46 | 
            +
                          else
         | 
| 47 | 
            +
                            new_line.write("      argument :#{name}, #{field}, required: false\n")
         | 
| 51 48 | 
             
                          end
         | 
| 52 | 
            -
                          @on = true if table_check(line: line, class_name: class_name)
         | 
| 53 49 | 
             
                        end
         | 
| 50 | 
            +
                        @on = true if table_check(line: line, class_name: class_name)
         | 
| 54 51 | 
             
                      end
         | 
| 55 52 | 
             
                    end
         | 
| 56 53 | 
             
                  end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                  def resolver_after_params class_name: "souls"
         | 
| 59 | 
            -
                    file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 60 | 
            -
                    File.open(file_path, "a") do |f|
         | 
| 61 | 
            -
                      f.write <<-EOS
         | 
| 62 | 
            -
                  argument :start_date, String, required: false
         | 
| 63 | 
            -
                  argument :end_date, String, required: false
         | 
| 64 54 | 
             
                end
         | 
| 65 55 |  | 
| 66 | 
            -
                 | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 56 | 
            +
                def self.resolver_after_params(class_name: "souls")
         | 
| 57 | 
            +
                  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 58 | 
            +
                  File.open(file_path, "a") do |f|
         | 
| 59 | 
            +
                    f.write(<<-TEXT)
         | 
| 60 | 
            +
                argument :start_date, String, required: false
         | 
| 61 | 
            +
                argument :end_date, String, required: false
         | 
| 62 | 
            +
              end
         | 
| 69 63 |  | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
                end
         | 
| 64 | 
            +
              option :filter, type: #{class_name.camelize}Filter, with: :apply_filter
         | 
| 65 | 
            +
              option :first, type: types.Int, with: :apply_first
         | 
| 66 | 
            +
              option :skip, type: types.Int, with: :apply_skip
         | 
| 74 67 |  | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 68 | 
            +
              def apply_filter(scope, value)
         | 
| 69 | 
            +
                branches = normalize_filters(value).inject { |a, b| a.or(b) }
         | 
| 70 | 
            +
                scope.merge branches
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              def normalize_filters(value, branches = [])
         | 
| 74 | 
            +
                scope = ::#{class_name.camelize}.all
         | 
| 75 | 
            +
                    TEXT
         | 
| 79 76 | 
             
                  end
         | 
| 77 | 
            +
                end
         | 
| 80 78 |  | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
                             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
                             | 
| 101 | 
            -
             | 
| 102 | 
            -
                             | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
                             | 
| 106 | 
            -
             | 
| 79 | 
            +
                def self.resolver_before_end(class_name: "souls")
         | 
| 80 | 
            +
                  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 81 | 
            +
                  path = "./db/schema.rb"
         | 
| 82 | 
            +
                  @on = false
         | 
| 83 | 
            +
                  @user_exist = false
         | 
| 84 | 
            +
                  @relation_params = []
         | 
| 85 | 
            +
                  File.open(file_path, "a") do |new_line|
         | 
| 86 | 
            +
                    File.open(path, "r") do |f|
         | 
| 87 | 
            +
                      f.each_line.with_index do |line, _i|
         | 
| 88 | 
            +
                        if @on
         | 
| 89 | 
            +
                          break if line.include?("end") || line.include?("t.index")
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                          type, name = get_type_and_name(line)
         | 
| 92 | 
            +
                          if line.include?("array: true")
         | 
| 93 | 
            +
                            new_line.write("      scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n")
         | 
| 94 | 
            +
                            next
         | 
| 95 | 
            +
                          end
         | 
| 96 | 
            +
                          case name
         | 
| 97 | 
            +
                          when "user_id"
         | 
| 98 | 
            +
                            @user_exist = true
         | 
| 99 | 
            +
                          when /$*_id\z/
         | 
| 100 | 
            +
                            @relation_params << name
         | 
| 101 | 
            +
                            new_line.write("      scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n")
         | 
| 102 | 
            +
                          when "created_at", "updated_at"
         | 
| 103 | 
            +
                            next
         | 
| 104 | 
            +
                          else
         | 
| 105 | 
            +
                            case type
         | 
| 106 | 
            +
                            when "boolean"
         | 
| 107 | 
            +
                              new_line.write("      scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n")
         | 
| 107 108 | 
             
                            else
         | 
| 108 | 
            -
                               | 
| 109 | 
            -
                              when "boolean"
         | 
| 110 | 
            -
                                new_line.write "      scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n"
         | 
| 111 | 
            -
                              else
         | 
| 112 | 
            -
                                new_line.write "      scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n"
         | 
| 113 | 
            -
                              end
         | 
| 109 | 
            +
                              new_line.write("      scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n")
         | 
| 114 110 | 
             
                            end
         | 
| 115 111 | 
             
                          end
         | 
| 116 | 
            -
                          @on = true if table_check(line: line, class_name: class_name)
         | 
| 117 112 | 
             
                        end
         | 
| 113 | 
            +
                        @on = true if table_check(line: line, class_name: class_name)
         | 
| 118 114 | 
             
                      end
         | 
| 119 115 | 
             
                    end
         | 
| 120 116 | 
             
                  end
         | 
| 117 | 
            +
                end
         | 
| 121 118 |  | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
             | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
                            end
         | 
| 119 | 
            +
                def self.resolver_end(class_name: "souls")
         | 
| 120 | 
            +
                  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
         | 
| 121 | 
            +
                  File.open(file_path, "a") do |f|
         | 
| 122 | 
            +
                    f.write(<<~TEXT)
         | 
| 123 | 
            +
                            scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
         | 
| 124 | 
            +
                            scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
         | 
| 125 | 
            +
                            branches << scope
         | 
| 126 | 
            +
                            value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
         | 
| 127 | 
            +
                            branches
         | 
| 132 128 | 
             
                          end
         | 
| 133 129 | 
             
                        end
         | 
| 134 | 
            -
                       | 
| 135 | 
            -
                     | 
| 136 | 
            -
                    file_path
         | 
| 130 | 
            +
                      end
         | 
| 131 | 
            +
                    TEXT
         | 
| 137 132 | 
             
                  end
         | 
| 133 | 
            +
                  file_path
         | 
| 134 | 
            +
                end
         | 
| 138 135 |  | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
                   | 
| 151 | 
            -
             | 
| 152 | 
            -
                   | 
| 136 | 
            +
                def self.resolver(class_name: "souls")
         | 
| 137 | 
            +
                  singularized_class_name = class_name.singularize.underscore
         | 
| 138 | 
            +
                  file_path = "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
         | 
| 139 | 
            +
                  return "Resolver already exist! #{file_path}" if File.exist?(file_path)
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                  resolver_head(class_name: singularized_class_name)
         | 
| 142 | 
            +
                  resolver_params(class_name: singularized_class_name)
         | 
| 143 | 
            +
                  resolver_after_params(class_name: singularized_class_name)
         | 
| 144 | 
            +
                  resolver_before_end(class_name: singularized_class_name)
         | 
| 145 | 
            +
                  resolver_end(class_name: singularized_class_name)
         | 
| 146 | 
            +
                  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
         | 
| 147 | 
            +
                  file_path
         | 
| 148 | 
            +
                rescue StandardError => e
         | 
| 149 | 
            +
                  raise(StandardError, e)
         | 
| 153 150 | 
             
                end
         | 
| 154 151 | 
             
              end
         | 
| 155 152 | 
             
            end
         |