souls 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22daf35890d58a1d3ae94c4554bbde04d0ea51bc2a653ad2c0c1e7628fdf986f
4
- data.tar.gz: c23215bf1aa3d8e8bb2041eaa882bf962dd539a8e3fbc4ee4d0bf6a63839eb56
3
+ metadata.gz: d825fd34a0c8330fe7f2bb659061d47e5236f3026f3d48f2f47b53747dcecac2
4
+ data.tar.gz: 2e54fe6eb846ac78d53dc1cb5e4549e3af3f41fb2e8674477ac947e4563f8f55
5
5
  SHA512:
6
- metadata.gz: 0347e0819b7ff95322466e6fb0882d17b7fdb7e97c832926efadbf68356306cb3e4718029ffbb9f5b8df8f735c4f7dd45517ad91c9ba15561db9a3d841594c3f
7
- data.tar.gz: 23b1f76b4f35acf20bb72debff438249ea15efc663129de7758a50d2181e376e44675d0055def2d21088fe5d076841f95b2a90784a59f76055deb5cda21f6def
6
+ metadata.gz: a461d07f08c1c838ef6b532145e02bd1770fd689353a4e7ddb69ff176ee60573eca6079e8c1fa2831e19f393ed9c9451bf00db23b25629d5f31aa8222a0a1eb2
7
+ data.tar.gz: 837cad066a089928ab0f2b86eb42249eac6bc580c6e01eb70fc288f33bb82828efb3be26193ce7a2e17355efe6b20b5a5ceffd3c0e2c3eaf500c73727730e0e1
@@ -203,4 +203,6 @@ Style/DateTime:
203
203
  Enabled: false
204
204
  Layout/HeredocIndentation:
205
205
  Exclude:
206
- - "lib/souls/init.rb"
206
+ - "lib/souls/init.rb"
207
+ Style/RaiseArgs:
208
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.9.1)
4
+ souls (0.9.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/souls CHANGED
@@ -48,7 +48,7 @@ begin
48
48
  when "g", "generate"
49
49
  case ARGV[1]
50
50
  when "test"
51
- Souls::Init.delete_mutation class_name: "article"
51
+ Souls::Init.get_tables
52
52
  when "model"
53
53
  Souls::Init.model class_name: ARGV[2]
54
54
  when "mutation"
@@ -59,6 +59,10 @@ begin
59
59
  Souls::Init.type class_name: ARGV[2]
60
60
  when "migrate"
61
61
  Souls::Init.migration class_name: ARGV[2]
62
+ when "migrate_all"
63
+ Souls::Init.get_tables.each do |class_name|
64
+ Souls::Init.migration class_name: class_name
65
+ end
62
66
  when "migration"
63
67
  `rake db:create_migration NAME=#{ARGV[3]}`
64
68
  when "rspec_factory"
@@ -74,15 +78,16 @@ begin
74
78
  else
75
79
  end
76
80
  when "t", "test"
77
- `rubocop`
78
- `bundle exec rspec`
81
+ puts `rubocop`
82
+ puts `bundle exec rspec`
79
83
  when "deploy"
80
84
  project_id = Souls.configuration.project_id
81
85
  `gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
82
86
  else
83
- puts "Welcome to Souls!Yeah!"
87
+ puts "Welcome to SOULs!"
84
88
  end
85
89
  rescue StandardError => error
86
90
  puts error
87
- puts "Thank you!Souls!"
91
+ puts "Thank you!!"
92
+ puts "SOULs"
88
93
  end
@@ -2,6 +2,7 @@ require "souls/version"
2
2
  require "souls/init"
3
3
  require "json"
4
4
  require "active_support/core_ext/string/inflections"
5
+ require "fileutils"
5
6
 
6
7
  module Souls
7
8
  class Error < StandardError; end
@@ -284,20 +284,21 @@ module Souls
284
284
  end
285
285
 
286
286
  def create_mutation_head class_name: "souls"
287
- file_path = "./app/graphql/mutations/create_#{class_name}.rb"
287
+ file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
288
288
  File.open(file_path, "w") do |new_line|
289
289
  new_line.write <<~EOS
290
290
  module Mutations
291
- class Create#{class_name.camelize} < BaseMutation
292
- field :#{class_name}, Types::#{class_name.camelize}Type, null: false
293
- field :error, String, null: true
291
+ module #{class_name.camelize}
292
+ class Create#{class_name.camelize} < BaseMutation
293
+ field :#{class_name}, Types::#{class_name.camelize}Type, null: false
294
+ field :error, String, null: true
294
295
 
295
296
  EOS
296
297
  end
297
298
  end
298
299
 
299
300
  def create_mutation_params class_name: "souls"
300
- file_path = "./app/graphql/mutations/create_#{class_name}.rb"
301
+ file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
301
302
  path = "./db/schema.rb"
302
303
  @on = false
303
304
  File.open(file_path, "a") do |new_line|
@@ -311,7 +312,7 @@ module Souls
311
312
  when "created_at", "updated_at"
312
313
  next
313
314
  else
314
- new_line.write " argument :#{name}, #{field}, required: false\n"
315
+ new_line.write " argument :#{name}, #{field}, required: false\n"
315
316
  end
316
317
  end
317
318
  @on = true if table_check(line: line, class_name: class_name)
@@ -321,19 +322,20 @@ module Souls
321
322
  end
322
323
 
323
324
  def create_mutation_end class_name: "souls"
324
- file_path = "./app/graphql/mutations/create_#{class_name}.rb"
325
+ file_path = "./app/graphql/mutations/#{class_name}/create_#{class_name}.rb"
325
326
  File.open(file_path, "a") do |new_line|
326
327
  new_line.write <<~EOS
327
328
 
328
- def resolve **args
329
- #{class_name} = #{class_name.camelize}.new args
330
- if #{class_name}.save
331
- { #{class_name}: #{class_name} }
332
- else
333
- { error: #{class_name}.errors.full_messages }
329
+ def resolve **args
330
+ #{class_name} = #{class_name.camelize}.new args
331
+ if #{class_name}.save
332
+ { #{class_name}: #{class_name} }
333
+ else
334
+ { error: #{class_name}.errors.full_messages }
335
+ end
336
+ rescue StandardError => error
337
+ GraphQL::ExecutionError.new error
334
338
  end
335
- rescue StandardError => error
336
- GraphQL::ExecutionError.new error
337
339
  end
338
340
  end
339
341
  end
@@ -343,19 +345,20 @@ module Souls
343
345
  end
344
346
 
345
347
  def update_mutation_head class_name: "souls"
346
- file_path = "./app/graphql/mutations/update_#{class_name}.rb"
348
+ file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
347
349
  File.open(file_path, "w") do |new_line|
348
350
  new_line.write <<~EOS
349
351
  module Mutations
350
- class Update#{class_name.camelize} < BaseMutation
351
- field :#{class_name}, Types::#{class_name.camelize}Type, null: false
352
+ module #{class_name.camelize}
353
+ class Update#{class_name.camelize} < BaseMutation
354
+ field :#{class_name}, Types::#{class_name.camelize}Type, null: false
352
355
 
353
356
  EOS
354
357
  end
355
358
  end
356
359
 
357
360
  def update_mutation_params class_name: "souls"
358
- file_path = "./app/graphql/mutations/update_#{class_name}.rb"
361
+ file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
359
362
  path = "./db/schema.rb"
360
363
  @on = false
361
364
  File.open(file_path, "a") do |new_line|
@@ -369,7 +372,7 @@ module Souls
369
372
  when "created_at", "updated_at"
370
373
  next
371
374
  else
372
- new_line.write " argument :#{name}, #{field}, required: false\n"
375
+ new_line.write " argument :#{name}, #{field}, required: false\n"
373
376
  end
374
377
  end
375
378
  @on = true if table_check(line: line, class_name: class_name)
@@ -379,16 +382,17 @@ module Souls
379
382
  end
380
383
 
381
384
  def update_mutation_end class_name: "souls"
382
- file_path = "./app/graphql/mutations/update_#{class_name}.rb"
385
+ file_path = "./app/graphql/mutations/#{class_name}/update_#{class_name}.rb"
383
386
  File.open(file_path, "a") do |new_line|
384
387
  new_line.write <<~EOS
385
388
 
386
- def resolve **args
387
- #{class_name} = #{class_name.camelize}.find args[:id]
388
- #{class_name}.update args
389
- { #{class_name}: #{class_name.camelize}.find(args[:id]) }
390
- rescue StandardError => error
391
- GraphQL::ExecutionError.new error
389
+ def resolve **args
390
+ #{class_name} = #{class_name.camelize}.find args[:id]
391
+ #{class_name}.update args
392
+ { #{class_name}: #{class_name.camelize}.find(args[:id]) }
393
+ rescue StandardError => error
394
+ GraphQL::ExecutionError.new error
395
+ end
392
396
  end
393
397
  end
394
398
  end
@@ -404,20 +408,22 @@ module Souls
404
408
  end
405
409
 
406
410
  def delete_mutation class_name: "souls"
407
- file_path = "./app/graphql/mutations/delete_#{class_name}.rb"
411
+ file_path = "./app/graphql/mutations/#{class_name}/delete_#{class_name}.rb"
408
412
  File.open(file_path, "w") do |f|
409
413
  f.write <<~EOS
410
414
  module Mutations
411
- class Delete#{class_name.camelize} < BaseMutation
412
- field :#{class_name}, Types::#{class_name.camelize}Type, null: false
413
- argument :id, Integer, required: true
414
-
415
- def resolve id:
416
- #{class_name} = #{class_name.camelize}.find id
417
- #{class_name}.destroy
418
- { #{class_name}: #{class_name} }
419
- rescue StandardError => error
420
- GraphQL::ExecutionError.new error
415
+ module #{class_name.camelize}
416
+ class Delete#{class_name.camelize} < BaseMutation
417
+ field :#{class_name}, Types::#{class_name.camelize}Type, null: false
418
+ argument :id, Integer, required: true
419
+
420
+ def resolve id:
421
+ #{class_name} = #{class_name.camelize}.find id
422
+ #{class_name}.destroy
423
+ { #{class_name}: #{class_name} }
424
+ rescue StandardError => error
425
+ GraphQL::ExecutionError.new error
426
+ end
421
427
  end
422
428
  end
423
429
  end
@@ -426,13 +432,32 @@ module Souls
426
432
  puts "Mutation create_#{class_name}.rb Auto Generated from schema.rb!: `#{file_path}`"
427
433
  end
428
434
 
435
+ def create_confirm
436
+ puts "Directory already exists, Overwrite?? (Y/N)"
437
+ input = STDIN.gets.chomp
438
+ return true if input == "Y"
439
+ raise StandardError.new "Directory Already Exist!"
440
+ end
441
+
429
442
  def mutation class_name: "souls"
430
443
  singularized_class_name = class_name.singularize
444
+ if Dir.exist? "./app/graphql/mutations/#{singularized_class_name}"
445
+ create_confirm
446
+ FileUtils.rm_r("./app/graphql/mutations/#{singularized_class_name}")
447
+ end
448
+ Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
431
449
  create_mutation_head class_name: singularized_class_name
432
450
  create_mutation_params class_name: singularized_class_name
433
451
  create_mutation_end class_name: singularized_class_name
434
452
  update_mutation class_name: singularized_class_name
435
453
  delete_mutation class_name: singularized_class_name
454
+ puts "\n#############################################################################################################"
455
+ puts "\nAdd these lines at `./app/graphql/types/mutation_type.rb`"
456
+ puts "\n\n"
457
+ puts "field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}"
458
+ puts "field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}"
459
+ puts "field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
460
+ puts "\n\n#############################################################################################################"
436
461
  end
437
462
 
438
463
  def create_query class_name: "souls"
@@ -480,6 +505,12 @@ module Souls
480
505
  singularized_class_name = class_name.singularize
481
506
  create_query class_name: singularized_class_name
482
507
  create_queries class_name: singularized_class_name
508
+ puts "\n#############################################################################################################"
509
+ puts "\nAdd these lines at `./app/graphql/types/query_type.rb`"
510
+ puts "\n\n"
511
+ puts "field :#{singularized_class_name}, resolber: Queries::#{singularized_class_name.camelize}"
512
+ puts "field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
513
+ puts "\n\n#############################################################################################################"
483
514
  end
484
515
 
485
516
  def create_type_head class_name: "souls"
@@ -623,6 +654,17 @@ module Souls
623
654
  end
624
655
  end
625
656
 
657
+ def get_tables
658
+ path = "./db/schema.rb"
659
+ tables = []
660
+ File.open(path, "r") do |f|
661
+ f.each_line.with_index do |line, i|
662
+ tables << line.split("\"")[1] if line.include?("create_table")
663
+ end
664
+ end
665
+ tables
666
+ end
667
+
626
668
  def add_mutation_type class_name: "souls"
627
669
  # let's do this later
628
670
  end
@@ -632,13 +674,13 @@ module Souls
632
674
  end
633
675
 
634
676
  def migration class_name: "souls"
635
- `rake db:migrate`
677
+ # `rake db:migrate`
636
678
  model class_name: class_name
637
- mutation class_name: class_name
638
- query class_name: class_name
639
679
  type class_name: class_name
640
680
  rspec_factory class_name: class_name
641
681
  rspec_model class_name: class_name
682
+ query class_name: class_name
683
+ mutation class_name: class_name
642
684
  end
643
685
  end
644
686
  end
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
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.9.3
4
+ version: 0.9.4
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-01-21 00:00:00.000000000 Z
13
+ date: 2021-01-22 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.