souls 0.8.9 → 0.9.4

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: a805d220db3a397f804739f3e1b23bd78b77e1ca23953abbf1b88a473a818967
4
- data.tar.gz: b780848b2039100bccfd3afecec4b4bebe2a0656e7bd5e978f1aa553fddeb082
3
+ metadata.gz: d825fd34a0c8330fe7f2bb659061d47e5236f3026f3d48f2f47b53747dcecac2
4
+ data.tar.gz: 2e54fe6eb846ac78d53dc1cb5e4549e3af3f41fb2e8674477ac947e4563f8f55
5
5
  SHA512:
6
- metadata.gz: 815c4d0fbfc43dd9844e8d995a667b52fcda667e1379be448a75ba70024a6c9ccae2efcb4059ecc713bf0a903a64e1b3cea3ad739807105b0a8299dda3714114
7
- data.tar.gz: d7799896e331fcc85c6c33f66fc2890651b6933c046bb85f6d26396e62654dc16833c04c97ff52a9cb67745d8f7a62830750c1527aecafa71ccd1125d8ce73a1
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
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gem "activesupport", "6.1.0"
7
7
  gem "rake", "13.0.3"
8
8
  gem "rspec", "3.1.0"
9
9
  gem "steep", "0.39.0"
10
+ gem "rubocop", "1.7.0"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.8.8)
4
+ souls (0.9.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -26,6 +26,7 @@ GEM
26
26
  rb-fsevent (~> 0.10, >= 0.10.3)
27
27
  rb-inotify (~> 0.9, >= 0.9.10)
28
28
  minitest (5.14.2)
29
+ parallel (1.20.1)
29
30
  parser (2.7.2.0)
30
31
  ast (~> 2.4.1)
31
32
  rainbow (3.0.0)
@@ -34,6 +35,8 @@ GEM
34
35
  rb-inotify (0.10.1)
35
36
  ffi (~> 1.0)
36
37
  rbs (1.0.0)
38
+ regexp_parser (2.0.3)
39
+ rexml (3.2.4)
37
40
  rspec (3.1.0)
38
41
  rspec-core (~> 3.1.0)
39
42
  rspec-expectations (~> 3.1.0)
@@ -46,6 +49,18 @@ GEM
46
49
  rspec-mocks (3.1.3)
47
50
  rspec-support (~> 3.1.0)
48
51
  rspec-support (3.1.2)
52
+ rubocop (1.7.0)
53
+ parallel (~> 1.10)
54
+ parser (>= 2.7.1.5)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8, < 3.0)
57
+ rexml
58
+ rubocop-ast (>= 1.2.0, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 2.0)
61
+ rubocop-ast (1.4.0)
62
+ parser (>= 2.7.1.5)
63
+ ruby-progressbar (1.11.0)
49
64
  steep (0.39.0)
50
65
  activesupport (>= 5.1)
51
66
  ast_utils (~> 0.3.0)
@@ -57,6 +72,7 @@ GEM
57
72
  thor (1.0.1)
58
73
  tzinfo (2.0.4)
59
74
  concurrent-ruby (~> 1.0)
75
+ unicode-display_width (1.7.0)
60
76
  zeitwerk (2.4.2)
61
77
 
62
78
  PLATFORMS
@@ -66,6 +82,7 @@ DEPENDENCIES
66
82
  activesupport (= 6.1.0)
67
83
  rake (= 13.0.3)
68
84
  rspec (= 3.1.0)
85
+ rubocop (= 1.7.0)
69
86
  souls!
70
87
  steep (= 0.39.0)
71
88
 
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,22 +78,16 @@ begin
74
78
  else
75
79
  end
76
80
  when "t", "test"
77
- case ARGV[1]
78
- when "-r"
79
- `bundle exec rspec`
80
- when "-s"
81
- `bundle exec steep check`
82
- else
83
- `bundle exec steep check`
84
- `bundle exec rspec`
85
- end
81
+ puts `rubocop`
82
+ puts `bundle exec rspec`
86
83
  when "deploy"
87
84
  project_id = Souls.configuration.project_id
88
85
  `gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
89
86
  else
90
- puts "Welcome to Souls!Yeah!"
87
+ puts "Welcome to SOULs!"
91
88
  end
92
89
  rescue StandardError => error
93
90
  puts error
94
- puts "Thank you!Souls!"
91
+ puts "Thank you!!"
92
+ puts "SOULs"
95
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,12 +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
- create_mutation_head class_name: class_name
431
- create_mutation_params class_name: class_name
432
- create_mutation_end class_name: class_name
433
- update_mutation class_name: class_name
434
- delete_mutation class_name: class_name
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}"
449
+ create_mutation_head class_name: singularized_class_name
450
+ create_mutation_params class_name: singularized_class_name
451
+ create_mutation_end class_name: singularized_class_name
452
+ update_mutation class_name: singularized_class_name
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#############################################################################################################"
435
461
  end
436
462
 
437
463
  def create_query class_name: "souls"
@@ -476,8 +502,15 @@ module Souls
476
502
  end
477
503
 
478
504
  def query class_name: "souls"
479
- create_query class_name: class_name
480
- create_queries class_name: class_name
505
+ singularized_class_name = class_name.singularize
506
+ create_query class_name: singularized_class_name
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#############################################################################################################"
481
514
  end
482
515
 
483
516
  def create_type_head class_name: "souls"
@@ -526,9 +559,10 @@ module Souls
526
559
  end
527
560
 
528
561
  def type class_name: "souls"
529
- create_type_head class_name: class_name
530
- create_type_params class_name: class_name
531
- create_type_end class_name: class_name
562
+ singularized_class_name = class_name.singularize
563
+ create_type_head class_name: singularized_class_name
564
+ create_type_params class_name: singularized_class_name
565
+ create_type_end class_name: singularized_class_name
532
566
  end
533
567
 
534
568
  def rspec_factory_head class_name: "souls"
@@ -574,9 +608,10 @@ module Souls
574
608
  end
575
609
 
576
610
  def rspec_factory class_name: "souls"
577
- rspec_factory_head class_name: class_name
578
- rspec_factory_params class_name: class_name
579
- rspec_factory_end class_name: class_name
611
+ singularized_class_name = class_name.singularize
612
+ rspec_factory_head class_name: singularized_class_name
613
+ rspec_factory_params class_name: singularized_class_name
614
+ rspec_factory_end class_name: singularized_class_name
580
615
  end
581
616
 
582
617
  def rspec_model class_name: "souls"
@@ -619,6 +654,17 @@ module Souls
619
654
  end
620
655
  end
621
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
+
622
668
  def add_mutation_type class_name: "souls"
623
669
  # let's do this later
624
670
  end
@@ -630,11 +676,11 @@ module Souls
630
676
  def migration class_name: "souls"
631
677
  # `rake db:migrate`
632
678
  model class_name: class_name
633
- mutation class_name: class_name
634
- query class_name: class_name
635
679
  type class_name: class_name
636
680
  rspec_factory class_name: class_name
637
681
  rspec_model class_name: class_name
682
+ query class_name: class_name
683
+ mutation class_name: class_name
638
684
  end
639
685
  end
640
686
  end
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.8.9"
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.8.9
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.