souls 0.16.5 → 0.17.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/.rubocop.yml +1 -0
- data/Gemfile.lock +1 -1
- data/exe/souls +16 -1
- data/lib/souls/generate.rb +150 -35
- data/lib/souls/init.rb +0 -4
- data/lib/souls/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 652a6ed97ff4627ab69ae4b0dbe647c36961bf6ac31e3a221f6d1089800d87a6
|
4
|
+
data.tar.gz: '027758df8963b95327a77b59df5a77456f39d33764dbd20c668f88e96331ce59'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9109f25dd5e0ddbf756289732e5f6d7a508d70ce7ca07c378ff202c0b29f9b731f98e688a38dc59aa47c45af4c34bc1a6b01ee9998cdb36eb324906c865593
|
7
|
+
data.tar.gz: abffe7be9a74f4b785e83888a69a767a92d12d0182ef009cf802dabcda5124ef3380f02b5463078598f3258a00ed90f93ee2c46f164b21d71dc4f2f60c488cbe
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
@@ -35,7 +35,7 @@ begin
|
|
35
35
|
else
|
36
36
|
case ARGV[1]
|
37
37
|
when "RACK_ENV=production"
|
38
|
-
system "bundle exec irb
|
38
|
+
system "RACK_ENV=production bundle exec irb"
|
39
39
|
else
|
40
40
|
system "bundle exec irb"
|
41
41
|
end
|
@@ -48,6 +48,21 @@ begin
|
|
48
48
|
Souls::Init.config_init
|
49
49
|
when "-v", "--version"
|
50
50
|
puts Souls::VERSION
|
51
|
+
when "add"
|
52
|
+
case ARGV[1]
|
53
|
+
when "mutation"
|
54
|
+
Souls::Init.add_mutation class_name: "user", file_name: "hoi"
|
55
|
+
when "type"
|
56
|
+
Souls::Init.add_type class_name: "user", file_name: "hoi"
|
57
|
+
when "connection"
|
58
|
+
Souls::Init.add_connection class_name: "user", file_name: "hoi"
|
59
|
+
when "edge"
|
60
|
+
Souls::Init.add_edge class_name: "user", file_name: "hoi"
|
61
|
+
when "rspec_mutation"
|
62
|
+
Souls::Init.add_rspec_mutation class_name: "user", file_name: "hoi"
|
63
|
+
else
|
64
|
+
puts "HOI!"
|
65
|
+
end
|
51
66
|
when "g", "generate"
|
52
67
|
case ARGV[1]
|
53
68
|
when "test_dir"
|
data/lib/souls/generate.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Souls
|
2
2
|
module Init
|
3
3
|
class << self
|
4
|
+
def get_type_and_name line
|
5
|
+
line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
6
|
+
end
|
7
|
+
|
4
8
|
def node_type class_name: "souls"
|
5
9
|
file_path = "./app/graphql/types/#{class_name.singularize}_node_type.rb"
|
6
10
|
File.open(file_path, "w") do |f|
|
@@ -15,9 +19,10 @@ module Souls
|
|
15
19
|
[file_path]
|
16
20
|
end
|
17
21
|
|
18
|
-
def
|
22
|
+
def resolver_head class_name: "souls"
|
19
23
|
FileUtils.mkdir_p "./app/graphql/resolvers" unless Dir.exist? "./app/graphql/resolvers"
|
20
24
|
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
25
|
+
@relation_params = []
|
21
26
|
return ["Resolver already exist! #{file_path}"] if File.exist? file_path
|
22
27
|
File.open(file_path, "w") do |f|
|
23
28
|
f.write <<~EOS
|
@@ -30,63 +35,143 @@ module Souls
|
|
30
35
|
|
31
36
|
class #{class_name.camelize}Filter < ::Types::BaseInputObject
|
32
37
|
argument :OR, [self], required: false
|
38
|
+
EOS
|
39
|
+
end
|
40
|
+
end
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
def resolver_params class_name: "souls"
|
43
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
44
|
+
path = "./db/schema.rb"
|
45
|
+
@on = false
|
46
|
+
@user_exist = false
|
47
|
+
@relation_params = []
|
48
|
+
File.open(file_path, "a") do |new_line|
|
49
|
+
File.open(path, "r") do |f|
|
50
|
+
f.each_line.with_index do |line, i|
|
51
|
+
if @on
|
52
|
+
if line.include?("end") || line.include?("t.index")
|
53
|
+
break
|
54
|
+
end
|
55
|
+
field = "[String]" if line.include?("array: true")
|
56
|
+
type, name = get_type_and_name(line)
|
57
|
+
field ||= type_check type
|
58
|
+
case name
|
59
|
+
when "user_id"
|
60
|
+
@user_exist = true
|
61
|
+
when /$*_id\z/
|
62
|
+
@relation_params << name
|
63
|
+
new_line.write " argument :#{name}, String, required: false\n"
|
64
|
+
when "created_at", "updated_at"
|
65
|
+
next
|
66
|
+
else
|
67
|
+
new_line.write " argument :#{name}, #{field}, required: false\n"
|
37
68
|
end
|
69
|
+
end
|
70
|
+
@on = true if table_check(line: line, class_name: class_name)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
38
75
|
|
39
|
-
|
40
|
-
|
41
|
-
|
76
|
+
def resolver_after_params class_name: "souls"
|
77
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
78
|
+
File.open(file_path, "a") do |f|
|
79
|
+
f.write <<-EOS
|
80
|
+
argument :start_date, String, required: false
|
81
|
+
argument :end_date, String, required: false
|
82
|
+
end
|
42
83
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
84
|
+
option :filter, type: #{class_name.camelize}Filter, with: :apply_filter
|
85
|
+
option :first, type: types.Int, with: :apply_first
|
86
|
+
option :skip, type: types.Int, with: :apply_skip
|
47
87
|
|
48
|
-
|
49
|
-
|
50
|
-
|
88
|
+
def apply_filter(scope, value)
|
89
|
+
branches = normalize_filters(value).inject { |a, b| a.or(b) }
|
90
|
+
scope.merge branches
|
91
|
+
end
|
51
92
|
|
52
|
-
|
53
|
-
|
54
|
-
|
93
|
+
def normalize_filters(value, branches = [])
|
94
|
+
scope = ::#{class_name.camelize}.all
|
95
|
+
EOS
|
96
|
+
end
|
97
|
+
end
|
55
98
|
|
56
|
-
|
57
|
-
|
58
|
-
|
99
|
+
def resolver_before_end class_name: "souls"
|
100
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
101
|
+
path = "./db/schema.rb"
|
102
|
+
@on = false
|
103
|
+
@user_exist = false
|
104
|
+
@relation_params = []
|
105
|
+
File.open(file_path, "a") do |new_line|
|
106
|
+
File.open(path, "r") do |f|
|
107
|
+
f.each_line.with_index do |line, i|
|
108
|
+
if @on
|
109
|
+
if line.include?("end") || line.include?("t.index")
|
110
|
+
break
|
59
111
|
end
|
112
|
+
type, name = get_type_and_name(line)
|
113
|
+
if line.include?("array: true")
|
114
|
+
new_line.write " scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
|
115
|
+
next
|
116
|
+
end
|
117
|
+
case name
|
118
|
+
when "user_id"
|
119
|
+
@user_exist = true
|
120
|
+
when /$*_id\z/
|
121
|
+
@relation_params << name
|
122
|
+
new_line.write " scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n"
|
123
|
+
when "created_at", "updated_at"
|
124
|
+
next
|
125
|
+
else
|
126
|
+
case type
|
127
|
+
when "boolean"
|
128
|
+
new_line.write " scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n"
|
129
|
+
else
|
130
|
+
new_line.write " scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
@on = true if table_check(line: line, class_name: class_name)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
60
139
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
140
|
+
def resolver_end class_name: "souls"
|
141
|
+
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
142
|
+
File.open(file_path, "a") do |f|
|
143
|
+
f.write <<-EOS
|
144
|
+
scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
|
145
|
+
scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
|
67
146
|
|
68
|
-
|
147
|
+
branches << scope
|
69
148
|
|
70
|
-
|
149
|
+
value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
|
71
150
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
151
|
+
branches
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
76
155
|
EOS
|
77
156
|
end
|
78
157
|
[file_path]
|
79
158
|
end
|
80
159
|
|
160
|
+
def resolver class_name: "souls"
|
161
|
+
singularized_class_name = class_name.singularize.underscore
|
162
|
+
resolver_head class_name: singularized_class_name
|
163
|
+
resolver_params class_name: singularized_class_name
|
164
|
+
resolver_after_params class_name: singularized_class_name
|
165
|
+
resolver_before_end class_name: singularized_class_name
|
166
|
+
resolver_end class_name: singularized_class_name
|
167
|
+
end
|
168
|
+
|
81
169
|
def job class_name: "send_mail"
|
82
170
|
file_path = "./app/jobs/#{class_name.singularize}_job.rb"
|
83
171
|
return ["Job already exist! #{file_path}"] if File.exist? file_path
|
84
172
|
File.open(file_path, "w") do |f|
|
85
173
|
f.write <<~EOS
|
86
174
|
class #{class_name.camelize}
|
87
|
-
include Sidekiq::Status::Worker
|
88
|
-
include Sidekiq::Worker
|
89
|
-
sidekiq_options queue: "default"
|
90
175
|
|
91
176
|
def perform **args
|
92
177
|
# write task code here
|
@@ -300,6 +385,36 @@ end
|
|
300
385
|
rescue StandardError => error
|
301
386
|
puts error
|
302
387
|
end
|
388
|
+
|
389
|
+
def add_mutation class_name: "souls", file_name: "hoi"
|
390
|
+
singularized_class_name = class_name.singularize.underscore
|
391
|
+
file_path = "./app/graphql/mutations/#{singularized_class_name}/#{file_name}.rb"
|
392
|
+
file_path
|
393
|
+
end
|
394
|
+
|
395
|
+
def add_type class_name: "souls", file_name: "hoi"
|
396
|
+
singularized_class_name = class_name.singularize.underscore
|
397
|
+
file_path = "./app/graphql/types/#{file_name}.rb"
|
398
|
+
file_path
|
399
|
+
end
|
400
|
+
|
401
|
+
def add_edge class_name: "souls", file_name: "hoi"
|
402
|
+
singularized_class_name = class_name.singularize.underscore
|
403
|
+
file_path = "./app/graphql/types/#{file_name}.rb"
|
404
|
+
file_path
|
405
|
+
end
|
406
|
+
|
407
|
+
def add_connection class_name: "souls", file_name: "hoi"
|
408
|
+
singularized_class_name = class_name.singularize.underscore
|
409
|
+
file_path = "./app/graphql/types/#{file_name}.rb"
|
410
|
+
file_path
|
411
|
+
end
|
412
|
+
|
413
|
+
def add_rspec_mutation class_name: "souls", file_name: "hoi"
|
414
|
+
singularized_class_name = class_name.singularize.underscore
|
415
|
+
file_path = "./app/graphql/types/#{file_name}.rb"
|
416
|
+
file_path
|
417
|
+
end
|
303
418
|
end
|
304
419
|
end
|
305
420
|
end
|
data/lib/souls/init.rb
CHANGED
@@ -780,10 +780,6 @@ module Souls
|
|
780
780
|
EOS
|
781
781
|
else
|
782
782
|
new_line.write <<-EOS
|
783
|
-
|
784
|
-
def get_global_key class_name, id
|
785
|
-
Base64.encode64(\"\#{class_name}:\#{id}\")
|
786
|
-
end
|
787
783
|
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(", ")}) }
|
788
784
|
|
789
785
|
let(:mutation) do
|
data/lib/souls/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.17.0
|
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-03-
|
13
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SOULS is a Web Application Framework for Microservices on Multi Cloud
|
16
16
|
Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|
@@ -55,7 +55,7 @@ metadata:
|
|
55
55
|
homepage_uri: https://github.com/elsoul/souls
|
56
56
|
source_code_uri: https://github.com/elsoul/souls
|
57
57
|
changelog_uri: https://github.com/elsoul/souls
|
58
|
-
post_install_message:
|
58
|
+
post_install_message:
|
59
59
|
rdoc_options: []
|
60
60
|
require_paths:
|
61
61
|
- lib
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubygems_version: 3.2.3
|
74
|
-
signing_key:
|
74
|
+
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: SOULS is a GraphQL Based Web Application Framework for Microservices on Multi
|
77
77
|
Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
|