souls 0.29.1 β†’ 0.29.2

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: 839fce6c4905d3dc922902ad84093c842c952b0ae11e6d179ff9dba0df2d7a54
4
- data.tar.gz: 6647e81c9e7e11b4aed1c97a134393a0c7cca081bb2d122a54a06fb50d60f978
3
+ metadata.gz: 730068b7f3f94de4766fe3868d5b8d16cdcbdf9c1c2ba4b94f047052bfe7ac69
4
+ data.tar.gz: fbd205b97defe15233528f17af4ac35718fb75da3ab7f593110ec9e1d019b306
5
5
  SHA512:
6
- metadata.gz: 42c45890bf4e6af520643e2ca8e53b090c2e1ce8ee3a5ad38849af44c08f8e5897b31926a328f77eb6c1cba5ffae6e16ae548cd7e5ec3c94fae24f9d300d0726
7
- data.tar.gz: 8b0fa856d5e3e8e9ec4f3a6b284fb089aa0cc2edc8bbef8a66e2899038dac6e12e5dd126dd7d968a47547041e344e5e404957d4949a4efc7a05e3efaa10ffaa6
6
+ metadata.gz: 6eb87212d994fc4296aae60c39358f1f323416c9e1ca6d9c837f8eed0f432dfeacf8a39a2be57e38c41d38bb2c83dcd1cd27f1648ef819dd5300daa0b416c885
7
+ data.tar.gz: 25a74b86d4d8877e1fb569015a06b1c8cd82d11754a2d8992eff6964de98e4319a3ec3712806c2061f03b3c3e8998454b8186b8fd9afa5dd0839cef9552c7a64
data/exe/souls CHANGED
@@ -24,7 +24,20 @@ begin
24
24
  puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
25
25
  end
26
26
  when "worker"
27
- puts(Paint["Coming Soon...", :green])
27
+ api_command = ARGV[1]
28
+ case api_command
29
+ when "generate", "g"
30
+ method_name = ARGV[2]
31
+ class_name = ARGV[3]
32
+ status = Paint["Running SOULs Generate Commands...", :yellow]
33
+ Whirly.start(spinner: "clock", interval: 420, stop: "πŸŽ‰") do
34
+ Whirly.status = status
35
+ Souls::Worker::Generate.public_send(method_name, class_name: class_name)
36
+ Whirly.status = "Done!"
37
+ end
38
+ else
39
+ puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
40
+ end
28
41
  when "new"
29
42
  args = ARGV
30
43
  Souls::Init.return_method(args)
data/lib/souls.rb CHANGED
@@ -2,6 +2,7 @@ require_relative "souls/version"
2
2
  require "active_support/core_ext/string/inflections"
3
3
  require_relative "souls/init"
4
4
  require_relative "souls/api"
5
+ require_relative "souls/worker"
5
6
  require_relative "souls/gcloud"
6
7
  require_relative "souls/release"
7
8
  require_relative "souls/docker"
@@ -63,8 +63,8 @@ module Souls
63
63
  roles = [
64
64
  "roles/cloudsql.instanceUser",
65
65
  "roles/containerregistry.ServiceAgent",
66
- "roles/pubsub.serviceAgent",
67
- "roles/firestore.serviceAgent",
66
+ "roles/pubsub.serviceAdmin",
67
+ "roles/firestore.serviceAdmin",
68
68
  "roles/iam.serviceAccountUser",
69
69
  "roles/storage.objectAdmin",
70
70
  "roles/run.admin"
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.29.1".freeze
2
+ VERSION = "0.29.2".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
@@ -1 +1 @@
1
- 0.8.1
1
+ 0.8.2
data/lib/souls/worker.rb CHANGED
@@ -1 +1,6 @@
1
- # worker
1
+ require_relative "./worker/generate"
2
+
3
+ module Souls
4
+ module Worker
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ require_relative "./generate/application"
2
+ require_relative "./generate/mailer"
3
+
4
+ module Souls
5
+ module Worker::Generate
6
+ end
7
+ end
@@ -0,0 +1,150 @@
1
+ module Souls
2
+ module Worker
3
+ module Generate
4
+ ## Common Methods
5
+ def self.generated_paths(class_name: "user")
6
+ singularized_class_name = class_name.singularize.underscore
7
+ pluralized_class_name = class_name.pluralize.underscore
8
+ [
9
+ "./app/models/#{singularized_class_name}.rb",
10
+ "./app/policies/#{singularized_class_name}_policy.rb",
11
+ "./app/graphql/mutations/create_#{singularized_class_name}.rb",
12
+ "./app/graphql/mutations/delete_#{singularized_class_name}.rb",
13
+ "./app/graphql/mutations/destroy_delete_#{singularized_class_name}.rb",
14
+ "./app/graphql/mutations/update_#{singularized_class_name}.rb",
15
+ "./app/graphql/queries/#{singularized_class_name}.rb",
16
+ "./app/graphql/queries/#{pluralized_class_name}.rb",
17
+ "./app/graphql/resolvers/#{singularized_class_name}_search.rb",
18
+ "./app/graphql/types/#{singularized_class_name}_type.rb",
19
+ "./app/graphql/types/edges/#{singularized_class_name}_edge.rb",
20
+ "./app/graphql/types/connections/#{singularized_class_name}_connection.rb",
21
+ "./spec/factories/#{pluralized_class_name}.rb",
22
+ "./spec/mutations/#{singularized_class_name}_spec.rb",
23
+ "./spec/models/#{singularized_class_name}_spec.rb",
24
+ "./spec/queries/#{singularized_class_name}_spec.rb",
25
+ "./spec/policies/#{singularized_class_name}_policy_spec.rb",
26
+ "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
27
+ ]
28
+ end
29
+
30
+ def self.get_type_and_name(line)
31
+ line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
32
+ end
33
+
34
+ def self.get_tables
35
+ path = "./db/schema.rb"
36
+ tables = []
37
+ File.open(path, "r") do |f|
38
+ f.each_line.with_index do |line, _i|
39
+ tables << line.split("\"")[1] if line.include?("create_table")
40
+ end
41
+ end
42
+ tables
43
+ end
44
+
45
+ def self.type_check(type)
46
+ {
47
+ bigint: "Integer",
48
+ string: "String",
49
+ float: "Float",
50
+ text: "String",
51
+ datetime: "String",
52
+ date: "String",
53
+ boolean: "Boolean",
54
+ integer: "Integer"
55
+ }[type.to_sym]
56
+ end
57
+
58
+ def self.get_test_type(type)
59
+ {
60
+ bigint: 1,
61
+ float: 4.2,
62
+ string: '"MyString"',
63
+ text: '"MyString"',
64
+ datetime: "Time.now",
65
+ date: "Time.now",
66
+ boolean: false,
67
+ integer: 1
68
+ }[type.to_sym]
69
+ end
70
+
71
+ def self.table_check(line: "", class_name: "")
72
+ if line.include?("create_table") && (line.split[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
73
+
74
+ return true
75
+ end
76
+
77
+ false
78
+ end
79
+
80
+ def self.migrate(class_name: "souls")
81
+ singularized_class_name = class_name.singularize
82
+ model(class_name: singularized_class_name)
83
+ type(class_name: singularized_class_name)
84
+ edge(class_name: singularized_class_name)
85
+ connection(class_name: singularized_class_name)
86
+ resolver(class_name: singularized_class_name)
87
+ rspec_factory(class_name: singularized_class_name)
88
+ rspec_model(class_name: singularized_class_name)
89
+ rspec_mutation(class_name: singularized_class_name)
90
+ rspec_query(class_name: singularized_class_name)
91
+ rspec_resolver(class_name: singularized_class_name)
92
+ query(class_name: singularized_class_name)
93
+ mutation(class_name: singularized_class_name)
94
+ policy(class_name: singularized_class_name)
95
+ rspec_policy(class_name: singularized_class_name)
96
+ rescue StandardError => e
97
+ raise(StandardError, e)
98
+ end
99
+
100
+ def self.migrate_all
101
+ puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
102
+ Souls::Api::Generate.get_tables.each do |table|
103
+ Souls::Api::Generate.migrate(class_name: table.singularize)
104
+ puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
105
+ end
106
+ end
107
+
108
+ def self.delete_all(class_name: "souls")
109
+ singularized_class_name = class_name.singularize.underscore
110
+ pluralized_class_name = class_name.pluralize.underscore
111
+ FileUtils.rm("./app/models/#{singularized_class_name}.rb")
112
+ FileUtils.rm("./app/policies/#{singularized_class_name}_policy.rb")
113
+ FileUtils.rm_rf("./app/graphql/mutations/base/#{singularized_class_name}")
114
+ FileUtils.rm("./app/graphql/queries/#{singularized_class_name}.rb")
115
+ FileUtils.rm("./app/graphql/queries/#{pluralized_class_name}.rb")
116
+ FileUtils.rm("./app/graphql/resolvers/#{singularized_class_name}_search.rb")
117
+ FileUtils.rm("./app/graphql/types/#{singularized_class_name}_type.rb")
118
+ FileUtils.rm("./app/graphql/types/edges/#{singularized_class_name}_edge.rb")
119
+ FileUtils.rm("./app/graphql/types/connections/#{singularized_class_name}_connection.rb")
120
+ FileUtils.rm("./spec/factories/#{pluralized_class_name}.rb")
121
+ FileUtils.rm("./spec/mutations/base/#{singularized_class_name}_spec.rb")
122
+ FileUtils.rm("./spec/models/#{singularized_class_name}_spec.rb")
123
+ FileUtils.rm("./spec/queries/#{singularized_class_name}_spec.rb")
124
+ FileUtils.rm("./spec/policies/#{singularized_class_name}_policy_spec.rb")
125
+ FileUtils.rm("./spec/resolvers/#{singularized_class_name}_search_spec.rb")
126
+ puts(Paint["deleted #{class_name.camelize} CRUD!", :yellow])
127
+ rescue StandardError => e
128
+ raise(StandardError, e)
129
+ end
130
+
131
+ def self.update_delete(class_name: "souls")
132
+ singularized_class_name = class_name.singularize.underscore
133
+ pluralized_class_name = class_name.pluralize.underscore
134
+ FileUtils.rm_rf("./app/graphql/mutations/#{singularized_class_name}")
135
+ FileUtils.rm("./app/graphql/queries/#{singularized_class_name}.rb")
136
+ FileUtils.rm("./app/graphql/queries/#{pluralized_class_name}.rb")
137
+ FileUtils.rm("./app/graphql/resolvers/#{singularized_class_name}_search.rb")
138
+ FileUtils.rm("./app/graphql/types/#{singularized_class_name}_type.rb")
139
+ FileUtils.rm("./app/graphql/types/edges/#{singularized_class_name}_edge.rb")
140
+ FileUtils.rm("./app/graphql/types/connections/#{singularized_class_name}_connection.rb")
141
+ FileUtils.rm("./spec/mutations/#{singularized_class_name}_spec.rb")
142
+ FileUtils.rm("./spec/queries/#{singularized_class_name}_spec.rb")
143
+ FileUtils.rm("./spec/resolvers/#{singularized_class_name}_search_spec.rb")
144
+ puts("deleted #{class_name.camelize} CRUD!")
145
+ rescue StandardError => e
146
+ raise(StandardError, e)
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,59 @@
1
+ module Souls
2
+ module Worker
3
+ module Generate
4
+ class << self
5
+ def mailer(class_name: "mailer", option: :mailgun)
6
+ if option == :sendgrid
7
+ sendgrid_mailer(class_name: class_name)
8
+ else
9
+ mailgun_mailer(class_name: class_name)
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def mailgun_mailer(class_name: "mailer")
16
+ file_dir = "./app/graphql/mutations/mailers/"
17
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
18
+ file_path = "#{file_dir}#{class_name.singularize}.rb"
19
+ raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
20
+
21
+ File.open(file_path, "w") do |f|
22
+ f.write(<<~TEXT)
23
+ module Mutations
24
+ module Mailers
25
+ class #{class_name.camelize}Mailer < BaseMutation
26
+ description "Mail を送俑します。"
27
+ field :response, String, null: false
28
+
29
+ def resolve
30
+ # First, instantiate the Mailgun Client with your API key
31
+ mg_client = Mailgun::Client.new("YOUR-API-KEY")
32
+
33
+ # Define your message parameters
34
+ message_params = {
35
+ from: "postmaster@YOUR-DOMAIN",
36
+ to: "sending@to.mail.com",
37
+ subject: "SOULs Mailer test!",
38
+ text: "It is really easy to send a message!"
39
+ }
40
+
41
+ # Send your message through the client
42
+ mg_client.send_message("YOUR-sandbox.mailgun.org", message_params)
43
+ { response: "Job done!" }
44
+ rescue StandardError => e
45
+ GraphQL::ExecutionError.new(e.to_s)
46
+ end
47
+ end
48
+ end
49
+ TEXT
50
+ end
51
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
52
+ file_path
53
+ end
54
+
55
+ def sendgrid_mailer; end
56
+ end
57
+ end
58
+ end
59
+ end
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.29.1
4
+ version: 0.29.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -134,6 +134,9 @@ files:
134
134
  - lib/souls/versions/.souls_api_version
135
135
  - lib/souls/versions/.souls_worker_version
136
136
  - lib/souls/worker.rb
137
+ - lib/souls/worker/generate.rb
138
+ - lib/souls/worker/generate/application.rb
139
+ - lib/souls/worker/generate/mailer.rb
137
140
  homepage: https://souls.elsoul.nl
138
141
  licenses:
139
142
  - Apache-2.0