souls 0.9.7 → 0.10.3

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: 889a302559758a12cf2318206787f3848ca961cee8505218ff0414c797fd3f48
4
- data.tar.gz: 9cc808cb6af449c3330b6fa67e559875621c3f45ab7268f1c65e3c3d1a8be0ad
3
+ metadata.gz: fe9369434a6abecbc1cb289ea7aac653a0e3b91db733b3a36db61315d1d74ad2
4
+ data.tar.gz: 7e87da0f68519dc5b1c1d275a252386162aba25357a53c80e045603ec99363fd
5
5
  SHA512:
6
- metadata.gz: b2d55d3e5bee86ae7b31fda1261c0c64be8dc1280bb253de49f5080adf396c378802b11ae07b0da4c08c13e22762850fb63d16c79ecabfa1f1d3c80c30c98805
7
- data.tar.gz: f1f6c88288d458ee6c2125d0b2675dbeee6763300464018f97a55573f83bc53c6633a2e8b0237d19bf70e4ecd7d2290a042121d33261256fc2132bee0519b1e6
6
+ metadata.gz: ce2e507855c02c4035afd03626d49a294f65d70ee67f6f789e89e77dc2af839ab407a5ec4e10971b7047305551503e4bf7aca56a1fe4aed8b03709542ab48cd7
7
+ data.tar.gz: edbb59b6dec323d14247ff441a7e4bf4ad4aba340f5a2ab30c1ddf29f24ed38833edc5d1625747e8baeadc420e084a629953c610c83396a515438b9d13c44f65
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.9.6)
4
+ souls (0.10.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/souls CHANGED
@@ -76,8 +76,8 @@ begin
76
76
  else
77
77
  end
78
78
  when "t", "test"
79
- puts `rubocop`
80
- puts `bundle exec rspec`
79
+ `rubocop`
80
+ `bundle exec rspec`
81
81
  when "deploy"
82
82
  project_id = Souls.configuration.project_id
83
83
  `gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
@@ -244,7 +244,7 @@ module Souls
244
244
  end
245
245
 
246
246
  def model class_name: "souls"
247
- file_path = "./app/models/#{class_name}.rb"
247
+ file_path = "./app/models/#{class_name.singularize}.rb"
248
248
  File.open(file_path, "w") do |f|
249
249
  f.write <<~EOS
250
250
  class #{class_name.camelize} < ActiveRecord::Base
@@ -261,6 +261,7 @@ module Souls
261
261
  float: "Float",
262
262
  text: "String",
263
263
  datetime: "GraphQL::Types::ISO8601DateTime",
264
+ date: "GraphQL::Types::ISO8601DateTime",
264
265
  boolean: "Boolean",
265
266
  integer: "Integer"
266
267
  }[type.to_sym]
@@ -273,6 +274,7 @@ module Souls
273
274
  string: '"MyString"',
274
275
  text: '"MyString"',
275
276
  datetime: "Time.now",
277
+ date: "Time.now",
276
278
  boolean: false,
277
279
  integer: 1
278
280
  }[type.to_sym]
@@ -330,7 +332,7 @@ module Souls
330
332
  new_line.write <<~EOS
331
333
 
332
334
  def resolve **args
333
- #{class_name} = #{class_name.camelize}.new args
335
+ #{class_name} = ::#{class_name.camelize}.new args
334
336
  if #{class_name}.save
335
337
  { #{class_name}: #{class_name} }
336
338
  else
@@ -391,9 +393,9 @@ module Souls
391
393
  new_line.write <<~EOS
392
394
 
393
395
  def resolve **args
394
- #{class_name} = #{class_name.camelize}.find args[:id]
396
+ #{class_name} = ::#{class_name.camelize}.find args[:id]
395
397
  #{class_name}.update args
396
- { #{class_name}: #{class_name.camelize}.find(args[:id]) }
398
+ { #{class_name}: ::#{class_name.camelize}.find(args[:id]) }
397
399
  rescue StandardError => error
398
400
  GraphQL::ExecutionError.new error
399
401
  end
@@ -422,7 +424,7 @@ module Souls
422
424
  argument :id, Integer, required: true
423
425
 
424
426
  def resolve id:
425
- #{class_name} = #{class_name.camelize}.find id
427
+ #{class_name} = ::#{class_name.camelize}.find id
426
428
  #{class_name}.destroy
427
429
  { #{class_name}: #{class_name} }
428
430
  rescue StandardError => error
@@ -436,20 +438,20 @@ module Souls
436
438
  file_path
437
439
  end
438
440
 
439
- def create_confirm
440
- puts "Directory already exists, Overwrite?? (Y/N)"
441
+ def create_confirm dir_path: ""
442
+ puts "Directory already exists, Overwrite?? (Y/N)\n#{dir_path}"
441
443
  input = STDIN.gets.chomp
442
444
  return true if input == "Y"
443
- raise StandardError.new "Directory Already Exist!"
445
+ raise StandardError.new "Directory Already Exist!\n#{dir_path}"
444
446
  end
445
447
 
446
448
  def mutation class_name: "souls"
447
449
  singularized_class_name = class_name.singularize
448
450
  if Dir.exist? "./app/graphql/mutations/#{singularized_class_name}"
449
- # create_confirm
450
- FileUtils.rm_r("./app/graphql/mutations/#{singularized_class_name}")
451
+ create_confirm dir_path: "./app/graphql/mutations/#{singularized_class_name}"
452
+ else
453
+ Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
451
454
  end
452
- Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
453
455
  create_mutation_head class_name: singularized_class_name
454
456
  create_mutation_params class_name: singularized_class_name
455
457
  [
@@ -526,8 +528,9 @@ module Souls
526
528
  f.each_line.with_index do |line, i|
527
529
  if @on
528
530
  new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
531
+ field = "[String]" if line.include?("array: true")
529
532
  type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
530
- field = type_check type
533
+ field ||= type_check type
531
534
  new_line.write " field :#{name}, #{field}, null: true\n"
532
535
  end
533
536
  if table_check(line: line, class_name: class_name)
@@ -576,8 +579,9 @@ module Souls
576
579
  f.each_line.with_index do |line, i|
577
580
  if @on
578
581
  new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
582
+ field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
579
583
  type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
580
- field = get_test_type type
584
+ field ||= get_test_type type
581
585
  new_line.write " #{name} { #{field} }\n"
582
586
  end
583
587
  if table_check(line: line, class_name: class_name)
@@ -612,12 +616,7 @@ module Souls
612
616
  f.write <<~EOS
613
617
  RSpec.describe #{class_name.camelize}, type: :model do
614
618
  it "作成する" do
615
- expect(FactoryBot.build(:#{class_name})).to be_valid
616
- end
617
-
618
- it "同じtitleがあると作成できない" do
619
- FactoryBot.build(:#{class_name}, title: "hey")
620
- expect(FactoryBot.build(:#{class_name}, title: "hey")).to be_valid
619
+ expect(FactoryBot.build(:#{class_name.singularize})).to be_valid
621
620
  end
622
621
  end
623
622
  EOS
@@ -666,7 +665,6 @@ module Souls
666
665
  end
667
666
 
668
667
  def migrate class_name: "souls"
669
- # `rake db:migrate`
670
668
  singularized_class_name = class_name.singularize
671
669
  model_paths = model class_name: singularized_class_name
672
670
  type_paths = type class_name: singularized_class_name
@@ -682,21 +680,22 @@ module Souls
682
680
  query: query_path,
683
681
  mutation: mutation_path,
684
682
  add_query_type: [
685
- "field :#{singularized_class_name}, resolver: Queries::#{singularized_class_name.camelize}",
686
- "field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
683
+ " field :#{singularized_class_name}, resolver: Queries::#{singularized_class_name.camelize}",
684
+ " field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
687
685
  ],
688
686
  add_mutation_type: [
689
- "field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}",
690
- "field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}",
691
- "field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
687
+ " field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}",
688
+ " field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}",
689
+ " field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
692
690
  ]
693
691
  ]
694
692
  end
695
693
 
696
694
  def migrate_all
697
695
  puts "◆◆◆ Let's Auto Generate CRUD API ◆◆◆\n"
696
+ `rake db:migrate`
698
697
  paths = get_tables.map do |class_name|
699
- migrate class_name: class_name
698
+ migrate class_name: class_name.singularize
700
699
  end
701
700
  puts "\n============== Model ======================\n\n"
702
701
  paths.each do |class_name|
@@ -746,6 +745,12 @@ module Souls
746
745
  path[:add_query_type].each { |line| puts line }
747
746
  end
748
747
  end
748
+ puts "\n ## Connection Type\n\n"
749
+ get_tables.each do |class_name|
750
+ puts " def #{class_name.pluralize}"
751
+ puts " #{class_name.camelize}.all.order(id: :desc)"
752
+ puts " end\n\n"
753
+ end
749
754
  puts "\n#############################################################\n"
750
755
  puts "# #\n"
751
756
  puts "# Add These Lines at ./app/graphql/types/mutation_type.rb #\n"
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.9.7"
2
+ VERSION = "0.10.3"
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.7
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI