Sha256: b41aa45d720ab6c4b3d7d6b68cb4180cd553f26d85107902d2f68c85e769f247

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

module Souls
  class Generate < Thor
    desc "edge_rbs [CLASS_NAME]", "Generate GraphQL Edge RBS from schema.rb"
    def edge_rbs(class_name)
      file_path = ""
      Dir.chdir(Souls.get_mother_path.to_s) do
        file_dir = "./sig/api/app/graphql/types/edges/"
        FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
        singularized_class_name = class_name.underscore.singularize
        file_path = "#{file_dir}#{singularized_class_name}_edge.rbs"
        File.open(file_path, "w") do |f|
          f.write(<<~TEXT)
            module Types
              class #{singularized_class_name.camelize}Edge < BaseObject
                def self.implements: (*untyped) -> untyped
                def self.global_id_field: (*untyped) -> untyped
                def self.field: (*untyped) -> untyped
                def self.connection_type: ()-> untyped
              end
            end
          TEXT
        end
        puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
      end
      file_path
    rescue Thor::Error => e
      raise(Thor::Error, e)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
souls-0.58.1 lib/souls/api/generate/edge_rbs.rb
souls-0.58.0 lib/souls/api/generate/edge_rbs.rb
souls-0.57.1 lib/souls/api/generate/edge_rbs.rb
souls-0.57.0 lib/souls/api/generate/edge_rbs.rb
souls-0.56.4 lib/souls/api/generate/edge_rbs.rb
souls-0.56.3 lib/souls/api/generate/edge_rbs.rb
souls-0.56.2 lib/souls/api/generate/edge_rbs.rb
souls-0.56.1 lib/souls/api/generate/edge_rbs.rb
souls-0.56.0 lib/souls/api/generate/edge_rbs.rb