souls 0.60.2 → 0.60.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2a12904fa0b9dd7fc558dcb8bff291ea14302fa9aa14cf87ade8092e27f6cc
4
- data.tar.gz: 9142fb468c45f4fd65930bba9f29f1c796c85a0d62c29059f3fc0184ba7c1956
3
+ metadata.gz: ec823772e4849a995e22414890aff5a90c6521e369c9e1c31974204b6f82d65a
4
+ data.tar.gz: b78d324b3ff93c2e3350d2c059020995e7c8a8479dd3293aead47041b5aa3d5f
5
5
  SHA512:
6
- metadata.gz: 2448ff57ad0c5e940994d81217de376f669d7a33fccf1c8fa0eb65f53a091e8ee0ca9a5aa29521596173554c820ac6584ed2d02071841c9709aca0a5e8781ebb
7
- data.tar.gz: ca45ef93f5db68edffec37f2dd5b915b4070d9ec8204342085da5c3c42a1544075c1b29cbeac3fb0682f9dd8e0971e9c0625d5f558e900223ea1c9163c309cee
6
+ metadata.gz: 18d97704c8db8e3befb5aafadcf19eec3c92bd7472811063295fe26df2d63e5da3153f1337b6d40983b60d13049cb3ebc16d885c146726bf714f05e6506abf77
7
+ data.tar.gz: 8ad57a789e18a2bce598705e5a4d296b73c35b3dbecabccec68cd1acdf75abb3147f55fee4efb1f1d0c9ba7d27869d158b5657936d7803da26a798a354642071
@@ -1,6 +1,7 @@
1
1
  module Souls
2
2
  class Generate < Thor
3
3
  desc "scaffold [CLASS_NAME]", "Generate Scaffold from schema.rb"
4
+ method_option :mutation, type: :boolean, aliases: "--rbs", desc: "Mutation File Name"
4
5
  def scaffold(class_name)
5
6
  singularized_class_name = class_name.singularize
6
7
  model(singularized_class_name)
@@ -5,24 +5,26 @@ module Souls
5
5
  def manager_rbs(class_name)
6
6
  file_path = ""
7
7
  singularized_class_name = class_name.underscore.singularize
8
- file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
9
- FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
10
- file_path = "#{file_dir}/#{options[:mutation]}.rbs"
11
- File.open(file_path, "w") do |f|
12
- f.write(<<~TEXT)
13
- module Mutations
14
- module Managers
15
- module #{singularized_class_name.camelize}Manager
16
- class #{singularized_class_name.camelize}Login
17
- def self.description: (String)-> untyped
18
- def self.argument: (untyped, untyped, untyped)-> untyped
19
- def self.field: (untyped, untyped, untyped)-> untyped
8
+ Dir.chdir(Souls.get_mother_path.to_s) do
9
+ file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
10
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
11
+ file_path = "#{file_dir}/#{options[:mutation]}.rbs"
12
+ File.open(file_path, "w") do |f|
13
+ f.write(<<~TEXT)
14
+ module Mutations
15
+ module Managers
16
+ module #{singularized_class_name.camelize}Manager
17
+ class #{options[:mutation].singularize.camelize}
18
+ def self.description: (String)-> untyped
19
+ def self.argument: (untyped, untyped, untyped)-> untyped
20
+ def self.field: (untyped, untyped, untyped)-> untyped
21
+ end
20
22
  end
21
23
  end
22
24
  end
23
- end
24
- TEXT
25
- puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
25
+ TEXT
26
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
27
+ end
26
28
  end
27
29
  file_path
28
30
  rescue Thor::Error => e
@@ -4,15 +4,13 @@ module Souls
4
4
  def model_rbs(class_name)
5
5
  file_path = ""
6
6
  Dir.chdir(Souls.get_mother_path.to_s) do
7
- file_dir = "./sig/api/app/graphql/types/models/"
7
+ file_dir = "./sig/api/app/models/"
8
8
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
9
9
  singularized_class_name = class_name.underscore.singularize
10
10
  file_path = "#{file_dir}#{singularized_class_name}_model.rbs"
11
11
  File.open(file_path, "w") do |f|
12
12
  f.write(<<~TEXT)
13
- module Types
14
- class #{singularized_class_name.camelize} < ActiveRecord::Base
15
- end
13
+ class #{singularized_class_name.camelize} < ActiveRecord::Base
16
14
  end
17
15
  TEXT
18
16
  end
@@ -55,14 +55,17 @@ module Souls
55
55
  if @user_exist
56
56
  new_line.write(<<-TEXT)
57
57
 
58
- def resolve args
58
+ def resolve(args)
59
59
  params = args.dup
60
60
  params[:user_id] = context[:user][:id]
61
+ data = ::#{class_name.camelize}.new(args)
61
62
  TEXT
62
63
  else
63
64
  new_line.write(<<-TEXT)
64
65
 
65
- def resolve args
66
+ def resolve(args)
67
+ params = args.dup
68
+ data = ::#{class_name.camelize}.new(args)
66
69
  TEXT
67
70
  end
68
71
  break
@@ -93,9 +96,11 @@ module Souls
93
96
  return false if relation_params.empty?
94
97
 
95
98
  file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
96
- relation_params.each do |params_name|
97
- File.open(file_path, "a") do |new_line|
98
- new_line.write(" _, args[:#{params_name}] = SoulsApiSchema.from_global_id(args[:#{params_name}])\n")
99
+
100
+ File.open(file_path, "a") do |new_line|
101
+ relation_params.each_with_index do |params_name, i|
102
+ new_line.write(" params = args.dup\n") if @user_exist && i.zero?
103
+ new_line.write(" _, params[:#{params_name}] = SoulsApiSchema.from_global_id(args[:#{params_name}])\n")
99
104
  end
100
105
  end
101
106
  true
@@ -105,7 +110,6 @@ module Souls
105
110
  file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
106
111
  File.open(file_path, "a") do |new_line|
107
112
  new_line.write(<<~TEXT)
108
- data = ::#{class_name.camelize}.new args
109
113
  raise(StandardError, data.errors.full_messages) unless data.save
110
114
 
111
115
  { #{class_name}_edge: { node: data } }
@@ -14,9 +14,6 @@ module Souls
14
14
  f.write(<<~TEXT)
15
15
  class Base
16
16
  end
17
- module SearchObject
18
- def self.module: (Symbol) -> untyped
19
- end
20
17
  class #{singularized_class_name.camelize}Search < Base
21
18
  include SearchObject
22
19
  def self.scope: () ?{ () -> nil } -> [Hash[Symbol, untyped]]
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.60.2".freeze
2
+ VERSION = "0.60.3".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.39.2
1
+ 0.39.3
@@ -1 +1 @@
1
- 0.39.2
1
+ 0.39.3
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.60.2
4
+ version: 0.60.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI