souls 0.29.7 → 0.30.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc98a9c24cdabf1ec57a40a86568022f359ea9f06dca660e43026be99f15cd35
4
- data.tar.gz: 1a98e52c5c2c99db4f862eb3df16cbb203103582cb6eff0bbfb82ba3c124fb07
3
+ metadata.gz: 5962fa30ee40e4c0970f8f674fb311d006abd7743d6d5163b5c5918fba6a290e
4
+ data.tar.gz: 297905b6a9a0e7f341c55de8917947850c895412f034ae6a22911b95cf44b37b
5
5
  SHA512:
6
- metadata.gz: a69a2c609172b3d5a0d3c0bbe9578a1b67aa9a0613c217b1f6d3cfcc2b62b34ff21d455cb933728383eecff5fe61ae3a30ea7ddba7d833cc54c44dde8026818e
7
- data.tar.gz: 46b1abe8dd28421a07480afadf78ee88b21a58593d61869b3cc5deaca895f006a34ca9c4efd9a8de4c1dc70c59b14241f17b78396be8106e78e6ef58a5a92b9d
6
+ metadata.gz: 1d02f01e778522c4c9e7a59260d361608acf5117b3c942dbe1b413e30f4b2ccb1494c5866fe6a94ee3c7d8cfcc6fb585f001831db62dbf86c3ff89a185ed7daf
7
+ data.tar.gz: e5ba936eb96bb0be0bb1abe6c346e029d57c2c32acfa58f21253d5dc63565025681cd67c60c210899bd6352d9c542d8639be582f79d83989d9acfa3d1b2d2342
data/exe/souls CHANGED
@@ -21,7 +21,12 @@ begin
21
21
  Whirly.status = "Done!"
22
22
  end
23
23
  when "schema:update"
24
- Souls::Api::Update.update_create_mutation_head
24
+ class_name = ARGV[2]
25
+ Souls::Api::Update.create_mutation(class_name: class_name)
26
+ Souls::Api::Update.update_mutation(class_name: class_name)
27
+ Souls::Api::Update.rspec_factory(class_name: class_name)
28
+ Souls::Api::Update.rspec_mutation(class_name: class_name)
29
+ Souls::Api::Update.rspec_resolver(class_name: class_name)
25
30
  else
26
31
  puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
27
32
  end
data/lib/souls.rb CHANGED
@@ -332,6 +332,17 @@ module Souls
332
332
  }
333
333
  end
334
334
 
335
+ def check_schema(class_name: "user")
336
+ schema_data = get_columns_num(class_name: class_name)
337
+ create_migration_data = get_create_migration_type(class_name: class_name)
338
+ add_migration_data = get_migration_type(class_name: class_name, action: "add")
339
+ remove_migration_data = get_migration_type(class_name: class_name, action: "remove")
340
+ migration_data = create_migration_data + add_migration_data - remove_migration_data
341
+ return "Already Up to date!" if schema_data.size == migration_data.size
342
+
343
+ schema_data - migration_data
344
+ end
345
+
335
346
  def get_columns_num(class_name: "user")
336
347
  file_path = "./db/schema.rb"
337
348
  class_check_flag = false
@@ -351,28 +362,62 @@ module Souls
351
362
  cols
352
363
  end
353
364
 
354
- def get_add_migration_type(class_name: "user")
365
+ def get_create_migration_type(class_name: "user")
366
+ pluralized_class_name = class_name.pluralize
367
+ file_path = Dir["db/migrate/*_create_#{pluralized_class_name}.rb"][0]
368
+
369
+ class_check_flag = false
370
+ response = [
371
+ { column_name: "created_at", type: "datetime", array: false },
372
+ { column_name: "updated_at", type: "datetime", array: false }
373
+ ]
374
+ File.open(file_path) do |f|
375
+ f.each_line do |line|
376
+ class_check_flag = true if line.include?("create_table")
377
+ next unless class_check_flag == true && !line.include?("create_table")
378
+ return response if line.include?("t.timestamps") || line.strip == "end"
379
+
380
+ types = Souls::Api::Generate.get_type_and_name(line)
381
+ types.map { |n| n.gsub!(":", "") }
382
+ array = line.include?("array: true")
383
+ response << { column_name: types[1], type: types[0], array: array }
384
+ end
385
+ end
386
+ end
387
+
388
+ def get_migration_type(class_name: "user", action: "add")
355
389
  pluralized_class_name = class_name.pluralize
356
- file_paths = Dir["db/migrate/*_add_column_to_#{pluralized_class_name}.rb"]
357
- p(file_paths)
390
+ file_paths = Dir["db/migrate/*_#{action}_column_to_#{pluralized_class_name}.rb"]
391
+
358
392
  new_columns =
359
393
  file_paths.map do |file_path|
360
- get_col_name_and_type(class_name: class_name, file_path: file_path)
394
+ get_col_name_and_type(class_name: class_name, file_path: file_path, action: action)
361
395
  end
362
396
  new_columns.flatten
363
397
  end
364
398
 
365
- def get_col_name_and_type(class_name: "user", file_path: "db/migrate/20210816094410_add_column_to_users.rb")
399
+ def get_last_migration_type(class_name: "user", action: "add")
400
+ pluralized_class_name = class_name.pluralize
401
+ file_paths = Dir["db/migrate/*_#{action}_column_to_#{pluralized_class_name}.rb"]
402
+
403
+ file_paths.max
404
+ resoponse = get_col_name_and_type(class_name: class_name, file_path: file_paths.max, action: action)
405
+ resoponse.flatten
406
+ end
407
+
408
+ def get_col_name_and_type(
409
+ class_name: "user", file_path: "db/migrate/20210816094410_add_column_to_users.rb", action: "add"
410
+ )
366
411
  pluralized_class_name = class_name.pluralize
367
412
  response = []
368
413
  File.open(file_path) do |line|
369
414
  line.each_line do |file_line|
370
- next unless file_line.include?("add_column")
415
+ next unless file_line.include?("#{action}_column")
371
416
 
372
417
  array = file_line.include?("array: true")
373
418
  types = file_line.split(",").map(&:strip)
374
419
  types.map { |n| n.gsub!(":", "") }
375
- types[0].gsub!("add_column ", "")
420
+ types[0].gsub!("#{action}_column ", "")
376
421
  unless types[0].to_s == pluralized_class_name
377
422
  raise(StandardError, "Wrong class_name!Please Check your migration file!")
378
423
  end
@@ -76,14 +76,14 @@ module Souls
76
76
 
77
77
  def self.get_test_type(type)
78
78
  {
79
- bigint: 1,
79
+ bigint: "rand(1..10)",
80
80
  float: 4.2,
81
81
  string: '"MyString"',
82
82
  text: '"MyString"',
83
83
  datetime: "Time.now",
84
- date: "Time.now",
84
+ date: "Time.now.strftime('%F')",
85
85
  boolean: false,
86
- integer: 1
86
+ integer: "rand(1..10)"
87
87
  }[type.to_sym]
88
88
  end
89
89
 
@@ -92,10 +92,10 @@ module Souls
92
92
  " #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
93
93
  )
94
94
  else
95
+ camel = name.singularize.camelize(:lower)
96
+ camels = name.pluralize.camelize(:lower)
95
97
  case type
96
98
  when "string", "text", "date", "datetime"
97
- camel = name.singularize.camelize(:lower)
98
- camels = name.pluralize.camelize(:lower)
99
99
  if array_true
100
100
  new_line.write(
101
101
  " #{camels}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
@@ -1,4 +1,9 @@
1
- require_relative "./update/update_mutation"
1
+ require_relative "./update/mutation"
2
+ require_relative "./update/resolver"
3
+ require_relative "./update/type"
4
+ require_relative "./update/rspec_factory"
5
+ require_relative "./update/rspec_mutation"
6
+ require_relative "./update/rspec_resolver"
2
7
 
3
8
  module Souls
4
9
  module Api::Update
@@ -0,0 +1,79 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def create_mutation(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
9
+ new_file_path = "tmp/create_mutation.rb"
10
+ file_path = "#{dir_name}/create_#{singularized_class_name}.rb"
11
+ argument = false
12
+ File.open(file_path) do |f|
13
+ File.open(new_file_path, "w") do |new_line|
14
+ f.each_line do |line|
15
+ new_line.write(line)
16
+ next unless line.include?("argument") && !argument
17
+
18
+ new_cols.each do |col|
19
+ type = col[:array] ? "[#{col[:type].camelize}]" : col[:type].camelize
20
+ args = check_mutation_argument(class_name: class_name)
21
+ unless args.include?(col[:column_name])
22
+ new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
23
+ end
24
+ end
25
+ argument = true
26
+ end
27
+ end
28
+ end
29
+ FileUtils.rm(file_path)
30
+ FileUtils.mv(new_file_path, file_path)
31
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
32
+ end
33
+
34
+ def update_update_mutation(class_name: "user")
35
+ singularized_class_name = class_name.singularize.underscore
36
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
37
+ dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
38
+ new_file_path = "tmp/update_mutation.rb"
39
+ file_path = "#{dir_name}/update_#{singularized_class_name}.rb"
40
+ argument = false
41
+ File.open(file_path) do |f|
42
+ File.open(new_file_path, "w") do |new_line|
43
+ f.each_line do |line|
44
+ new_line.write(line)
45
+ next unless line.include?("argument") && !argument
46
+
47
+ new_cols.each do |col|
48
+ type = Souls::Api::Generate.type_check(col[:type])
49
+ type = "[#{type}]" if col[:array]
50
+ args = check_mutation_argument(class_name: class_name, action: "update")
51
+ unless args.include?(col[:column_name])
52
+ new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
53
+ end
54
+ end
55
+ argument = true
56
+ end
57
+ end
58
+ end
59
+ FileUtils.rm(file_path)
60
+ FileUtils.mv(new_file_path, file_path)
61
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
62
+ end
63
+
64
+ def check_mutation_argument(class_name: "user", action: "create")
65
+ singularized_class_name = class_name.singularize.underscore
66
+ dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
67
+ file_path = "#{dir_name}/#{action}_#{singularized_class_name}.rb"
68
+ args = []
69
+ File.open(file_path) do |f|
70
+ f.each_line do |line|
71
+ args << line.split(",")[0].gsub("argument :", "").strip.underscore if line.include?("argument")
72
+ end
73
+ end
74
+ args
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,72 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def resolver(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./app/graphql/resolvers"
9
+ new_file_path = "tmp/update_resolver.rb"
10
+ file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
11
+ args = check_resolver_argument(class_name: class_name)
12
+ scope_args = check_resolver_argument(class_name: class_name, action: "scope")
13
+ argument = false
14
+ scope = false
15
+ File.open(file_path) do |f|
16
+ File.open(new_file_path, "w") do |new_line|
17
+ f.each_line do |line|
18
+ new_line.write(line)
19
+ if line.include?("argument") && !argument
20
+ new_cols.each do |col|
21
+ type = Souls::Api::Generate.type_check(col[:type])
22
+ type = "[#{type}]" if col[:array]
23
+ add_line = " argument :#{col[:column_name]}, #{type}, required: false\n"
24
+ new_line.write(add_line) unless args.include?(col[:column_name])
25
+ end
26
+ argument = true
27
+ elsif line.include?("scope = ::") && !scope
28
+ new_cols.each do |col|
29
+ type = Souls::Api::Generate.type_check(col[:type])
30
+ type = "[#{type}]" if col[:array]
31
+
32
+ if type.include?("[")
33
+ add_line = " scope = scope.where('#{col[:column_name]} @> ARRAY[?]::#{col[:type]}[]', value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
34
+ else
35
+ add_line = " scope = scope.where(#{col[:column_name]}: value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
36
+ end
37
+ new_line.write(add_line) unless scope_args.include?(col[:column_name])
38
+ end
39
+ scope = true
40
+ end
41
+ end
42
+ end
43
+ end
44
+ FileUtils.rm(file_path)
45
+ FileUtils.mv(new_file_path, file_path)
46
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
47
+ end
48
+
49
+ def check_resolver_argument(class_name: "user", action: "argument")
50
+ singularized_class_name = class_name.singularize.underscore
51
+ dir_name = "./app/graphql/resolvers"
52
+ file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
53
+ args = []
54
+ File.open(file_path) do |f|
55
+ f.each_line do |line|
56
+ if action == "scope" && line.include?("scope = scope.where")
57
+ args << if line.include?("is_deleted")
58
+ "is_deleted"
59
+ else
60
+ line.to_s.match(/if value\[:(.+)\]/)[1].underscore
61
+ end
62
+ elsif action == "argument" && line.include?("argument")
63
+ args << line.split(",")[0].gsub("argument :", "").strip.underscore
64
+ end
65
+ end
66
+ end
67
+ args
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,50 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def rspec_factory(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ pluralized_class_name = class_name.pluralize.underscore
8
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
9
+ dir_name = "./spec/factories"
10
+ new_file_path = "tmp/create_factory.rb"
11
+ file_path = "#{dir_name}/#{pluralized_class_name}.rb"
12
+ argument = false
13
+ File.open(file_path) do |f|
14
+ File.open(new_file_path, "w") do |new_line|
15
+ f.each_line do |line|
16
+ new_line.write(line)
17
+ next unless line.include?("{") && !argument
18
+
19
+ new_cols.each do |col|
20
+ type = Souls::Api::Generate.get_test_type(col[:type])
21
+ type = "[#{type}]" if col[:array]
22
+ args = check_factory_argument(class_name: class_name)
23
+
24
+ new_line.write(" #{col[:column_name]} { #{type} }\n") unless args.include?(col[:column_name])
25
+ end
26
+ argument = true
27
+ end
28
+ end
29
+ end
30
+ FileUtils.rm(file_path)
31
+ FileUtils.mv(new_file_path, file_path)
32
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
33
+ end
34
+
35
+ def check_factory_argument(class_name: "user")
36
+ pluralized_class_name = class_name.pluralize.underscore
37
+ dir_name = "./spec/factories"
38
+ file_path = "#{dir_name}/#{pluralized_class_name}.rb"
39
+ args = []
40
+ File.open(file_path) do |f|
41
+ f.each_line do |line|
42
+ args << line.split("{")[0].strip.underscore if line.include?("{")
43
+ end
44
+ end
45
+ args
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,97 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def rspec_mutation(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./spec/mutations/base"
9
+ new_file_path = "tmp/rspec_mutation.rb"
10
+ file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
11
+ argument = false
12
+ node_res = false
13
+ test_res = false
14
+ File.open(file_path) do |f|
15
+ File.open(new_file_path, "w") do |new_line|
16
+ f.each_line do |line|
17
+ new_line.write(line)
18
+ node_res = true if line.include?("node {")
19
+ test_res = true if line.include?("include(")
20
+ node_res = false if node_res && line.include?("}")
21
+ test_res = false if test_res && line.strip == ")"
22
+
23
+ if line.include?('#{') && !argument
24
+ new_cols.each do |col|
25
+ type = Souls::Api::Generate.type_check(col[:type])
26
+ if type == "String" && !col[:array]
27
+ type_line = " #{col[:column_name].singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{col[:column_name].singularize.underscore}]}\"\n"
28
+ else
29
+ type_line = " #{col[:column_name].singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{col[:column_name].singularize.underscore}]}\n"
30
+ end
31
+ args = check_rspec_mutation_argument(class_name: class_name)
32
+ new_line.write(type_line) unless args.include?(col[:column_name].singularize.underscore)
33
+ end
34
+ argument = true
35
+ elsif node_res && !line.include?("{")
36
+ node_args = check_rspec_mutation_argument(class_name: class_name, action: "node_args")
37
+ new_cols.each do |col|
38
+ new_line.write(" #{col[:column_name]}\n") unless node_args.include?(col[:column_name])
39
+ end
40
+ node_res = false
41
+ elsif test_res && line.include?("=> be_")
42
+ test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
43
+ new_cols.each do |col|
44
+ type = Souls::Api::Generate.type_check(col[:type])
45
+ text =
46
+ case type
47
+ when "String"
48
+ col[:array] ? "be_all(String)" : "be_a(String)"
49
+ when "Integer", "Float"
50
+ col[:array] ? "be_all(Integer)" : "be_a(Integer)"
51
+ when "Boolean"
52
+ col[:array] ? "be_all([true, false])" : "be_in([true, false])"
53
+ else
54
+ col[:array] ? "be_all(String)" : "be_a(String)"
55
+ end
56
+ unless test_args.include?(col[:column_name])
57
+ new_line.write(" \"#{col[:column_name]}\" => #{text},\n")
58
+ end
59
+ end
60
+ test_res = false
61
+ end
62
+ end
63
+ end
64
+ end
65
+ FileUtils.rm(file_path)
66
+ FileUtils.mv(new_file_path, file_path)
67
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
68
+ end
69
+
70
+ def check_rspec_mutation_argument(class_name: "user", action: "argument")
71
+ singularized_class_name = class_name.singularize.underscore
72
+ dir_name = "./spec/mutations/base"
73
+ file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
74
+ node_res = false
75
+ test_res = false
76
+ args = []
77
+ File.open(file_path) do |f|
78
+ f.each_line do |line|
79
+ node_res = true if line.include?("node {")
80
+ test_res = true if line.include?("include(")
81
+ node_res = false if node_res && line.include?("}")
82
+ test_res = false if test_res && line.strip == ")"
83
+ if action == "node_args"
84
+ args << line.strip.underscore if node_res && !line.include?("{")
85
+ elsif action == "test_args"
86
+ args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
87
+ elsif line.include?('#{')
88
+ args << line.split(":")[0].strip.underscore
89
+ end
90
+ end
91
+ end
92
+ args
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,85 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def rspec_resolver(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./spec/resolvers"
9
+ new_file_path = "tmp/rspec_resolver.rb"
10
+ file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
11
+ node_res = false
12
+ test_res = false
13
+ File.open(file_path) do |f|
14
+ File.open(new_file_path, "w") do |new_line|
15
+ f.each_line do |line|
16
+ new_line.write(line)
17
+ node_res = true if line.include?("node {")
18
+ test_res = true if line.include?("include(")
19
+ node_res = false if node_res && line.include?("}")
20
+ test_res = false if test_res && line.strip == ")"
21
+
22
+ if node_res && !line.include?("{")
23
+ node_args = check_rspec_resolver_argument(class_name: class_name, action: "node_args")
24
+ new_cols.each do |col|
25
+ new_line.write(" #{col[:column_name].camelize}\n") unless node_args.include?(col[:column_name])
26
+ end
27
+ node_res = false
28
+ elsif test_res && line.include?("=> be_")
29
+ test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
30
+ new_cols.each do |col|
31
+ type = Souls::Api::Generate.type_check(col[:type])
32
+ p type
33
+ text =
34
+ case type
35
+ when "String"
36
+ col[:array] ? "be_all(String)" : "be_a(String)"
37
+ when "Integer", "Float"
38
+ col[:array] ? "be_all(Integer)" : "be_a(Integer)"
39
+ when "Boolean"
40
+ col[:array] ? "be_all([true, false])" : "be_in([true, false])"
41
+ else
42
+ col[:array] ? "be_all(String)" : "be_a(String)"
43
+ end
44
+ unless test_args.include?(col[:column_name])
45
+ new_line.write(" \"#{col[:column_name]}\" => #{text},\n")
46
+ end
47
+ end
48
+ test_res = false
49
+ end
50
+ end
51
+ end
52
+ end
53
+ FileUtils.rm(file_path)
54
+ FileUtils.mv(new_file_path, file_path)
55
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
56
+ end
57
+
58
+ def check_rspec_resolver_argument(class_name: "user", action: "node_args")
59
+ singularized_class_name = class_name.singularize.underscore
60
+ dir_name = "./spec/resolvers"
61
+ file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
62
+ node_res = false
63
+ test_res = false
64
+ args = []
65
+ File.open(file_path) do |f|
66
+ f.each_line do |line|
67
+ node_res = true if line.include?("node {")
68
+ test_res = true if line.include?("include(")
69
+ node_res = false if node_res && line.include?("}")
70
+ test_res = false if test_res && line.strip == ")"
71
+ if action == "node_args"
72
+ args << line.strip.underscore if node_res && !line.include?("{")
73
+ elsif action == "test_args"
74
+ args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
75
+ elsif line.include?('#{')
76
+ args << line.split(":")[0].strip.underscore
77
+ end
78
+ end
79
+ end
80
+ args
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,50 @@
1
+ module Souls
2
+ module Api
3
+ module Update
4
+ class << self
5
+ def type(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./app/graphql/types"
9
+ new_file_path = "tmp/create_type.rb"
10
+ file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
11
+ argument = false
12
+ File.open(file_path) do |f|
13
+ File.open(new_file_path, "w") do |new_line|
14
+ f.each_line do |line|
15
+ new_line.write(line)
16
+ next unless line.include?("field") && !argument
17
+
18
+ new_cols.each do |col|
19
+ type = Souls::Api::Generate.type_check(col[:type])
20
+ type = "[#{type}]" if col[:array]
21
+ args = check_type_argument(class_name: class_name)
22
+ unless args.include?(col[:column_name])
23
+ new_line.write(" field :#{col[:column_name]}, #{type}, null: true\n")
24
+ end
25
+ end
26
+ argument = true
27
+ end
28
+ end
29
+ end
30
+ FileUtils.rm(file_path)
31
+ FileUtils.mv(new_file_path, file_path)
32
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
33
+ end
34
+
35
+ def check_type_argument(class_name: "user")
36
+ singularized_class_name = class_name.singularize.underscore
37
+ dir_name = "./app/graphql/types"
38
+ file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
39
+ args = []
40
+ File.open(file_path) do |f|
41
+ f.each_line do |line|
42
+ args << line.split(",")[0].gsub("field :", "").strip if line.include?(" field :")
43
+ end
44
+ end
45
+ args
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.29.7".freeze
2
+ VERSION = "0.30.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.8.7
1
+ 0.9.0
@@ -1 +1 @@
1
- 0.8.7
1
+ 0.9.0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.7
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
8
8
  - KishiTheMechanic
9
9
  - James Neve
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
13
  date: 2021-08-17 00:00:00.000000000 Z
@@ -121,7 +121,12 @@ files:
121
121
  - lib/souls/api/generate/rspec_resolver.rb
122
122
  - lib/souls/api/generate/type.rb
123
123
  - lib/souls/api/update.rb
124
- - lib/souls/api/update/update_mutation.rb
124
+ - lib/souls/api/update/mutation.rb
125
+ - lib/souls/api/update/resolver.rb
126
+ - lib/souls/api/update/rspec_factory.rb
127
+ - lib/souls/api/update/rspec_mutation.rb
128
+ - lib/souls/api/update/rspec_resolver.rb
129
+ - lib/souls/api/update/type.rb
125
130
  - lib/souls/docker.rb
126
131
  - lib/souls/docker/docker.rb
127
132
  - lib/souls/gcloud.rb
@@ -147,7 +152,7 @@ metadata:
147
152
  homepage_uri: https://souls.elsoul.nl
148
153
  source_code_uri: https://github.com/elsoul/souls
149
154
  changelog_uri: https://github.com/elsoul/souls
150
- post_install_message:
155
+ post_install_message:
151
156
  rdoc_options: []
152
157
  require_paths:
153
158
  - lib
@@ -163,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
168
  version: '0'
164
169
  requirements: []
165
170
  rubygems_version: 3.2.22
166
- signing_key:
171
+ signing_key:
167
172
  specification_version: 4
168
173
  summary: SOULs is a Serverless Application Framework with Ruby GraphQL. SOULs has
169
174
  3 strains, API, Worker, and Frontend. It can be used in combination according to
@@ -1,11 +0,0 @@
1
- module Souls
2
- module Api
3
- module Update
4
- class << self
5
- def update_create_mutation_head
6
- p(Souls.get_add_migration_type)
7
- end
8
- end
9
- end
10
- end
11
- end