souls 0.51.2 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/souls +4 -202
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +97 -93
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -5
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- data/lib/souls/worker/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,7 +1,7 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
def
|
2
|
+
class Generate < Thor
|
3
|
+
desc "policy [CLASS_NAME]", "Generate Policy File Template"
|
4
|
+
def policy(class_name)
|
5
5
|
dir_name = "./app/policies"
|
6
6
|
FileUtils.mkdir_p(dir_name) unless Dir.exist?(dir_name)
|
7
7
|
file_path = "#{dir_name}/#{class_name.singularize}_policy.rb"
|
@@ -44,8 +44,8 @@ module Souls
|
|
44
44
|
end
|
45
45
|
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
46
46
|
file_path
|
47
|
-
rescue
|
48
|
-
raise(
|
47
|
+
rescue Thor::Error => e
|
48
|
+
raise(Thor::Error, e)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,65 +1,65 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class Generate < Thor
|
3
|
+
desc "query [CLASS_NAME]", "Generate GraphQL Query from schema.rb"
|
4
|
+
def query(class_name)
|
5
|
+
file_dir = "./app/graphql/queries/"
|
6
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
7
|
+
singularized_class_name = class_name.singularize
|
8
|
+
create_query(class_name: singularized_class_name)
|
9
|
+
create_queries(class_name: singularized_class_name)
|
10
|
+
rescue Thor::Error => e
|
11
|
+
raise(Thor::Error, e)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_queries(class_name: "user")
|
17
|
+
file_path = "./app/graphql/queries/#{class_name.pluralize}.rb"
|
18
|
+
return "Query already exist! #{file_path}" if File.exist?(file_path)
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
20
|
+
File.open(file_path, "w") do |f|
|
21
|
+
f.write(<<~TEXT)
|
22
|
+
module Queries
|
23
|
+
class #{class_name.camelize.pluralize} < Queries::BaseQuery
|
24
|
+
type [Types::#{class_name.camelize}Type], null: false
|
14
25
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
26
|
+
def resolve
|
27
|
+
::#{class_name.camelize}.all
|
28
|
+
rescue StandardError => error
|
29
|
+
GraphQL::ExecutionError.new error
|
20
30
|
end
|
21
31
|
end
|
22
|
-
|
23
|
-
|
24
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
25
|
-
file_path
|
26
|
-
rescue StandardError => e
|
27
|
-
raise(StandardError, e)
|
32
|
+
end
|
33
|
+
TEXT
|
28
34
|
end
|
35
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
36
|
+
file_path
|
37
|
+
rescue StandardError => e
|
38
|
+
raise(StandardError, e)
|
39
|
+
end
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
def create_query(class_name: "user")
|
42
|
+
file_path = "./app/graphql/queries/#{class_name}.rb"
|
43
|
+
return "Query already exist! #{file_path}" if File.exist?(file_path)
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
45
|
+
File.open(file_path, "w") do |f|
|
46
|
+
f.write(<<~TEXT)
|
47
|
+
module Queries
|
48
|
+
class #{class_name.camelize} < Queries::BaseQuery
|
49
|
+
type Types::#{class_name.camelize}Type, null: false
|
50
|
+
argument :id, String, required: true
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
52
|
+
def resolve **args
|
53
|
+
_, data_id = SoulsApiSchema.from_global_id args[:id]
|
54
|
+
::#{class_name.camelize}.find(data_id)
|
55
|
+
rescue StandardError => error
|
56
|
+
GraphQL::ExecutionError.new error
|
47
57
|
end
|
48
58
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
raise(StandardError, e)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def query(class_name: "user")
|
58
|
-
file_dir = "./app/graphql/queries/"
|
59
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
60
|
-
singularized_class_name = class_name.singularize
|
61
|
-
create_query(class_name: singularized_class_name)
|
62
|
-
create_queries(class_name: singularized_class_name)
|
59
|
+
end
|
60
|
+
TEXT
|
61
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
62
|
+
file_path
|
63
63
|
rescue StandardError => e
|
64
64
|
raise(StandardError, e)
|
65
65
|
end
|
@@ -1,63 +1,80 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@relation_params = []
|
9
|
-
File.open(file_path, "w") do |f|
|
10
|
-
f.write(<<~TEXT)
|
11
|
-
module Resolvers
|
12
|
-
class #{class_name.camelize}Search < Base
|
13
|
-
include SearchObject.module(:graphql)
|
14
|
-
scope { ::#{class_name.camelize}.all }
|
15
|
-
type Types::#{class_name.camelize}Type.connection_type, null: false
|
16
|
-
description "Search #{class_name.camelize}"
|
2
|
+
class Generate < Thor
|
3
|
+
desc "resolver [CLASS_NAME]", "Generate GraphQL Resolver from schema.rb"
|
4
|
+
def resolver(class_name)
|
5
|
+
singularized_class_name = class_name.singularize.underscore
|
6
|
+
file_path = "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
7
|
+
raise(StandardError, "Resolver already exist! #{file_path}") if File.exist?(file_path)
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
resolver_head(class_name: singularized_class_name)
|
10
|
+
resolver_params(class_name: singularized_class_name)
|
11
|
+
resolver_after_params(class_name: singularized_class_name)
|
12
|
+
resolver_before_end(class_name: singularized_class_name)
|
13
|
+
resolver_end(class_name: singularized_class_name)
|
14
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
15
|
+
file_path
|
16
|
+
rescue Thor::Error => e
|
17
|
+
raise(Thor::Error, e)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def resolver_head(class_name: "user")
|
23
|
+
FileUtils.mkdir_p("./app/graphql/resolvers") unless Dir.exist?("./app/graphql/resolvers")
|
24
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
25
|
+
@relation_params = []
|
26
|
+
File.open(file_path, "w") do |f|
|
27
|
+
f.write(<<~TEXT)
|
28
|
+
module Resolvers
|
29
|
+
class #{class_name.camelize}Search < Base
|
30
|
+
include SearchObject.module(:graphql)
|
31
|
+
scope { ::#{class_name.camelize}.all }
|
32
|
+
type Types::#{class_name.camelize}Type.connection_type, null: false
|
33
|
+
description "Search #{class_name.camelize}"
|
34
|
+
|
35
|
+
class #{class_name.camelize}Filter < ::Types::BaseInputObject
|
36
|
+
argument :OR, [self], required: false
|
37
|
+
TEXT
|
22
38
|
end
|
39
|
+
end
|
23
40
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
41
|
+
def resolver_params(class_name: "user")
|
42
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
43
|
+
path = "./db/schema.rb"
|
44
|
+
@on = false
|
45
|
+
@user_exist = false
|
46
|
+
@relation_params = []
|
47
|
+
File.open(file_path, "a") do |new_line|
|
48
|
+
File.open(path, "r") do |f|
|
49
|
+
f.each_line.with_index do |line, _i|
|
50
|
+
if @on
|
51
|
+
break if line.include?("t.index") || line.strip == "end"
|
35
52
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
53
|
+
field = "[String]" if line.include?("array: true")
|
54
|
+
type, name = Souls.get_type_and_name(line)
|
55
|
+
field ||= Souls.type_check(type)
|
56
|
+
case name
|
57
|
+
when "user_id"
|
58
|
+
@user_exist = true
|
59
|
+
when /$*_id\z/
|
60
|
+
@relation_params << name
|
61
|
+
new_line.write(" argument :#{name}, String, required: false\n")
|
62
|
+
when "created_at", "updated_at"
|
63
|
+
next
|
64
|
+
else
|
65
|
+
new_line.write(" argument :#{name}, #{field}, required: false\n")
|
50
66
|
end
|
51
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
52
67
|
end
|
68
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
53
69
|
end
|
54
70
|
end
|
55
71
|
end
|
72
|
+
end
|
56
73
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
74
|
+
def resolver_after_params(class_name: "user")
|
75
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
76
|
+
File.open(file_path, "a") do |f|
|
77
|
+
f.write(<<-TEXT)
|
61
78
|
argument :start_date, String, required: false
|
62
79
|
argument :end_date, String, required: false
|
63
80
|
end
|
@@ -73,86 +90,69 @@ module Souls
|
|
73
90
|
|
74
91
|
def normalize_filters(value, branches = [])
|
75
92
|
scope = ::#{class_name.camelize}.all
|
76
|
-
|
77
|
-
end
|
93
|
+
TEXT
|
78
94
|
end
|
95
|
+
end
|
79
96
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
97
|
+
def resolver_before_end(class_name: "user")
|
98
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
99
|
+
path = "./db/schema.rb"
|
100
|
+
@on = false
|
101
|
+
@user_exist = false
|
102
|
+
@relation_params = []
|
103
|
+
File.open(file_path, "a") do |new_line|
|
104
|
+
File.open(path, "r") do |f|
|
105
|
+
f.each_line.with_index do |line, _i|
|
106
|
+
if @on
|
107
|
+
break if line.include?("t.index") || line.strip == "end"
|
91
108
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
+
type, name = Souls.get_type_and_name(line)
|
110
|
+
if line.include?("array: true")
|
111
|
+
new_line.write(
|
112
|
+
" scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
|
113
|
+
)
|
114
|
+
next
|
115
|
+
end
|
116
|
+
case name
|
117
|
+
when "user_id"
|
118
|
+
@user_exist = true
|
119
|
+
when /$*_id\z/
|
120
|
+
@relation_params << name
|
121
|
+
new_line.write(
|
122
|
+
" scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n"
|
123
|
+
)
|
124
|
+
when "created_at", "updated_at"
|
125
|
+
next
|
126
|
+
else
|
127
|
+
case type
|
128
|
+
when "boolean"
|
129
|
+
new_line.write(" scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n")
|
109
130
|
else
|
110
|
-
|
111
|
-
when "boolean"
|
112
|
-
new_line.write(" scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n")
|
113
|
-
else
|
114
|
-
new_line.write(" scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n")
|
115
|
-
end
|
131
|
+
new_line.write(" scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n")
|
116
132
|
end
|
117
133
|
end
|
118
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
119
134
|
end
|
135
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
120
136
|
end
|
121
137
|
end
|
122
138
|
end
|
139
|
+
end
|
123
140
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
141
|
+
def resolver_end(class_name: "user")
|
142
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
143
|
+
File.open(file_path, "a") do |f|
|
144
|
+
f.write(<<~TEXT)
|
145
|
+
scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
|
146
|
+
scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
|
147
|
+
branches << scope
|
148
|
+
value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
|
149
|
+
branches
|
134
150
|
end
|
135
151
|
end
|
136
|
-
|
137
|
-
|
138
|
-
file_path
|
139
|
-
end
|
140
|
-
|
141
|
-
def resolver(class_name: "user")
|
142
|
-
singularized_class_name = class_name.singularize.underscore
|
143
|
-
file_path = "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
144
|
-
raise(StandardError, "Resolver already exist! #{file_path}") if File.exist?(file_path)
|
145
|
-
|
146
|
-
resolver_head(class_name: singularized_class_name)
|
147
|
-
resolver_params(class_name: singularized_class_name)
|
148
|
-
resolver_after_params(class_name: singularized_class_name)
|
149
|
-
resolver_before_end(class_name: singularized_class_name)
|
150
|
-
resolver_end(class_name: singularized_class_name)
|
151
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
152
|
-
file_path
|
153
|
-
rescue StandardError => e
|
154
|
-
raise(StandardError, e)
|
152
|
+
end
|
153
|
+
TEXT
|
155
154
|
end
|
155
|
+
file_path
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -1,67 +1,67 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_factory [CLASS_NAME]", "Generate Rspec Factory Test from schema.rb"
|
4
|
+
def rspec_factory(class_name)
|
5
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
6
|
+
return "RspecFactory already exist! #{file_path}" if File.exist?(file_path)
|
7
|
+
|
8
|
+
singularized_class_name = class_name.singularize
|
9
|
+
rspec_factory_head(class_name: singularized_class_name)
|
10
|
+
rspec_factory_params(class_name: singularized_class_name)
|
11
|
+
rspec_factory_end(class_name: singularized_class_name)
|
12
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
13
|
+
file_path
|
14
|
+
rescue Thor::Error => e
|
15
|
+
raise(Thor::Error, e)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def rspec_factory_head(class_name: "user")
|
21
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
22
|
+
FileUtils.mkdir_p("./spec/factories/") unless Dir.exist?("./spec/factories/")
|
23
|
+
File.open(file_path, "w") do |f|
|
24
|
+
f.write(<<~TEXT)
|
25
|
+
FactoryBot.define do
|
26
|
+
factory :#{class_name} do
|
27
|
+
TEXT
|
14
28
|
end
|
29
|
+
end
|
15
30
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
31
|
+
def rspec_factory_params(class_name: "user")
|
32
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
33
|
+
path = "./db/schema.rb"
|
34
|
+
@on = false
|
35
|
+
File.open(file_path, "a") do |new_line|
|
36
|
+
File.open(path, "r") do |f|
|
37
|
+
f.each_line.with_index do |line, _i|
|
38
|
+
if @on
|
39
|
+
new_line.write("\n" && break) if line.include?("t.index") || line.strip == "end"
|
40
|
+
field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
|
41
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
42
|
+
field ||= Souls.get_test_type(type)
|
43
|
+
if type == "bigint" && name.include?("_id")
|
44
|
+
id_name = name.gsub("_id", "")
|
45
|
+
new_line.write(" association :#{id_name}, factory: :#{id_name}\n")
|
46
|
+
else
|
47
|
+
new_line.write(" #{name} { #{field} }\n")
|
34
48
|
end
|
35
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
36
49
|
end
|
50
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
37
51
|
end
|
38
52
|
end
|
39
53
|
end
|
54
|
+
end
|
40
55
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
56
|
+
def rspec_factory_end(class_name: "user")
|
57
|
+
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
58
|
+
File.open(file_path, "a") do |f|
|
59
|
+
f.write(<<~TEXT)
|
46
60
|
end
|
47
|
-
|
48
|
-
|
49
|
-
file_path
|
50
|
-
end
|
51
|
-
|
52
|
-
def rspec_factory(class_name: "user")
|
53
|
-
file_path = "./spec/factories/#{class_name.pluralize}.rb"
|
54
|
-
return "RspecFactory already exist! #{file_path}" if File.exist?(file_path)
|
55
|
-
|
56
|
-
singularized_class_name = class_name.singularize
|
57
|
-
rspec_factory_head(class_name: singularized_class_name)
|
58
|
-
rspec_factory_params(class_name: singularized_class_name)
|
59
|
-
rspec_factory_end(class_name: singularized_class_name)
|
60
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
61
|
-
file_path
|
62
|
-
rescue StandardError => e
|
63
|
-
raise(StandardError, e)
|
61
|
+
end
|
62
|
+
TEXT
|
64
63
|
end
|
64
|
+
file_path
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|