souls 0.15.4 → 0.15.5

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: 92bb6af0f4b226fb280b5c821065a5e1a2a42d122421f515f0b69b18f6c9d4e4
4
- data.tar.gz: 94a3ae84d925f9da525506d5ef8e21a18fb9cad3216b814532a91f656f318459
3
+ metadata.gz: e72a21841cb1bad148b2b4fb2c9b6fc01fe55bf3b369bfb3aaf71df1393bd34f
4
+ data.tar.gz: 1e60f71a7d2ad5734d7f8a6f18cca6b437148c7f4f9d08145fe5eddef81be639
5
5
  SHA512:
6
- metadata.gz: 89c2cd3f9f1053718cfe21866a4c0f496a5b11f940c1199ae244f3285447129b6e5ed9507728b26151104882f4322de1b9fc5859f57da570f57de95f5a82d6fd
7
- data.tar.gz: 35b6bf6be49bb5a6cc34fc6884023715a8d6ccbcc1f5a76b8486717feadb214cf5fcf528d6b0c1fe37065a23f967fc009ace2ba7df69ba4d462602820dc5bb83
6
+ metadata.gz: 0fbaa59c380970e79452516a7b049dd8815c0f65bd35dad5cd9f263adb700fe5b44b2e2b7ccd298ecfaf4c9e6c80966f1d955f9346a0799d8a2b242dbb305889
7
+ data.tar.gz: 2d7ab88bd16ac812b1e751faf5f924e75e01dcb7be5b181867083bfb60d2611aadd92247c7be4d8fcfe99361055214d668107d45b61caf8a7216524c998ad20c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.15.2)
4
+ souls (0.15.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/souls CHANGED
@@ -25,7 +25,7 @@ begin
25
25
  when "service"
26
26
  system "bundle exec rake run_server"
27
27
  else
28
- STDOUT.write `foreman start -f Procfile.dev`
28
+ `foreman start -f Procfile.dev`
29
29
  end
30
30
  when "c", "console"
31
31
  strain = Souls.configuration.strain
@@ -33,7 +33,7 @@ begin
33
33
  when "media", "admin"
34
34
  system "yarn dev"
35
35
  else
36
- STDOUT.write `bundle exec irb`
36
+ `bundle exec irb`
37
37
  end
38
38
  when "i", "infra"
39
39
  Souls.send ARGV[1]
@@ -77,6 +77,8 @@ begin
77
77
  Souls::Init.rspec_query class_name: ARGV[2]
78
78
  when "rspec_type"
79
79
  Souls::Init.rspec_type class_name: ARGV[2]
80
+ when "rspec_resolver"
81
+ Souls::Init.rspec_resolver class_name: ARGV[2]
80
82
  else
81
83
  "SOULs!"
82
84
  end
@@ -18,6 +18,7 @@ module Souls
18
18
  def resolver class_name: "souls"
19
19
  FileUtils.mkdir_p "./app/graphql/resolvers" unless Dir.exist? "./app/graphql/resolvers"
20
20
  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
21
+ return ["Aleady Exist!"] if File.exist? file_path
21
22
  File.open(file_path, "w") do |f|
22
23
  f.write <<~EOS
23
24
  module Resolvers
@@ -30,6 +31,7 @@ module Souls
30
31
  class #{class_name.camelize}Filter < ::Types::BaseInputObject
31
32
  argument :OR, [self], required: false
32
33
 
34
+ argument :is_deleted, Boolean, required: false
33
35
  argument :start_date, String, required: false
34
36
  argument :end_date, String, required: false
35
37
  end
@@ -57,8 +59,9 @@ module Souls
57
59
  end
58
60
 
59
61
  def normalize_filters(value, branches = [])
60
- scope = ::Article.all
62
+ scope = ::#{class_name.camelize}.all
61
63
 
64
+ scope = scope.where(is_deleted: value[:is_deleted]) if value[:is_deleted]
62
65
  scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
63
66
  scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
64
67
 
@@ -75,24 +78,203 @@ module Souls
75
78
  [file_path]
76
79
  end
77
80
 
78
- def job class_name: "send_mail"
79
- file_path = "./app/jobs/#{class_name.singularize}_job.rb"
80
- File.open(file_path, "w") do |f|
81
- f.write <<~EOS
82
- class #{class_name.camelize}
83
- include Sidekiq::Status::Worker
84
- include Sidekiq::Worker
85
- sidekiq_options queue: "default"
86
-
87
- def perform **args
88
- # write task code here
81
+ def job class_name: "send_mail"
82
+ file_path = "./app/jobs/#{class_name.singularize}_job.rb"
83
+ return ["Aleady Exist!"] if File.exist? file_path
84
+ File.open(file_path, "w") do |f|
85
+ f.write <<~EOS
86
+ class #{class_name.camelize}
87
+ include Sidekiq::Status::Worker
88
+ include Sidekiq::Worker
89
+ sidekiq_options queue: "default"
90
+
91
+ def perform **args
92
+ # write task code here
93
+ end
94
+ end
95
+ EOS
96
+ end
97
+ [file_path]
98
+ end
99
+
100
+ def rspec_resolver_head class_name: "souls"
101
+ file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
102
+ File.open(file_path, "w") do |f|
103
+ f.write <<~EOS
104
+ RSpec.describe \"#{class_name.camelize}Search Resolver テスト\" do
105
+ describe "削除フラグ false の #{class_name.camelize} を返却する" do
106
+ EOS
107
+ end
108
+ end
109
+
110
+ def rspec_resolver_after_head class_name: "souls"
111
+ file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
112
+ path = "./db/schema.rb"
113
+ @on = false
114
+ @user_exist = false
115
+ @relation_params = []
116
+ File.open(file_path, "a") do |new_line|
117
+ File.open(path, "r") do |f|
118
+ f.each_line.with_index do |line, i|
119
+ if @on
120
+ if line.include?("end") || line.include?("t.index")
121
+ if @relation_params.empty?
122
+ new_line.write <<-EOS
123
+ let(:#{class_name}) { FactoryBot.create(:#{class_name}) }
124
+
125
+ let(:query) do
126
+ %(query {
127
+ #{class_name.singularize.camelize(:lower)}Search(filter: {
128
+ isDeleted: false
129
+ }) {
130
+ edges {
131
+ cursor
132
+ node {
133
+ id
134
+ EOS
135
+ else
136
+ new_line.write <<-EOS
137
+ let(:#{class_name}) { FactoryBot.create(:#{class_name}, #{@relation_params.join(", ")}) }
138
+
139
+ let(:query) do
140
+ %(query {
141
+ #{class_name.singularize.camelize(:lower)}Search(filter: {
142
+ isDeleted: false
143
+ }) {
144
+ edges {
145
+ cursor
146
+ node {
147
+ id
148
+ EOS
149
+ end
150
+ break
151
+ end
152
+ _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
153
+ case name
154
+ when /$*_id\z/
155
+ relation_col = name.gsub("_id", "")
156
+ @relation_params << "#{name}: #{relation_col}.id"
157
+ new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
158
+ end
159
+ end
160
+ if table_check(line: line, class_name: class_name)
161
+ @on = true
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ def rspec_resolver_params class_name: "souls"
169
+ file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
170
+ path = "./db/schema.rb"
171
+ @on = false
172
+ File.open(file_path, "a") do |new_line|
173
+ File.open(path, "r") do |f|
174
+ f.each_line.with_index do |line, i|
175
+ if @on
176
+ if line.include?("end") || line.include?("t.index")
177
+ new_line.write <<-EOS
178
+ }
179
+ }
180
+ nodes {
181
+ id
182
+ }
183
+ pageInfo {
184
+ endCursor
185
+ hasNextPage
186
+ startCursor
187
+ hasPreviousPage
188
+ }
189
+ }
190
+ }
191
+ )
192
+ end
193
+
194
+ subject(:result) do
195
+ SoulsApiSchema.execute(query).as_json
196
+ end
197
+
198
+ it "return #{class_name.camelize} Data" do
199
+ a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}Search", "edges")[0]["node"]
200
+ p result if a1.nil?
201
+ expect(a1).to include(
202
+ "id" => be_a(String),
203
+ EOS
204
+ break
205
+ end
206
+ _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
207
+ case name
208
+ when "user_id", "created_at", "updated_at", /$*_id\z/
209
+ next
210
+ else
211
+ new_line.write " #{name.camelize(:lower)}\n"
212
+ end
213
+ end
214
+ if table_check(line: line, class_name: class_name)
215
+ @on = true
216
+ end
89
217
  end
90
218
  end
91
- EOS
219
+ end
92
220
  end
93
- [file_path]
221
+
222
+ def rspec_resolver_end class_name: "souls"
223
+ file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
224
+ path = "./db/schema.rb"
225
+ @on = false
226
+ File.open(file_path, "a") do |new_line|
227
+ File.open(path, "r") do |f|
228
+ f.each_line.with_index do |line, i|
229
+ if @on
230
+ if line.include?("end") || line.include?("t.index")
231
+ new_line.write <<-EOS
232
+ )
94
233
  end
234
+ end
235
+ end
236
+ EOS
237
+ break
238
+ end
239
+ type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
240
+ field ||= type_check type
241
+ array_true = line.include?("array: true")
242
+ case name
243
+ when "user_id", "created_at", "updated_at", /$*_id\z/
244
+ next
245
+ else
246
+ case type
247
+ when "text", "date", "datetime"
248
+ if array_true
249
+ new_line.write " \"#{name.camelize(:lower)}\" => be_all(String),\n"
250
+ else
251
+ new_line.write " \"#{name.camelize(:lower)}\" => be_a(String),\n"
252
+ end
253
+ when "boolean"
254
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
255
+ when "string", "bigint", "integer", "float"
256
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
257
+ end
258
+ end
259
+ end
260
+ if table_check(line: line, class_name: class_name)
261
+ @on = true
262
+ end
263
+ end
264
+ end
265
+ end
266
+ [file_path]
267
+ end
95
268
 
269
+ def rspec_resolver class_name: "souls"
270
+ singularized_class_name = class_name.singularize
271
+ file_path = "#{Dir.pwd}/spec/resolvers/#{singularized_class_name}_search_spec.rb"
272
+ return ["Aleady Exist!"] if File.exist? file_path
273
+ rspec_resolver_head class_name: singularized_class_name
274
+ rspec_resolver_after_head class_name: singularized_class_name
275
+ rspec_resolver_params class_name: singularized_class_name
276
+ rspec_resolver_end class_name: singularized_class_name
277
+ end
96
278
  end
97
279
  end
98
- end
280
+ end
data/lib/souls/init.rb CHANGED
@@ -114,11 +114,11 @@ module Souls
114
114
  system "cp -r #{repository_name}-#{folder}/ #{app_name}/"
115
115
  system "rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}"
116
116
  txt = <<~TEXT
117
- _____ ____ __ ____#{' '}
118
- / ___// __ \\/ / / / / _____
119
- \\__ \\/ / / / / / / / / ___/
120
- ___/ / /_/ / /_/ / /___(__ )#{' '}
121
- /____/\\____/\\____/_____/____/#{' '}
117
+ _____ ____ __ ____#{' '}
118
+ / ___// __ \\/ / / / / _____
119
+ \\__ \\/ / / / / / / / / ___/
120
+ ___/ / /_/ / /_/ / /___(__ )#{' '}
121
+ /____/\\____/\\____/_____/____/#{' '}
122
122
  TEXT
123
123
  puts txt
124
124
  puts "=============================="
@@ -724,7 +724,7 @@ module Souls
724
724
  end
725
725
 
726
726
  def rspec_factory class_name: "souls"
727
- return ["Aleady Exist!"] unless File.exist? "./spec/factories/#{class_name.singularize}"
727
+ return ["Aleady Exist!"] if File.exist? "./spec/factories/#{class_name.singularize}"
728
728
  singularized_class_name = class_name.singularize
729
729
  rspec_factory_head class_name: singularized_class_name
730
730
  rspec_factory_params class_name: singularized_class_name
@@ -733,7 +733,7 @@ module Souls
733
733
 
734
734
  def rspec_model class_name: "souls"
735
735
  file_path = "./spec/models/#{class_name}_spec.rb"
736
- return ["Aleady Exist!"] unless File.exist? file_path
736
+ return ["Aleady Exist!"] if File.exist? file_path
737
737
  File.open(file_path, "w") do |f|
738
738
  f.write <<~EOS
739
739
  RSpec.describe "#{class_name.camelize} Model テスト", type: :model do
@@ -934,13 +934,13 @@ module Souls
934
934
  File.open(file_path, "a") do |new_line|
935
935
  File.open(path, "r") do |f|
936
936
  f.each_line.with_index do |line, i|
937
- if @on
937
+ if @on
938
938
  if line.include?("end") || line.include?("t.index")
939
939
  new_line.write <<~EOS
940
- )
941
- end
942
- end
940
+ )
943
941
  end
942
+ end
943
+ end
944
944
  EOS
945
945
  break
946
946
  end
@@ -1051,7 +1051,7 @@ module Souls
1051
1051
  File.open(file_path, "a") do |new_line|
1052
1052
  File.open(path, "r") do |f|
1053
1053
  f.each_line.with_index do |line, i|
1054
- if @on
1054
+ if @on
1055
1055
  if line.include?("end") || line.include?("t.index")
1056
1056
  new_line.write <<-EOS
1057
1057
  }
@@ -1093,13 +1093,13 @@ module Souls
1093
1093
  File.open(file_path, "a") do |new_line|
1094
1094
  File.open(path, "r") do |f|
1095
1095
  f.each_line.with_index do |line, i|
1096
- if @on
1096
+ if @on
1097
1097
  if line.include?("end") || line.include?("t.index")
1098
- new_line.write <<-EOS
1099
- )
1100
- end
1101
- end
1102
- end
1098
+ new_line.write <<~EOS
1099
+ )
1100
+ end
1101
+ end
1102
+ end
1103
1103
  EOS
1104
1104
  break
1105
1105
  end
@@ -1174,20 +1174,24 @@ end
1174
1174
  model_paths = model class_name: singularized_class_name
1175
1175
  type_paths = type class_name: singularized_class_name
1176
1176
  node_type_paths = node_type class_name: singularized_class_name
1177
+ resolver_paths = resolver class_name: singularized_class_name
1177
1178
  rspec_factory_paths = rspec_factory class_name: singularized_class_name
1178
1179
  rspec_model_paths = rspec_model class_name: singularized_class_name
1179
1180
  rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
1180
1181
  rspec_query_paths = rspec_query class_name: singularized_class_name
1182
+ rspec_resolver_paths = rspec_resolver class_name: singularized_class_name
1181
1183
  query_path = query class_name: singularized_class_name
1182
1184
  mutation_path = mutation class_name: singularized_class_name
1183
1185
  [
1184
1186
  model: model_paths,
1185
1187
  type: type_paths,
1188
+ resolver: resolver_paths,
1186
1189
  node_type: node_type_paths,
1187
1190
  rspec_factory: rspec_factory_paths,
1188
1191
  rspec_model: rspec_model_paths,
1189
1192
  rspec_mutation: rspec_mutation_paths,
1190
1193
  rspec_query: rspec_query_paths,
1194
+ rspec_resolver: rspec_resolver_paths,
1191
1195
  query: query_path,
1192
1196
  mutation: mutation_path,
1193
1197
  add_query_type: [
@@ -1208,11 +1212,13 @@ end
1208
1212
  result = migrate class_name: class_name
1209
1213
  puts result[0][:model]
1210
1214
  puts result[0][:type]
1215
+ puts result[0][:resolver]
1211
1216
  puts result[0][:node_type]
1212
1217
  puts result[0][:rspec_factory]
1213
1218
  puts result[0][:rspec_model]
1214
1219
  puts result[0][:rspec_mutation]
1215
1220
  puts result[0][:rspec_query]
1221
+ puts result[0][:rspec_resolver]
1216
1222
  puts result[0][:query]
1217
1223
  puts result[0][:mutation]
1218
1224
 
@@ -1258,6 +1264,12 @@ end
1258
1264
  path[:type].each { |line| puts line }
1259
1265
  end
1260
1266
  end
1267
+ puts "\n============== Resolver =======================\n\n"
1268
+ paths.each do |class_name|
1269
+ class_name.each do |path|
1270
+ path[:resovler].each { |line| puts line }
1271
+ end
1272
+ end
1261
1273
  puts "\n============== NodeType =======================\n\n"
1262
1274
  paths.each do |class_name|
1263
1275
  class_name.each do |path|
@@ -1288,6 +1300,12 @@ end
1288
1300
  path[:rspec_query].each { |line| puts line }
1289
1301
  end
1290
1302
  end
1303
+ puts "\n============== RspecResolver =================\n\n"
1304
+ paths.each do |class_name|
1305
+ class_name.each do |path|
1306
+ path[:rspec_resolver].each { |line| puts line }
1307
+ end
1308
+ end
1291
1309
  puts "\n============== Query ======================\n\n"
1292
1310
  paths.each do |class_name|
1293
1311
  class_name.each do |path|
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.15.4"
2
+ VERSION = "0.15.5"
3
3
  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.15.4
4
+ version: 0.15.5
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-02-13 00:00:00.000000000 Z
13
+ date: 2021-02-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.
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.2.3
73
+ rubygems_version: 3.2.4
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: SOULS is a GraphQL Based Web Application Framework for Microservices on Multi