souls 0.28.9 → 0.29.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 +4 -4
- data/exe/souls +21 -4
- data/lib/souls.rb +3 -11
- data/lib/souls/api.rb +5 -0
- data/lib/souls/{generate.rb → api/generate.rb} +2 -2
- data/lib/souls/{generate → api/generate}/application.rb +9 -1
- data/lib/souls/{generate → api/generate}/connection.rb +1 -1
- data/lib/souls/{generate → api/generate}/edge.rb +1 -1
- data/lib/souls/api/generate/methods.rb +64 -0
- data/lib/souls/api/generate/migration.rb +10 -0
- data/lib/souls/api/generate/model.rb +24 -0
- data/lib/souls/{generate → api/generate}/mutation.rb +1 -1
- data/lib/souls/{generate → api/generate}/policy.rb +1 -1
- data/lib/souls/{generate → api/generate}/query.rb +1 -1
- data/lib/souls/{generate → api/generate}/resolver.rb +7 -4
- data/lib/souls/{generate → api/generate}/rspec_factory.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_model.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_mutation.rb +19 -6
- data/lib/souls/{generate → api/generate}/rspec_policy.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_query.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_resolver.rb +1 -1
- data/lib/souls/{generate → api/generate}/type.rb +0 -0
- data/lib/souls/gcloud.rb +1 -0
- data/lib/souls/gcloud/methods.rb +6 -0
- data/lib/souls/gcloud/pubsub.rb +4 -1
- data/lib/souls/gcloud/run.rb +16 -0
- 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.rb +1 -0
- metadata +23 -19
- data/lib/souls/generate/methods.rb +0 -64
- data/lib/souls/generate/model.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1fa29d198c491633c970c526a3910ba8ea5ad1207b2686d492cc8724edee11
|
4
|
+
data.tar.gz: ebb96d69742107f4de37b7a90dd06c7ee77f36e745b436858c5e828e7be3b175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de749abf646d70b05b1c2274788ee301e972a0c3d1596f683202bb7ec88bb5419f189e31bcf36831c50f7eba174a605a7f102a9ca56d1a5737551c431a5066c
|
7
|
+
data.tar.gz: 8fbb1c4d72a55157098c49c3be430e525d68a68818d95bb82959ce821e04bd8d0e4e05549b539aceeafddf6fcdb92d13aef01ac904186714e56cb8de46717dca
|
data/exe/souls
CHANGED
@@ -1,13 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "souls"
|
3
3
|
begin
|
4
|
-
|
4
|
+
souls_command = ARGV[0]
|
5
|
+
require("./config/souls") unless ["new", "i", "-v", "deploy"].include?(souls_command)
|
5
6
|
rescue StandardError
|
6
7
|
puts("Make sure you are at SOULs APP directory!")
|
7
8
|
end
|
8
9
|
begin
|
9
|
-
souls_command = ARGV[0]
|
10
10
|
case souls_command
|
11
|
+
when "api"
|
12
|
+
api_command = ARGV[1]
|
13
|
+
case api_command
|
14
|
+
when "generate", "g"
|
15
|
+
method_name = ARGV[2]
|
16
|
+
class_name = ARGV[3]
|
17
|
+
status = Paint["Running SOULs Generate Commands...", :yellow]
|
18
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
19
|
+
Whirly.status = status
|
20
|
+
Souls::Api::Generate.public_send(method_name, class_name: class_name)
|
21
|
+
Whirly.status = "Done!"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
Paint["Comannd doesn't exist.Check you command again!...", :red]
|
25
|
+
end
|
26
|
+
when "worker"
|
27
|
+
Paint["Coming Soon...", :green]
|
11
28
|
when "new"
|
12
29
|
args = ARGV
|
13
30
|
Souls::Init.return_method(args)
|
@@ -78,12 +95,12 @@ begin
|
|
78
95
|
done = Paint["You're All Set ☻", :yellow]
|
79
96
|
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
80
97
|
Whirly.status = status
|
81
|
-
Souls::Generate.return_method(args)
|
98
|
+
Souls::Api::Generate.return_method(args)
|
82
99
|
Whirly.status = done
|
83
100
|
end
|
84
101
|
when "d", "delete"
|
85
102
|
class_name = ARGV[1]
|
86
|
-
Souls::Generate.delete_all(class_name: class_name)
|
103
|
+
Souls::Api::Generate.delete_all(class_name: class_name)
|
87
104
|
when "db:create"
|
88
105
|
rack_env = ARGV[1]
|
89
106
|
case rack_env
|
data/lib/souls.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative "souls/version"
|
2
2
|
require "active_support/core_ext/string/inflections"
|
3
3
|
require_relative "souls/init"
|
4
|
-
require_relative "souls/
|
4
|
+
require_relative "souls/api"
|
5
5
|
require_relative "souls/gcloud"
|
6
6
|
require_relative "souls/release"
|
7
7
|
require "date"
|
@@ -33,7 +33,7 @@ module Souls
|
|
33
33
|
class << self
|
34
34
|
attr_accessor :configuration
|
35
35
|
|
36
|
-
def
|
36
|
+
def psql
|
37
37
|
system(
|
38
38
|
"docker run --rm -d \
|
39
39
|
-p 5433:5432 \
|
@@ -46,7 +46,7 @@ module Souls
|
|
46
46
|
system("docker ps")
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def mysql
|
50
50
|
system(
|
51
51
|
"docker run --rm -d \
|
52
52
|
-p 3306:3306 \
|
@@ -59,14 +59,6 @@ module Souls
|
|
59
59
|
system("docker ps")
|
60
60
|
end
|
61
61
|
|
62
|
-
def run_awake(url)
|
63
|
-
app = Souls.configuration.app
|
64
|
-
system(
|
65
|
-
"gcloud scheduler jobs create http #{app}-awake
|
66
|
-
--schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
62
|
def gemfile_latest_version
|
71
63
|
file_path = "./Gemfile"
|
72
64
|
updated_gems = []
|
data/lib/souls/api.rb
ADDED
@@ -15,9 +15,9 @@ require_relative "./generate/type"
|
|
15
15
|
require_relative "./generate/edge"
|
16
16
|
require_relative "./generate/connection"
|
17
17
|
require_relative "./generate/application"
|
18
|
-
require_relative "./generate/
|
18
|
+
require_relative "./generate/migration"
|
19
19
|
|
20
20
|
module Souls
|
21
|
-
module Generate
|
21
|
+
module Api::Generate
|
22
22
|
end
|
23
23
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Common Methods
|
4
4
|
def self.generated_paths(class_name: "user")
|
5
5
|
singularized_class_name = class_name.singularize.underscore
|
@@ -116,6 +116,14 @@ module Souls
|
|
116
116
|
raise(StandardError, e)
|
117
117
|
end
|
118
118
|
|
119
|
+
def self.migrate_all
|
120
|
+
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
121
|
+
Souls::Api::Generate.get_tables.each do |table|
|
122
|
+
Souls::Api::Generate.migrate(class_name: table.singularize)
|
123
|
+
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
119
127
|
def self.delete_all(class_name: "souls")
|
120
128
|
singularized_class_name = class_name.singularize.underscore
|
121
129
|
pluralized_class_name = class_name.pluralize.underscore
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api::Generate
|
3
|
+
class << self
|
4
|
+
def return_method(args)
|
5
|
+
graphql_class = args[1]
|
6
|
+
class_name = args[2]
|
7
|
+
case graphql_class
|
8
|
+
when "test_dir"
|
9
|
+
Souls::Api::Generate.test_dir
|
10
|
+
when "model"
|
11
|
+
Souls::Api::Generate.model(class_name: class_name)
|
12
|
+
when "mutation"
|
13
|
+
Souls::Api::Generate.mutation(class_name: class_name)
|
14
|
+
when "query"
|
15
|
+
Souls::Api::Generate.query(class_name: class_name)
|
16
|
+
when "type"
|
17
|
+
Souls::Api::Generate.type(class_name: class_name)
|
18
|
+
when "edge"
|
19
|
+
Souls::Api::Generate.edge(class_name: class_name)
|
20
|
+
when "connection"
|
21
|
+
Souls::Api::Generate.connection(class_name: class_name)
|
22
|
+
when "resolver"
|
23
|
+
Souls::Api::Generate.resolver(class_name: class_name)
|
24
|
+
when "policy"
|
25
|
+
Souls::Api::Generate.policy(class_name: class_name)
|
26
|
+
when "rspec_factory"
|
27
|
+
Souls::Api::Generate.rspec_factory(class_name: class_name)
|
28
|
+
when "rspec_model"
|
29
|
+
Souls::Api::Generate.rspec_model(class_name: class_name)
|
30
|
+
when "rspec_mutation"
|
31
|
+
Souls::Api::Generate.rspec_mutation(class_name: class_name)
|
32
|
+
when "rspec_query"
|
33
|
+
Souls::Api::Generate.rspec_query(class_name: class_name)
|
34
|
+
when "rspec_resolver"
|
35
|
+
Souls::Api::Generate.rspec_resolver(class_name: class_name)
|
36
|
+
when "rspec_policy"
|
37
|
+
Souls::Api::Generate.rspec_policy(class_name: class_name)
|
38
|
+
when "node_type"
|
39
|
+
Souls::Api::Generate.node_type(class_name: class_name)
|
40
|
+
when "job"
|
41
|
+
Souls::Api::Generate.job(class_name: class_name)
|
42
|
+
when "migrate"
|
43
|
+
Souls::Api::Generate.migrate(class_name: class_name)
|
44
|
+
when "migrate_all"
|
45
|
+
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
46
|
+
Souls::Api::Generate.get_tables.each do |table|
|
47
|
+
Souls::Api::Generate.migrate(class_name: table.singularize)
|
48
|
+
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
49
|
+
end
|
50
|
+
when "migration"
|
51
|
+
pluralized_class_name = class_name.underscore.pluralize
|
52
|
+
system("rake db:create_migration NAME=create_#{pluralized_class_name}")
|
53
|
+
when "update"
|
54
|
+
Souls::Api::Generate.update_delete(class_name: class_name)
|
55
|
+
Souls::Api::Generate.migrate(class_name: class_name)
|
56
|
+
when "worker"
|
57
|
+
Souls::Init.download_worker
|
58
|
+
else
|
59
|
+
"SOULs!"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Generate
|
4
|
+
## Generate Model
|
5
|
+
def self.model(class_name: "souls")
|
6
|
+
file_dir = "./app/models/"
|
7
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
8
|
+
file_path = "#{file_dir}#{class_name.singularize}.rb"
|
9
|
+
return "Model already exist! #{file_path}" if File.exist?(file_path)
|
10
|
+
|
11
|
+
File.open(file_path, "w") do |f|
|
12
|
+
f.write(<<~TEXT)
|
13
|
+
class #{class_name.camelize} < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
TEXT
|
16
|
+
end
|
17
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
18
|
+
file_path
|
19
|
+
rescue StandardError => e
|
20
|
+
raise(StandardError, e)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Generate Resolver
|
4
4
|
def self.resolver_head(class_name: "souls")
|
5
5
|
FileUtils.mkdir_p("./app/graphql/resolvers") unless Dir.exist?("./app/graphql/resolvers")
|
@@ -35,7 +35,6 @@ module Souls
|
|
35
35
|
field = "[String]" if line.include?("array: true")
|
36
36
|
type, name = get_type_and_name(line)
|
37
37
|
field ||= type_check(type)
|
38
|
-
puts(line)
|
39
38
|
case name
|
40
39
|
when "user_id"
|
41
40
|
@user_exist = true
|
@@ -91,7 +90,9 @@ module Souls
|
|
91
90
|
|
92
91
|
type, name = get_type_and_name(line)
|
93
92
|
if line.include?("array: true")
|
94
|
-
new_line.write(
|
93
|
+
new_line.write(
|
94
|
+
" scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
|
95
|
+
)
|
95
96
|
next
|
96
97
|
end
|
97
98
|
case name
|
@@ -99,7 +100,9 @@ module Souls
|
|
99
100
|
@user_exist = true
|
100
101
|
when /$*_id\z/
|
101
102
|
@relation_params << name
|
102
|
-
new_line.write(
|
103
|
+
new_line.write(
|
104
|
+
" scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n"
|
105
|
+
)
|
103
106
|
when "created_at", "updated_at"
|
104
107
|
next
|
105
108
|
else
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Generate Rspec Mutation
|
4
4
|
def self.rspec_mutation_head(class_name: "souls")
|
5
5
|
file_dir = "./spec/mutations/base/"
|
@@ -73,7 +73,9 @@ module Souls
|
|
73
73
|
f.each_line.with_index do |line, _i|
|
74
74
|
if @on
|
75
75
|
if line.include?("t.index") || line.strip == "end"
|
76
|
-
new_line.write(
|
76
|
+
new_line.write(
|
77
|
+
" }) {\n #{class_name.singularize.camelize(:lower)}Edge {\n node {\n"
|
78
|
+
)
|
77
79
|
new_line.write(" id\n")
|
78
80
|
break
|
79
81
|
end
|
@@ -85,17 +87,28 @@ module Souls
|
|
85
87
|
when "user_id"
|
86
88
|
@user_exist = true
|
87
89
|
when /$*_id\z/
|
88
|
-
|
90
|
+
camel = name.singularize.camelize(:lower)
|
91
|
+
new_line.write(
|
92
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
93
|
+
)
|
89
94
|
else
|
90
95
|
case type
|
91
96
|
when "string", "text", "date", "datetime"
|
97
|
+
camel = name.singularize.camelize(:lower)
|
98
|
+
camels = name.pluralize.camelize(:lower)
|
92
99
|
if array_true
|
93
|
-
new_line.write(
|
100
|
+
new_line.write(
|
101
|
+
" #{camels}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
|
102
|
+
)
|
94
103
|
else
|
95
|
-
new_line.write(
|
104
|
+
new_line.write(
|
105
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
106
|
+
)
|
96
107
|
end
|
97
108
|
when "bigint", "integer", "float", "boolean"
|
98
|
-
new_line.write(
|
109
|
+
new_line.write(
|
110
|
+
" #{camel}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
111
|
+
)
|
99
112
|
end
|
100
113
|
end
|
101
114
|
end
|
File without changes
|
data/lib/souls/gcloud.rb
CHANGED
data/lib/souls/gcloud/methods.rb
CHANGED
@@ -54,6 +54,12 @@ module Souls
|
|
54
54
|
service_account = Souls.configuration.app
|
55
55
|
project_id = Souls.configuration.project_id
|
56
56
|
Souls::Gcloud.add_permissions(service_account: service_account, project_id: project_id)
|
57
|
+
when "run_list"
|
58
|
+
project_id = Souls.configuration.project_id
|
59
|
+
Souls::Gcloud.run_list(project_id: project_id)
|
60
|
+
when "run_awake"
|
61
|
+
app_name = Souls.configuration.app
|
62
|
+
Souls::Gcloud.run_awake(app_name: app_name)
|
57
63
|
else
|
58
64
|
raise(StandardError, "Wrong Method!")
|
59
65
|
end
|
data/lib/souls/gcloud/pubsub.rb
CHANGED
@@ -22,7 +22,10 @@ module Souls
|
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
|
-
def update_pubsub_subscription(
|
25
|
+
def update_pubsub_subscription(
|
26
|
+
topic_name: "send-user-mail",
|
27
|
+
endpoint: "https:://test.com"
|
28
|
+
)
|
26
29
|
system("gcloud pubsub subscriptions update #{topic_name}-sub --push-endpoint #{endpoint} ")
|
27
30
|
end
|
28
31
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Souls
|
2
|
+
module Gcloud
|
3
|
+
class << self
|
4
|
+
def run_awake(app_name: "souls-app", url: "")
|
5
|
+
system(
|
6
|
+
"gcloud scheduler jobs create http #{app_name}-awake
|
7
|
+
--schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_list(project_id: "souls-app")
|
12
|
+
system("gcloud run services list --project #{project_id}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/lib/souls/worker.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# worker
|
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.
|
4
|
+
version: 0.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-08-
|
13
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -101,34 +101,38 @@ files:
|
|
101
101
|
- README.md
|
102
102
|
- exe/souls
|
103
103
|
- lib/souls.rb
|
104
|
+
- lib/souls/api.rb
|
105
|
+
- lib/souls/api/generate.rb
|
106
|
+
- lib/souls/api/generate/application.rb
|
107
|
+
- lib/souls/api/generate/connection.rb
|
108
|
+
- lib/souls/api/generate/edge.rb
|
109
|
+
- lib/souls/api/generate/methods.rb
|
110
|
+
- lib/souls/api/generate/migration.rb
|
111
|
+
- lib/souls/api/generate/model.rb
|
112
|
+
- lib/souls/api/generate/mutation.rb
|
113
|
+
- lib/souls/api/generate/policy.rb
|
114
|
+
- lib/souls/api/generate/query.rb
|
115
|
+
- lib/souls/api/generate/resolver.rb
|
116
|
+
- lib/souls/api/generate/rspec_factory.rb
|
117
|
+
- lib/souls/api/generate/rspec_model.rb
|
118
|
+
- lib/souls/api/generate/rspec_mutation.rb
|
119
|
+
- lib/souls/api/generate/rspec_policy.rb
|
120
|
+
- lib/souls/api/generate/rspec_query.rb
|
121
|
+
- lib/souls/api/generate/rspec_resolver.rb
|
122
|
+
- lib/souls/api/generate/type.rb
|
104
123
|
- lib/souls/gcloud.rb
|
105
124
|
- lib/souls/gcloud/compute.rb
|
106
125
|
- lib/souls/gcloud/iam.rb
|
107
126
|
- lib/souls/gcloud/methods.rb
|
108
127
|
- lib/souls/gcloud/pubsub.rb
|
109
|
-
- lib/souls/
|
110
|
-
- lib/souls/generate/application.rb
|
111
|
-
- lib/souls/generate/connection.rb
|
112
|
-
- lib/souls/generate/edge.rb
|
113
|
-
- lib/souls/generate/methods.rb
|
114
|
-
- lib/souls/generate/model.rb
|
115
|
-
- lib/souls/generate/mutation.rb
|
116
|
-
- lib/souls/generate/policy.rb
|
117
|
-
- lib/souls/generate/query.rb
|
118
|
-
- lib/souls/generate/resolver.rb
|
119
|
-
- lib/souls/generate/rspec_factory.rb
|
120
|
-
- lib/souls/generate/rspec_model.rb
|
121
|
-
- lib/souls/generate/rspec_mutation.rb
|
122
|
-
- lib/souls/generate/rspec_policy.rb
|
123
|
-
- lib/souls/generate/rspec_query.rb
|
124
|
-
- lib/souls/generate/rspec_resolver.rb
|
125
|
-
- lib/souls/generate/type.rb
|
128
|
+
- lib/souls/gcloud/run.rb
|
126
129
|
- lib/souls/init.rb
|
127
130
|
- lib/souls/release.rb
|
128
131
|
- lib/souls/release/methods.rb
|
129
132
|
- lib/souls/version.rb
|
130
133
|
- lib/souls/versions/.souls_api_version
|
131
134
|
- lib/souls/versions/.souls_worker_version
|
135
|
+
- lib/souls/worker.rb
|
132
136
|
homepage: https://souls.elsoul.nl
|
133
137
|
licenses:
|
134
138
|
- Apache-2.0
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Souls
|
2
|
-
module Generate
|
3
|
-
class << self
|
4
|
-
def return_method(args)
|
5
|
-
graphql_class = args[1]
|
6
|
-
class_name = args[2]
|
7
|
-
case graphql_class
|
8
|
-
when "test_dir"
|
9
|
-
Souls::Generate.test_dir
|
10
|
-
when "model"
|
11
|
-
Souls::Generate.model(class_name: class_name)
|
12
|
-
when "mutation"
|
13
|
-
Souls::Generate.mutation(class_name: class_name)
|
14
|
-
when "query"
|
15
|
-
Souls::Generate.query(class_name: class_name)
|
16
|
-
when "type"
|
17
|
-
Souls::Generate.type(class_name: class_name)
|
18
|
-
when "edge"
|
19
|
-
Souls::Generate.edge(class_name: class_name)
|
20
|
-
when "connection"
|
21
|
-
Souls::Generate.connection(class_name: class_name)
|
22
|
-
when "resolver"
|
23
|
-
Souls::Generate.resolver(class_name: class_name)
|
24
|
-
when "policy"
|
25
|
-
Souls::Generate.policy(class_name: class_name)
|
26
|
-
when "rspec_factory"
|
27
|
-
Souls::Generate.rspec_factory(class_name: class_name)
|
28
|
-
when "rspec_model"
|
29
|
-
Souls::Generate.rspec_model(class_name: class_name)
|
30
|
-
when "rspec_mutation"
|
31
|
-
Souls::Generate.rspec_mutation(class_name: class_name)
|
32
|
-
when "rspec_query"
|
33
|
-
Souls::Generate.rspec_query(class_name: class_name)
|
34
|
-
when "rspec_resolver"
|
35
|
-
Souls::Generate.rspec_resolver(class_name: class_name)
|
36
|
-
when "rspec_policy"
|
37
|
-
Souls::Generate.rspec_policy(class_name: class_name)
|
38
|
-
when "node_type"
|
39
|
-
Souls::Generate.node_type(class_name: class_name)
|
40
|
-
when "job"
|
41
|
-
Souls::Generate.job(class_name: class_name)
|
42
|
-
when "migrate"
|
43
|
-
Souls::Generate.migrate(class_name: class_name)
|
44
|
-
when "migrate_all"
|
45
|
-
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
46
|
-
Souls::Generate.get_tables.each do |table|
|
47
|
-
Souls::Generate.migrate(class_name: table.singularize)
|
48
|
-
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
49
|
-
end
|
50
|
-
when "migration"
|
51
|
-
pluralized_class_name = class_name.underscore.pluralize
|
52
|
-
system("rake db:create_migration NAME=create_#{pluralized_class_name}")
|
53
|
-
when "update"
|
54
|
-
Souls::Generate.update_delete(class_name: class_name)
|
55
|
-
Souls::Generate.migrate(class_name: class_name)
|
56
|
-
when "worker"
|
57
|
-
Souls::Init.download_worker
|
58
|
-
else
|
59
|
-
"SOULs!"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/souls/generate/model.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Souls
|
2
|
-
module Generate
|
3
|
-
## Generate Model
|
4
|
-
def self.model(class_name: "souls")
|
5
|
-
file_dir = "./app/models/"
|
6
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
7
|
-
file_path = "#{file_dir}#{class_name.singularize}.rb"
|
8
|
-
return "Model already exist! #{file_path}" if File.exist?(file_path)
|
9
|
-
|
10
|
-
File.open(file_path, "w") do |f|
|
11
|
-
f.write(<<~TEXT)
|
12
|
-
class #{class_name.camelize} < ActiveRecord::Base
|
13
|
-
end
|
14
|
-
TEXT
|
15
|
-
end
|
16
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
17
|
-
file_path
|
18
|
-
rescue StandardError => e
|
19
|
-
raise(StandardError, e)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|