souls 0.15.1 → 0.15.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: 53de40efd144cd448a857b6137f1769b3666b561682395892440cc469cea45a2
4
- data.tar.gz: 9a25d0ee2b989d0b43305462c05991e829ace194f34b7ce4b0b52b0271ba425b
3
+ metadata.gz: 822cc3c17c118abe445b06166b676238c722060af7379ba7620ac7e38603810f
4
+ data.tar.gz: 84923f26838b78d83c79c50d4703c6a19f6c49c1bc9048345332286813d2e178
5
5
  SHA512:
6
- metadata.gz: 578a24022e14528fdfd8809269f69f6b4c02f6c27660ecb9e1d3752861518ffa7150f31a28fa4661cb380ead5cb157b3855b0434efcc471b529946891498c623
7
- data.tar.gz: 3774afb512a034298bca690f6ffb2d41ae71fd8407d97095409c55488f6d8b86eb2946f587c1e9dc0bdec69f8fe41c8f49882e9d70e7f87d121f182e97616519
6
+ metadata.gz: 077a258b9306c9b53bf17ca7d2d969f18369c43ce39c01d29dc1db7befc3d5cbf9fa8d0a69946b9fe242cfe4bba6d1e3c5627329741ec91fe5408fe4191e4446
7
+ data.tar.gz: c9265785646fe4bed96d999d21c75042be26e72f97cffaf2bade4427c084dd55e3453b2593dfcf2a0ce0c227b233b13f6937567729e03187216a3d1451ffae67
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.14.7)
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
- system "bundle exec puma -p 3000"
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
- system "bundle exec irb"
36
+ `bundle exec irb`
37
37
  end
38
38
  when "i", "infra"
39
39
  Souls.send ARGV[1]
@@ -47,12 +47,12 @@ begin
47
47
  case ARGV[1]
48
48
  when "test_dir"
49
49
  Souls::Init.test_dir
50
- when "test"
51
- Souls::Init.node_type class_name: "user"
50
+ when "node_type"
51
+ Souls::Init.node_type class_name: ARGV[2]
52
52
  when "resolver"
53
- Souls::Init.resolver class_name: "user"
53
+ Souls::Init.resolver class_name: ARGV[2]
54
54
  when "job"
55
- Souls::Init.job class_name: "user"
55
+ Souls::Init.job class_name: ARGV[2]
56
56
  when "model"
57
57
  Souls::Init.model class_name: ARGV[2]
58
58
  when "mutation"
@@ -66,7 +66,7 @@ begin
66
66
  when "migrate_all"
67
67
  Souls::Init.migrate_all
68
68
  when "migration"
69
- `rake db:create_migration NAME=#{ARGV[2]}`
69
+ STDOUT.write `rake db:create_migration NAME=#{ARGV[2]}`
70
70
  when "rspec_factory"
71
71
  Souls::Init.rspec_factory class_name: ARGV[2]
72
72
  when "rspec_model"
@@ -77,24 +77,26 @@ 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
83
85
  when "db:create"
84
- `rake db:create && rake db:create RACK_ENV=test`
86
+ STDOUT.write `rake db:create && rake db:create RACK_ENV=test`
85
87
  when "db:migrate"
86
- `rake db:migrate && rake db:migrate RACK_ENV=test`
88
+ STDOUT.write `rake db:migrate && rake db:migrate RACK_ENV=test`
87
89
  when "db:migrate:reset"
88
- `rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test`
90
+ STDOUT.write `rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test`
89
91
  when "t", "test"
90
- `rubocop`
91
- `bundle exec rspec`
92
+ STDOUT.write `rubocop`
93
+ STDOUT.write `bundle exec rspec`
92
94
  when "run"
93
- `docker build . -t souls:latest`
94
- `docker run --rm -p 3000:3000 souls:latest`
95
+ STDOUT.write `docker build . -t souls:latest`
96
+ STDOUT.write `docker run --rm -p 3000:3000 souls:latest`
95
97
  when "deploy"
96
98
  project_id = Souls.configuration.project_id
97
- `gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
99
+ STDOUT.write `gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
98
100
  else
99
101
  puts "Welcome to SOULs!"
100
102
  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,207 @@ 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
89
163
  end
90
164
  end
91
- EOS
165
+ end
92
166
  end
93
- [file_path]
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
+ )
94
192
  end
95
193
 
194
+ subject(:result) do
195
+ SoulsApiSchema.execute(query).as_json
196
+ end
197
+
198
+ it "return #{class_name.camelize} Data" do
199
+ begin
200
+ a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}Search", "edges")[0]["node"]
201
+ raise unless a1.present?
202
+ rescue
203
+ raise StandardError, result
204
+ end
205
+ expect(a1).to include(
206
+ "id" => be_a(String),
207
+ EOS
208
+ break
209
+ end
210
+ _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
211
+ case name
212
+ when "user_id", "created_at", "updated_at", /$*_id\z/
213
+ next
214
+ else
215
+ new_line.write " #{name.camelize(:lower)}\n"
216
+ end
217
+ end
218
+ if table_check(line: line, class_name: class_name)
219
+ @on = true
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
225
+
226
+ def rspec_resolver_end class_name: "souls"
227
+ file_path = "./spec/resolvers/#{class_name.singularize}_search_spec.rb"
228
+ path = "./db/schema.rb"
229
+ @on = false
230
+ File.open(file_path, "a") do |new_line|
231
+ File.open(path, "r") do |f|
232
+ f.each_line.with_index do |line, i|
233
+ if @on
234
+ if line.include?("end") || line.include?("t.index")
235
+ new_line.write <<-EOS
236
+ )
237
+ end
238
+ end
239
+ end
240
+ EOS
241
+ break
242
+ end
243
+ type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
244
+ field ||= type_check type
245
+ array_true = line.include?("array: true")
246
+ case name
247
+ when "user_id", "created_at", "updated_at", /$*_id\z/
248
+ next
249
+ else
250
+ case type
251
+ when "text", "date", "datetime"
252
+ if array_true
253
+ new_line.write " \"#{name.camelize(:lower)}\" => be_all(String),\n"
254
+ else
255
+ new_line.write " \"#{name.camelize(:lower)}\" => be_a(String),\n"
256
+ end
257
+ when "boolean"
258
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n"
259
+ when "string", "bigint", "integer", "float"
260
+ new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
261
+ end
262
+ end
263
+ end
264
+ if table_check(line: line, class_name: class_name)
265
+ @on = true
266
+ end
267
+ end
268
+ end
269
+ end
270
+ [file_path]
271
+ end
272
+
273
+ def rspec_resolver class_name: "souls"
274
+ singularized_class_name = class_name.singularize
275
+ file_path = "#{Dir.pwd}/spec/resolvers/#{singularized_class_name}_search_spec.rb"
276
+ return ["Aleady Exist!"] if File.exist? file_path
277
+ rspec_resolver_head class_name: singularized_class_name
278
+ rspec_resolver_after_head class_name: singularized_class_name
279
+ rspec_resolver_params class_name: singularized_class_name
280
+ rspec_resolver_end class_name: singularized_class_name
281
+ end
96
282
  end
97
283
  end
98
- end
284
+ 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
@@ -881,7 +881,12 @@ module Souls
881
881
  end
882
882
 
883
883
  it "return #{class_name.camelize} Data" do
884
- a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
884
+ begin
885
+ a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
886
+ raise unless a1.present?
887
+ rescue
888
+ raise StandardError, result
889
+ end
885
890
  expect(a1).to include(
886
891
  "id" => be_a(String),
887
892
  EOS
@@ -899,7 +904,12 @@ module Souls
899
904
  end
900
905
 
901
906
  it "return #{class_name.camelize} Data" do
902
- a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
907
+ begin
908
+ a1 = result.dig("data", "create#{class_name.singularize.camelize}", "#{class_name.singularize.camelize(:lower)}Edge", "node")
909
+ raise unless a1.present?
910
+ rescue
911
+ raise StandardError, result
912
+ end
903
913
  expect(a1).to include(
904
914
  "id" => be_a(String),
905
915
  EOS
@@ -934,13 +944,13 @@ module Souls
934
944
  File.open(file_path, "a") do |new_line|
935
945
  File.open(path, "r") do |f|
936
946
  f.each_line.with_index do |line, i|
937
- if @on
947
+ if @on
938
948
  if line.include?("end") || line.include?("t.index")
939
949
  new_line.write <<~EOS
940
- )
941
- end
942
- end
950
+ )
943
951
  end
952
+ end
953
+ end
944
954
  EOS
945
955
  break
946
956
  end
@@ -1006,7 +1016,7 @@ module Souls
1006
1016
  if line.include?("end") || line.include?("t.index")
1007
1017
  if @relation_params.empty?
1008
1018
  new_line.write <<-EOS
1009
- let(:#{class_name}) { FactoryBot.create(:#{class_name}) }
1019
+ let!(:#{class_name}) { FactoryBot.create(:#{class_name}) }
1010
1020
 
1011
1021
  let(:query) do
1012
1022
  data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
@@ -1051,7 +1061,7 @@ module Souls
1051
1061
  File.open(file_path, "a") do |new_line|
1052
1062
  File.open(path, "r") do |f|
1053
1063
  f.each_line.with_index do |line, i|
1054
- if @on
1064
+ if @on
1055
1065
  if line.include?("end") || line.include?("t.index")
1056
1066
  new_line.write <<-EOS
1057
1067
  }
@@ -1064,7 +1074,12 @@ module Souls
1064
1074
  end
1065
1075
 
1066
1076
  it "return #{class_name.camelize} Data" do
1067
- a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}")
1077
+ begin
1078
+ a1 = result.dig("data", "#{class_name.singularize.camelize(:lower)}")
1079
+ raise unless a1.present?
1080
+ rescue
1081
+ raise StandardError, result
1082
+ end
1068
1083
  expect(a1).to include(
1069
1084
  "id" => be_a(String),
1070
1085
  EOS
@@ -1093,13 +1108,13 @@ module Souls
1093
1108
  File.open(file_path, "a") do |new_line|
1094
1109
  File.open(path, "r") do |f|
1095
1110
  f.each_line.with_index do |line, i|
1096
- if @on
1111
+ if @on
1097
1112
  if line.include?("end") || line.include?("t.index")
1098
- new_line.write <<-EOS
1099
- )
1100
- end
1101
- end
1102
- end
1113
+ new_line.write <<~EOS
1114
+ )
1115
+ end
1116
+ end
1117
+ end
1103
1118
  EOS
1104
1119
  break
1105
1120
  end
@@ -1174,20 +1189,24 @@ end
1174
1189
  model_paths = model class_name: singularized_class_name
1175
1190
  type_paths = type class_name: singularized_class_name
1176
1191
  node_type_paths = node_type class_name: singularized_class_name
1192
+ resolver_paths = resolver class_name: singularized_class_name
1177
1193
  rspec_factory_paths = rspec_factory class_name: singularized_class_name
1178
1194
  rspec_model_paths = rspec_model class_name: singularized_class_name
1179
1195
  rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
1180
1196
  rspec_query_paths = rspec_query class_name: singularized_class_name
1197
+ rspec_resolver_paths = rspec_resolver class_name: singularized_class_name
1181
1198
  query_path = query class_name: singularized_class_name
1182
1199
  mutation_path = mutation class_name: singularized_class_name
1183
1200
  [
1184
1201
  model: model_paths,
1185
1202
  type: type_paths,
1203
+ resolver: resolver_paths,
1186
1204
  node_type: node_type_paths,
1187
1205
  rspec_factory: rspec_factory_paths,
1188
1206
  rspec_model: rspec_model_paths,
1189
1207
  rspec_mutation: rspec_mutation_paths,
1190
1208
  rspec_query: rspec_query_paths,
1209
+ rspec_resolver: rspec_resolver_paths,
1191
1210
  query: query_path,
1192
1211
  mutation: mutation_path,
1193
1212
  add_query_type: [
@@ -1208,11 +1227,13 @@ end
1208
1227
  result = migrate class_name: class_name
1209
1228
  puts result[0][:model]
1210
1229
  puts result[0][:type]
1230
+ puts result[0][:resolver]
1211
1231
  puts result[0][:node_type]
1212
1232
  puts result[0][:rspec_factory]
1213
1233
  puts result[0][:rspec_model]
1214
1234
  puts result[0][:rspec_mutation]
1215
1235
  puts result[0][:rspec_query]
1236
+ puts result[0][:rspec_resolver]
1216
1237
  puts result[0][:query]
1217
1238
  puts result[0][:mutation]
1218
1239
 
@@ -1258,6 +1279,12 @@ end
1258
1279
  path[:type].each { |line| puts line }
1259
1280
  end
1260
1281
  end
1282
+ puts "\n============== Resolver =======================\n\n"
1283
+ paths.each do |class_name|
1284
+ class_name.each do |path|
1285
+ path[:resovler].each { |line| puts line }
1286
+ end
1287
+ end
1261
1288
  puts "\n============== NodeType =======================\n\n"
1262
1289
  paths.each do |class_name|
1263
1290
  class_name.each do |path|
@@ -1288,6 +1315,12 @@ end
1288
1315
  path[:rspec_query].each { |line| puts line }
1289
1316
  end
1290
1317
  end
1318
+ puts "\n============== RspecResolver =================\n\n"
1319
+ paths.each do |class_name|
1320
+ class_name.each do |path|
1321
+ path[:rspec_resolver].each { |line| puts line }
1322
+ end
1323
+ end
1291
1324
  puts "\n============== Query ======================\n\n"
1292
1325
  paths.each do |class_name|
1293
1326
  class_name.each do |path|
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.15.1"
2
+ VERSION = "0.15.6"
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.1
4
+ version: 0.15.6
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-12 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.