souls 1.6.5 → 1.6.6

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: 3ed4af3543c0bea6062467ddbf1929eeb98d7eb35395cb88258ebd255680777c
4
- data.tar.gz: eb16453c0ea26b86bb808e7cebd907c2334bfa06ad36ee92a8a7ab226b1f0ad1
3
+ metadata.gz: ed868d84c673b87fa30bd5551fff5914c9262013177ef209eb7dd57bb20a1fdf
4
+ data.tar.gz: a292621677b313f73605bcc85e5ffd3e332b85bf405e07267de23487572e8083
5
5
  SHA512:
6
- metadata.gz: 720e9d40626f9bffbfc95b1f7cf9241d2e396a9710433da94d387dd6266ebe0b4fe9c5f887c081152f8d2889d1b0ad6e8949464d251d522c3105c98f4579d90f
7
- data.tar.gz: 993bcb80e1310eb883a5ba30c0bd10510d639ef5353141d3605b8450b11317aa1c83ef6aaf222e54eab474e8c055cad9064e9e52fc0aea21d5dc43fb3ae45eff
6
+ metadata.gz: 86fc4188dfd8b9104365dfb7fa2cd2e2805a60fea39a595dc38c4837179c1d68849db3b922cf657eb067c7c73c564ea3c6e2d4a32aa31b0e6bd336a5f2f6ce98
7
+ data.tar.gz: bcab2634608df31fef8a3686fab692936b0ab8fc6d71fba99dbba50298d1e7aa97cd4e6c5ee6c10212bcb0a6bd17544ca9a70c5e21f6f5b86fb824b3409be3fb
@@ -4,10 +4,13 @@ module Souls
4
4
  method_option :mailer, type: :boolean, aliases: "--mailer", default: false, desc: "Mailer Option"
5
5
  def job(class_name)
6
6
  if options[:mailer]
7
+ create_job_mailer_type(class_name)
7
8
  mailgun_mailer(class_name)
8
9
  else
9
- create_job_mutation(class_name)
10
+ create_job_type(class_name)
11
+ create_job(class_name)
10
12
  end
13
+ update_query_type(class_name)
11
14
  Souls::Generate.new.invoke(:job_rbs, [class_name], {})
12
15
  Souls::Generate.new.invoke(:rspec_job, [class_name], { mailer: options[:mailer] })
13
16
  rescue Thor::Error => e
@@ -16,25 +19,20 @@ module Souls
16
19
 
17
20
  private
18
21
 
19
- def create_job_mutation(class_name)
20
- file_dir = "./app/graphql/mutations/"
22
+ def create_job(class_name)
23
+ file_dir = "./app/graphql/queries/"
21
24
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
22
25
  file_path = "#{file_dir}#{class_name.singularize}.rb"
23
- raise(StandardError, "Mutation already exist! #{file_path}") if File.exist?(file_path)
26
+ raise(StandardError, "Query already exist! #{file_path}") if File.exist?(file_path)
24
27
 
25
28
  File.open(file_path, "w") do |f|
26
29
  f.write(<<~TEXT)
27
- module Mutations
28
- class #{class_name.camelize} < BaseMutation
29
- description "Job Description"
30
- field :response, String, null: false
31
-
30
+ module Queries
31
+ class #{class_name.camelize} < BaseQuery
32
+ description ""
33
+ type Types::#{class_name.camelize}Type, null: false
34
+
32
35
  def resolve
33
- # Define Job Here
34
-
35
- { response: "Job done!" }
36
- rescue StandardError => e
37
- GraphQL::ExecutionError.new(e.to_s)
38
36
  end
39
37
  end
40
38
  end
@@ -43,32 +41,50 @@ module Souls
43
41
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
44
42
  file_path
45
43
  end
44
+
45
+ def create_job_type(class_name)
46
+ file_dir = "./app/graphql/types/"
47
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
48
+ file_path = "#{file_dir}#{class_name.singularize}_type.rb"
49
+ raise(StandardError, "Type already exists! #{file_path}") if File.exist?(file_path)
50
+
51
+ File.open(file_path, "w") do |f|
52
+ f.write(<<~TEXT)
53
+ module Types
54
+ class #{class_name.camelize}Type < BaseObject
55
+ end
56
+ end
57
+ TEXT
58
+ end
59
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
60
+ file_path
61
+ end
46
62
 
47
63
  def mailgun_mailer(class_name)
48
- file_dir = "./app/graphql/mutations/"
64
+ file_dir = "./app/graphql/queries/"
49
65
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
50
66
  file_path = "#{file_dir}#{class_name.singularize}.rb"
51
- raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
67
+ raise(StandardError, "Mailer already exists! #{file_path}") if File.exist?(file_path)
52
68
 
53
69
  File.open(file_path, "w") do |f|
54
70
  f.write(<<~TEXT)
55
- module Mutations
56
- class #{class_name.camelize} < BaseMutation
57
- description "Mail を送信します。"
58
- field :response, String, null: false
59
-
71
+ module Queries
72
+ class #{class_name.camelize} < BaseQuery
73
+ description ""
74
+ type Types::#{class_name.camelize}Type, null: false
75
+
60
76
  def resolve
61
77
  # First, instantiate the Mailgun Client with your API key
62
78
  mg_client = ::Mailgun::Client.new("YOUR-API-KEY")
63
-
79
+
64
80
  # Define your message parameters
65
81
  message_params = {
66
- from: "postmaster@YOUR-DOMAIN",
82
+ from: "postmaster@from.mail.com",
67
83
  to: "sending@to.mail.com",
68
84
  subject: "SOULs Mailer test!",
69
85
  text: "It is really easy to send a message!"
70
86
  }
71
-
87
+
72
88
  # Send your message through the client
73
89
  mg_client.send_message("YOUR-MAILGUN-DOMAIN", message_params)
74
90
  { response: "Job done!" }
@@ -82,5 +98,44 @@ module Souls
82
98
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
83
99
  file_path
84
100
  end
101
+
102
+ def create_job_mailer_type(class_name)
103
+ file_dir = "./app/graphql/types/"
104
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
105
+ file_path = "#{file_dir}#{class_name.singularize}_type.rb"
106
+ raise(StandardError, "Type already exists! #{file_path}") if File.exist?(file_path)
107
+
108
+ File.open(file_path, "w") do |f|
109
+ f.write(<<~TEXT)
110
+ module Types
111
+ class #{class_name.camelize}Type < BaseObject
112
+ field :response, String, null: true
113
+ end
114
+ end
115
+ TEXT
116
+ end
117
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
118
+ file_path
119
+ end
120
+
121
+ def update_query_type(class_name)
122
+ file_dir = "./app/graphql/types/base/"
123
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
124
+ file_path = "#{file_dir}query_type.rb"
125
+ raise(StandardError, "Query type doesn't exist, please re-create it") unless File.exist?(file_path)
126
+
127
+ lines = File.readlines(file_path)
128
+ unless lines[-1].strip == "end" and lines[-2].strip == "end"
129
+ puts(Paint % ["Base query file has changed significantly and cannot be modified automatically, please update routes manually"], :yellow)
130
+ return
131
+ end
132
+
133
+ insert_string = " field :#{class_name.singularize}, resolver: Queries::#{class_name.camelize}\n"
134
+ lines.insert(-3, insert_string)
135
+ File.open(file_path, "w") { |f| f.write(lines.join) }
136
+
137
+ puts(Paint % ["Updated file : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
138
+ file_path
139
+ end
85
140
  end
86
141
  end
@@ -6,7 +6,7 @@ module Souls
6
6
  worker_name = FileUtils.pwd.split("/").last
7
7
  Dir.chdir(Souls.get_mother_path.to_s) do
8
8
  singularized_class_name = class_name.underscore.singularize
9
- file_dir = "./sig/#{worker_name}/app/graphql/mutations/"
9
+ file_dir = "./sig/#{worker_name}/app/graphql/queries/"
10
10
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
11
11
  file_path = "#{file_dir}#{singularized_class_name}.rbs"
12
12
  File.open(file_path, "w") do |f|
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.6.5".freeze
2
+ VERSION = "1.6.6".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.6.5
1
+ 1.6.6
@@ -1 +1 @@
1
- 1.6.5
1
+ 1.6.6
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.5
4
+ version: 1.6.6
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
- date: 2021-11-09 00:00:00.000000000 Z
13
+ date: 2021-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -232,8 +232,8 @@ licenses:
232
232
  metadata:
233
233
  homepage_uri: https://souls.elsoul.nl
234
234
  source_code_uri: https://github.com/elsoul/souls
235
- changelog_uri: https://github.com/elsoul/souls/releases/tag/v1.6.5
236
- post_install_message:
235
+ changelog_uri: https://github.com/elsoul/souls/releases/tag/v1.6.6
236
+ post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths:
239
239
  - lib
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  version: '0'
250
250
  requirements: []
251
251
  rubygems_version: 3.2.22
252
- signing_key:
252
+ signing_key:
253
253
  specification_version: 4
254
254
  summary: Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep,
255
255
  Active Record, RSpec, RuboCop, and Google Cloud.