souls 0.50.0 → 0.52.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/exe/souls +4 -202
  4. data/lib/souls/api/generate/application.rb +97 -94
  5. data/lib/souls/api/generate/connection.rb +5 -4
  6. data/lib/souls/api/generate/edge.rb +5 -4
  7. data/lib/souls/api/generate/index.rb +0 -1
  8. data/lib/souls/api/generate/manager.rb +9 -7
  9. data/lib/souls/api/generate/model.rb +16 -18
  10. data/lib/souls/api/generate/mutation.rb +217 -218
  11. data/lib/souls/api/generate/policy.rb +5 -5
  12. data/lib/souls/api/generate/query.rb +51 -51
  13. data/lib/souls/api/generate/resolver.rb +115 -115
  14. data/lib/souls/api/generate/rspec_factory.rb +53 -53
  15. data/lib/souls/api/generate/rspec_model.rb +5 -5
  16. data/lib/souls/api/generate/rspec_mutation.rb +178 -178
  17. data/lib/souls/api/generate/rspec_policy.rb +5 -5
  18. data/lib/souls/api/generate/rspec_query.rb +111 -111
  19. data/lib/souls/api/generate/rspec_resolver.rb +163 -163
  20. data/lib/souls/api/generate/type.rb +66 -66
  21. data/lib/souls/api/index.rb +7 -4
  22. data/lib/souls/api/update/index.rb +15 -0
  23. data/lib/souls/api/update/mutation.rb +68 -64
  24. data/lib/souls/api/update/resolver.rb +59 -60
  25. data/lib/souls/api/update/rspec_factory.rb +40 -39
  26. data/lib/souls/api/update/rspec_mutation.rb +84 -83
  27. data/lib/souls/api/update/rspec_resolver.rb +70 -69
  28. data/lib/souls/api/update/type.rb +39 -38
  29. data/lib/souls/cli/console/index.rb +13 -1
  30. data/lib/souls/cli/create/index.rb +100 -95
  31. data/lib/souls/cli/db/index.rb +122 -1
  32. data/lib/souls/cli/docker/index.rb +30 -38
  33. data/lib/souls/cli/gcloud/compute/index.rb +100 -93
  34. data/lib/souls/cli/gcloud/iam/index.rb +84 -69
  35. data/lib/souls/cli/gcloud/index.rb +36 -35
  36. data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
  37. data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
  38. data/lib/souls/cli/gcloud/run/index.rb +23 -17
  39. data/lib/souls/cli/gcloud/sql/index.rb +66 -45
  40. data/lib/souls/cli/index.rb +3 -20
  41. data/lib/souls/cli/init/index.rb +140 -138
  42. data/lib/souls/cli/release/release.rb +106 -105
  43. data/lib/souls/cli/server/index.rb +12 -1
  44. data/lib/souls/cli/sync/conf.rb +39 -38
  45. data/lib/souls/cli/sync/model.rb +19 -20
  46. data/lib/souls/cli/sync/pubsub.rb +69 -70
  47. data/lib/souls/cli/upgrade/gemfile.rb +108 -0
  48. data/lib/souls/cli/upgrade/index.rb +1 -1
  49. data/lib/souls/cli.rb +57 -0
  50. data/lib/souls/index.rb +1 -5
  51. data/lib/souls/version.rb +1 -1
  52. data/lib/souls/versions/.souls_api_version +1 -1
  53. data/lib/souls/versions/.souls_worker_version +1 -1
  54. data/lib/souls/worker/generate/index.rb +1 -1
  55. data/lib/souls/worker/generate/job.rb +45 -0
  56. data/lib/souls/worker/generate/mailer.rb +38 -43
  57. data/lib/souls/worker/index.rb +3 -1
  58. data/lib/souls.rb +2 -0
  59. metadata +19 -5
  60. data/lib/souls/api/generate/migration.rb +0 -51
  61. data/lib/souls/cli/upgrade/gem_update.rb +0 -107
  62. data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,52 +1,53 @@
1
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
2
+ class Update < Thor
3
+ desc "rspec_factory [CLASS_NAME]", "Update GraphQL Type from schema.rb"
4
+ def rspec_factory(class_name)
5
+ singularized_class_name = class_name.singularize.underscore
6
+ pluralized_class_name = class_name.pluralize.underscore
7
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
8
+ dir_name = "./spec/factories"
9
+ new_file_path = "tmp/create_factory.rb"
10
+ file_path = "#{dir_name}/#{pluralized_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
18
17
 
19
- new_cols.each do |col|
20
- next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
18
+ new_cols.each do |col|
19
+ next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
21
20
 
22
- type = Souls.get_test_type(col[:type])
23
- type = "[#{type}]" if col[:array]
24
- args = check_factory_argument(class_name: class_name)
21
+ type = Souls.get_test_type(col[:type])
22
+ type = "[#{type}]" if col[:array]
23
+ args = check_factory_argument(class_name: class_name)
25
24
 
26
- new_line.write(" #{col[:column_name]} { #{type} }\n") unless args.include?(col[:column_name])
27
- end
28
- argument = true
29
- end
25
+ new_line.write(" #{col[:column_name]} { #{type} }\n") unless args.include?(col[:column_name])
30
26
  end
27
+ argument = true
31
28
  end
32
- FileUtils.rm(file_path)
33
- FileUtils.mv(new_file_path, file_path)
34
- puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
35
29
  end
30
+ end
31
+ FileUtils.rm(file_path)
32
+ FileUtils.mv(new_file_path, file_path)
33
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
34
+ rescue Thor::Error => e
35
+ raise(Thor::Error, e)
36
+ end
36
37
 
37
- def check_factory_argument(class_name: "user")
38
- pluralized_class_name = class_name.pluralize.underscore
39
- dir_name = "./spec/factories"
40
- file_path = "#{dir_name}/#{pluralized_class_name}.rb"
41
- args = []
42
- File.open(file_path) do |f|
43
- f.each_line do |line|
44
- args << line.split("{")[0].strip.underscore if line.include?("{")
45
- end
46
- end
47
- args
38
+ private
39
+
40
+ def check_factory_argument(class_name: "user")
41
+ pluralized_class_name = class_name.pluralize.underscore
42
+ dir_name = "./spec/factories"
43
+ file_path = "#{dir_name}/#{pluralized_class_name}.rb"
44
+ args = []
45
+ File.open(file_path) do |f|
46
+ f.each_line do |line|
47
+ args << line.split("{")[0].strip.underscore if line.include?("{")
48
48
  end
49
49
  end
50
+ args
50
51
  end
51
52
  end
52
53
  end
@@ -1,100 +1,101 @@
1
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 == ")"
2
+ class Update < Thor
3
+ desc "rspec_mutation [CLASS_NAME]", "Update GraphQL Type from schema.rb"
4
+ def rspec_mutation(class_name)
5
+ singularized_class_name = class_name.singularize.underscore
6
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
7
+ dir_name = "./spec/mutations/base"
8
+ new_file_path = "tmp/rspec_mutation.rb"
9
+ file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
10
+ argument = false
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 == ")"
22
21
 
23
- if line.include?('#{') && !argument
24
- new_cols.each do |col|
25
- type = Souls.type_check(col[:type])
26
- next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
22
+ if line.include?('#{') && !argument
23
+ new_cols.each do |col|
24
+ type = Souls.type_check(col[:type])
25
+ next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
27
26
 
28
- type_line =
29
- if type == "String" && !col[:array]
30
- " #{col[:column_name].camelize(:lower)}: \"\#{#{class_name}[:#{col[:column_name].underscore}]}\"\n"
31
- else
32
- " #{col[:column_name].camelize(:lower)}: \#{#{class_name}[:#{col[:column_name].underscore}]}\n"
33
- end
34
- args = check_rspec_mutation_argument(class_name: class_name)
35
- new_line.write(type_line) unless args.include?(col[:column_name].underscore)
27
+ type_line =
28
+ if type == "String" && !col[:array]
29
+ " #{col[:column_name].camelize(:lower)}: \"\#{#{class_name}[:#{col[:column_name].underscore}]}\"\n"
30
+ else
31
+ " #{col[:column_name].camelize(:lower)}: \#{#{class_name}[:#{col[:column_name].underscore}]}\n"
36
32
  end
37
- argument = true
38
- elsif node_res && !line.include?("{")
39
- node_args = check_rspec_mutation_argument(class_name: class_name, action: "node_args")
40
- new_cols.each do |col|
41
- unless node_args.include?(col[:column_name])
42
- new_line.write(" #{col[:column_name].camelize(:lower)}\n")
43
- end
44
- end
45
- node_res = false
46
- elsif test_res && line.include?("=> be_")
47
- test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
48
- new_cols.each do |col|
49
- type = Souls.type_check(col[:type])
50
- text =
51
- case type
52
- when "Integer", "Float"
53
- col[:array] ? "be_all(Integer)" : "be_a(Integer)"
54
- when "Boolean"
55
- col[:array] ? "be_all([true, false])" : "be_in([true, false])"
56
- else
57
- col[:array] ? "be_all(String)" : "be_a(String)"
58
- end
59
- unless test_args.include?(col[:column_name])
60
- new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
61
- end
33
+ args = check_rspec_mutation_argument(class_name: class_name)
34
+ new_line.write(type_line) unless args.include?(col[:column_name].underscore)
35
+ end
36
+ argument = true
37
+ elsif node_res && !line.include?("{")
38
+ node_args = check_rspec_mutation_argument(class_name: class_name, action: "node_args")
39
+ new_cols.each do |col|
40
+ unless node_args.include?(col[:column_name])
41
+ new_line.write(" #{col[:column_name].camelize(:lower)}\n")
42
+ end
43
+ end
44
+ node_res = false
45
+ elsif test_res && line.include?("=> be_")
46
+ test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
47
+ new_cols.each do |col|
48
+ type = Souls.type_check(col[:type])
49
+ text =
50
+ case type
51
+ when "Integer", "Float"
52
+ col[:array] ? "be_all(Integer)" : "be_a(Integer)"
53
+ when "Boolean"
54
+ col[:array] ? "be_all([true, false])" : "be_in([true, false])"
55
+ else
56
+ col[:array] ? "be_all(String)" : "be_a(String)"
62
57
  end
63
- test_res = false
58
+ unless test_args.include?(col[:column_name])
59
+ new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
64
60
  end
65
61
  end
62
+ test_res = false
66
63
  end
67
64
  end
68
- FileUtils.rm(file_path)
69
- FileUtils.mv(new_file_path, file_path)
70
- puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
71
65
  end
66
+ end
67
+ FileUtils.rm(file_path)
68
+ FileUtils.mv(new_file_path, file_path)
69
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
70
+ rescue Thor::Error => e
71
+ raise(Thor::Error, e)
72
+ end
72
73
 
73
- def check_rspec_mutation_argument(class_name: "user", action: "argument")
74
- singularized_class_name = class_name.singularize.underscore
75
- dir_name = "./spec/mutations/base"
76
- file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
77
- node_res = false
78
- test_res = false
79
- args = []
80
- File.open(file_path) do |f|
81
- f.each_line do |line|
82
- node_res = true if line.include?("node {")
83
- test_res = true if line.include?("include(")
84
- node_res = false if node_res && line.include?("}")
85
- test_res = false if test_res && line.strip == ")"
86
- if action == "node_args"
87
- args << line.strip.underscore if node_res && !line.include?("{")
88
- elsif action == "test_args"
89
- args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
90
- elsif line.include?('#{')
91
- args << line.split(":")[0].strip.underscore
92
- end
93
- end
74
+ private
75
+
76
+ def check_rspec_mutation_argument(class_name: "user", action: "argument")
77
+ singularized_class_name = class_name.singularize.underscore
78
+ dir_name = "./spec/mutations/base"
79
+ file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
80
+ node_res = false
81
+ test_res = false
82
+ args = []
83
+ File.open(file_path) do |f|
84
+ f.each_line do |line|
85
+ node_res = true if line.include?("node {")
86
+ test_res = true if line.include?("include(")
87
+ node_res = false if node_res && line.include?("}")
88
+ test_res = false if test_res && line.strip == ")"
89
+ if action == "node_args"
90
+ args << line.strip.underscore if node_res && !line.include?("{")
91
+ elsif action == "test_args"
92
+ args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
93
+ elsif line.include?('#{')
94
+ args << line.split(":")[0].strip.underscore
94
95
  end
95
- args
96
96
  end
97
97
  end
98
+ args
98
99
  end
99
100
  end
100
101
  end
@@ -1,84 +1,85 @@
1
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 == ")"
2
+ class Update < Thor
3
+ desc "rspec_resolver [CLASS_NAME]", "Update GraphQL Type from schema.rb"
4
+ def rspec_resolver(class_name)
5
+ singularized_class_name = class_name.singularize.underscore
6
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
7
+ dir_name = "./spec/resolvers"
8
+ new_file_path = "tmp/rspec_resolver.rb"
9
+ file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
10
+ node_res = false
11
+ test_res = 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
+ node_res = true if line.include?("node {")
17
+ test_res = true if line.include?("include(")
18
+ node_res = false if node_res && line.include?("}")
19
+ test_res = false if test_res && line.strip == ")"
21
20
 
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
- unless node_args.include?(col[:column_name])
26
- new_line.write(" #{col[:column_name].camelize(:lower)}\n")
27
- end
28
- end
29
- node_res = false
30
- elsif test_res && line.include?("=> be_")
31
- test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
32
- new_cols.each do |col|
33
- type = Souls.type_check(col[:type])
34
- text =
35
- case type
36
- when "Integer", "Float"
37
- col[:array] ? "be_all(Integer)" : "be_a(Integer)"
38
- when "Boolean"
39
- col[:array] ? "be_all([true, false])" : "be_in([true, false])"
40
- else
41
- col[:array] ? "be_all(String)" : "be_a(String)"
42
- end
43
- unless test_args.include?(col[:column_name])
44
- new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
45
- end
21
+ if node_res && !line.include?("{")
22
+ node_args = check_rspec_resolver_argument(class_name: class_name, action: "node_args")
23
+ new_cols.each do |col|
24
+ unless node_args.include?(col[:column_name])
25
+ new_line.write(" #{col[:column_name].camelize(:lower)}\n")
26
+ end
27
+ end
28
+ node_res = false
29
+ elsif test_res && line.include?("=> be_")
30
+ test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
31
+ new_cols.each do |col|
32
+ type = Souls.type_check(col[:type])
33
+ text =
34
+ case type
35
+ when "Integer", "Float"
36
+ col[:array] ? "be_all(Integer)" : "be_a(Integer)"
37
+ when "Boolean"
38
+ col[:array] ? "be_all([true, false])" : "be_in([true, false])"
39
+ else
40
+ col[:array] ? "be_all(String)" : "be_a(String)"
46
41
  end
47
- test_res = false
42
+ unless test_args.include?(col[:column_name])
43
+ new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
48
44
  end
49
45
  end
46
+ test_res = false
50
47
  end
51
48
  end
52
- FileUtils.rm(file_path)
53
- FileUtils.mv(new_file_path, file_path)
54
- puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
55
49
  end
50
+ end
51
+ FileUtils.rm(file_path)
52
+ FileUtils.mv(new_file_path, file_path)
53
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
54
+ rescue Thor::Error => e
55
+ raise(Thor::Error, e)
56
+ end
56
57
 
57
- def check_rspec_resolver_argument(class_name: "user", action: "node_args")
58
- singularized_class_name = class_name.singularize.underscore
59
- dir_name = "./spec/resolvers"
60
- file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
61
- node_res = false
62
- test_res = false
63
- args = []
64
- File.open(file_path) do |f|
65
- f.each_line do |line|
66
- node_res = true if line.include?("node {")
67
- test_res = true if line.include?("include(")
68
- node_res = false if node_res && line.include?("}")
69
- test_res = false if test_res && line.strip == ")"
70
- if action == "node_args"
71
- args << line.strip.underscore if node_res && !line.include?("{")
72
- elsif action == "test_args"
73
- args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
74
- elsif line.include?('#{')
75
- args << line.split(":")[0].strip.underscore
76
- end
77
- end
58
+ private
59
+
60
+ def check_rspec_resolver_argument(class_name: "user", action: "node_args")
61
+ singularized_class_name = class_name.singularize.underscore
62
+ dir_name = "./spec/resolvers"
63
+ file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
64
+ node_res = false
65
+ test_res = false
66
+ args = []
67
+ File.open(file_path) do |f|
68
+ f.each_line do |line|
69
+ node_res = true if line.include?("node {")
70
+ test_res = true if line.include?("include(")
71
+ node_res = false if node_res && line.include?("}")
72
+ test_res = false if test_res && line.strip == ")"
73
+ if action == "node_args"
74
+ args << line.strip.underscore if node_res && !line.include?("{")
75
+ elsif action == "test_args"
76
+ args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
77
+ elsif line.include?('#{')
78
+ args << line.split(":")[0].strip.underscore
78
79
  end
79
- args
80
80
  end
81
81
  end
82
+ args
82
83
  end
83
84
  end
84
85
  end
@@ -1,50 +1,51 @@
1
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
2
+ class Update < Thor
3
+ desc "type [CLASS_NAME]", "Update GraphQL Type from schema.rb"
4
+ def type(class_name)
5
+ singularized_class_name = class_name.singularize.underscore
6
+ new_cols = Souls.get_columns_num(class_name: singularized_class_name)
7
+ dir_name = "./app/graphql/types"
8
+ new_file_path = "tmp/create_type.rb"
9
+ file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
10
+ argument = false
11
+ File.open(file_path) do |f|
12
+ File.open(new_file_path, "w") do |new_line|
13
+ f.each_line do |line|
14
+ new_line.write(line)
15
+ next unless line.include?("field") && !argument
17
16
 
18
- new_cols.each do |col|
19
- type = Souls.get_type(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
17
+ new_cols.each do |col|
18
+ type = Souls.get_type(col[:type])
19
+ type = "[#{type}]" if col[:array]
20
+ args = check_type_argument(class_name: class_name)
21
+ unless args.include?(col[:column_name])
22
+ new_line.write(" field :#{col[:column_name]}, #{type}, null: true\n")
27
23
  end
28
24
  end
25
+ argument = true
29
26
  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
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
+ rescue Thor::Error => e
33
+ raise(Thor::Error, e)
34
+ end
34
35
 
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
36
+ private
37
+
38
+ def check_type_argument(class_name: "user")
39
+ singularized_class_name = class_name.singularize.underscore
40
+ dir_name = "./app/graphql/types"
41
+ file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
42
+ args = []
43
+ File.open(file_path) do |f|
44
+ f.each_line do |line|
45
+ args << line.split(",")[0].gsub("field :", "").strip if line.include?(" field :")
46
46
  end
47
47
  end
48
+ args
48
49
  end
49
50
  end
50
51
  end