souls 0.15.0 → 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: 7c22359f9bf2b95ffa6147f13daba5698613b367eb65e20255eeb8c62b6443fd
4
- data.tar.gz: 91aa8fdc875ffa24adf86a6c08e9b9549c8230af74c4451bf0a0566a1f83fc15
3
+ metadata.gz: e72a21841cb1bad148b2b4fb2c9b6fc01fe55bf3b369bfb3aaf71df1393bd34f
4
+ data.tar.gz: 1e60f71a7d2ad5734d7f8a6f18cca6b437148c7f4f9d08145fe5eddef81be639
5
5
  SHA512:
6
- metadata.gz: 5bf1f4a6d0b57d67305ef55b14508c3f977a494cc7e9c5e4a66f6c7b157428863a99aa279647a2a27785836b1771b82604fe6c30acfff9e30ca02b299fcbb5a9
7
- data.tar.gz: c2b05ea81adcbffaaf08c80147c30aadc6f3393937b52a22577f73e50cfb89752729546251c35f212a75d7df75d8a99dc8dd7523a54a71588284d5b63c513d30
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.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,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,6 +724,7 @@ module Souls
724
724
  end
725
725
 
726
726
  def rspec_factory class_name: "souls"
727
+ return ["Aleady Exist!"] if File.exist? "./spec/factories/#{class_name.singularize}"
727
728
  singularized_class_name = class_name.singularize
728
729
  rspec_factory_head class_name: singularized_class_name
729
730
  rspec_factory_params class_name: singularized_class_name
@@ -732,6 +733,7 @@ module Souls
732
733
 
733
734
  def rspec_model class_name: "souls"
734
735
  file_path = "./spec/models/#{class_name}_spec.rb"
736
+ return ["Aleady Exist!"] if File.exist? file_path
735
737
  File.open(file_path, "w") do |f|
736
738
  f.write <<~EOS
737
739
  RSpec.describe "#{class_name.camelize} Model テスト", type: :model do
@@ -885,6 +887,7 @@ module Souls
885
887
  EOS
886
888
  else
887
889
  new_line.write <<-EOS
890
+ }
888
891
  }
889
892
  }
890
893
  }
@@ -931,13 +934,13 @@ module Souls
931
934
  File.open(file_path, "a") do |new_line|
932
935
  File.open(path, "r") do |f|
933
936
  f.each_line.with_index do |line, i|
934
- if @on
937
+ if @on
935
938
  if line.include?("end") || line.include?("t.index")
936
939
  new_line.write <<~EOS
937
- )
938
- end
939
- end
940
+ )
940
941
  end
942
+ end
943
+ end
941
944
  EOS
942
945
  break
943
946
  end
@@ -1048,7 +1051,7 @@ module Souls
1048
1051
  File.open(file_path, "a") do |new_line|
1049
1052
  File.open(path, "r") do |f|
1050
1053
  f.each_line.with_index do |line, i|
1051
- if @on
1054
+ if @on
1052
1055
  if line.include?("end") || line.include?("t.index")
1053
1056
  new_line.write <<-EOS
1054
1057
  }
@@ -1090,13 +1093,13 @@ module Souls
1090
1093
  File.open(file_path, "a") do |new_line|
1091
1094
  File.open(path, "r") do |f|
1092
1095
  f.each_line.with_index do |line, i|
1093
- if @on
1096
+ if @on
1094
1097
  if line.include?("end") || line.include?("t.index")
1095
- new_line.write <<-EOS
1096
- )
1097
- end
1098
- end
1099
- end
1098
+ new_line.write <<~EOS
1099
+ )
1100
+ end
1101
+ end
1102
+ end
1100
1103
  EOS
1101
1104
  break
1102
1105
  end
@@ -1171,20 +1174,24 @@ end
1171
1174
  model_paths = model class_name: singularized_class_name
1172
1175
  type_paths = type class_name: singularized_class_name
1173
1176
  node_type_paths = node_type class_name: singularized_class_name
1177
+ resolver_paths = resolver class_name: singularized_class_name
1174
1178
  rspec_factory_paths = rspec_factory class_name: singularized_class_name
1175
1179
  rspec_model_paths = rspec_model class_name: singularized_class_name
1176
1180
  rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
1177
1181
  rspec_query_paths = rspec_query class_name: singularized_class_name
1182
+ rspec_resolver_paths = rspec_resolver class_name: singularized_class_name
1178
1183
  query_path = query class_name: singularized_class_name
1179
1184
  mutation_path = mutation class_name: singularized_class_name
1180
1185
  [
1181
1186
  model: model_paths,
1182
1187
  type: type_paths,
1188
+ resolver: resolver_paths,
1183
1189
  node_type: node_type_paths,
1184
1190
  rspec_factory: rspec_factory_paths,
1185
1191
  rspec_model: rspec_model_paths,
1186
1192
  rspec_mutation: rspec_mutation_paths,
1187
1193
  rspec_query: rspec_query_paths,
1194
+ rspec_resolver: rspec_resolver_paths,
1188
1195
  query: query_path,
1189
1196
  mutation: mutation_path,
1190
1197
  add_query_type: [
@@ -1205,11 +1212,13 @@ end
1205
1212
  result = migrate class_name: class_name
1206
1213
  puts result[0][:model]
1207
1214
  puts result[0][:type]
1215
+ puts result[0][:resolver]
1208
1216
  puts result[0][:node_type]
1209
1217
  puts result[0][:rspec_factory]
1210
1218
  puts result[0][:rspec_model]
1211
1219
  puts result[0][:rspec_mutation]
1212
1220
  puts result[0][:rspec_query]
1221
+ puts result[0][:rspec_resolver]
1213
1222
  puts result[0][:query]
1214
1223
  puts result[0][:mutation]
1215
1224
 
@@ -1255,6 +1264,12 @@ end
1255
1264
  path[:type].each { |line| puts line }
1256
1265
  end
1257
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
1258
1273
  puts "\n============== NodeType =======================\n\n"
1259
1274
  paths.each do |class_name|
1260
1275
  class_name.each do |path|
@@ -1285,6 +1300,12 @@ end
1285
1300
  path[:rspec_query].each { |line| puts line }
1286
1301
  end
1287
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
1288
1309
  puts "\n============== Query ======================\n\n"
1289
1310
  paths.each do |class_name|
1290
1311
  class_name.each do |path|
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.15.0"
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.0
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-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.
@@ -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