Sha256: 81b66d4d2737b2d8aef365935975a6c8005c6d6f40639030fe212925aa0ce536

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

module Souls
  class Generate < Thor
    desc "manager_rbs [CLASS_NAME]", "Generate SOULs Manager RBS Template"
    method_option :mutation, aliases: "--mutation", required: true, desc: "Mutation File Name"
    def manager_rbs(class_name)
      file_path = ""
      singularized_class_name = class_name.underscore.singularize
      Dir.chdir(Souls.get_mother_path.to_s) do
        file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
        FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
        file_path = "#{file_dir}/#{options[:mutation]}.rbs"
        File.open(file_path, "w") do |f|
          f.write(<<~TEXT)
            module Mutations
              module Managers
                module #{singularized_class_name.camelize}Manager < BaseMutation
                  class #{options[:mutation].singularize.camelize}
                    def self.description: (String)-> untyped
                    def self.argument: (untyped, untyped, untyped)-> untyped
                    def self.field: (untyped, untyped, untyped)-> untyped
                  end
                end
              end
            end
          TEXT
          Souls::Painter.create_file(file_path.to_s)
        end
      end
      file_path
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
souls-1.13.6 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.5 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.4 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.3 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.2 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.1 lib/souls/cli/generate/manager_rbs.rb
souls-1.13.0 lib/souls/cli/generate/manager_rbs.rb