souls 0.13.8 → 0.13.9

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: f017a0b2dc2d05a5e78b857b3e437a931d976c0ab0b6c83625ee62f7109092b1
4
- data.tar.gz: 23bfc89940d3018c6626d38f4cef322829f224acd541100e92f696a3040155c9
3
+ metadata.gz: bbcbcf33c2d8228114814ed5964c6cca8aba01902b953908081fe83cd2a1bdbb
4
+ data.tar.gz: 449d4d9de9382a3887464ef61c90858bf46c0e20cfd25bd44eef3c5e278a0b8a
5
5
  SHA512:
6
- metadata.gz: c228b2dcf307527d6732a37e1b6f8694de43a1641e092a2cee49d1cf3a19595bd52581bb2842e0703e4316ca62335856e4e73960487a2be57dda3d632dd4c424
7
- data.tar.gz: 70b3e91e48d84161cf97210a8adc360c7266fafef31729a4e18eee2adad7470c0cfaa3c37e40ebca7dc9acac178208dac734d002e87fe93c52d0d6c57a8531b8
6
+ metadata.gz: 9241c9826bbd18c5d2d27501de5ce55236ecab6099949d0725fd3147028276cf98bec9f775278e263960e20c402a85d80368982d3a49141eae181eec1b0dc6a4
7
+ data.tar.gz: cfa3dbb3166216147d3e4cce41d2a0ee78c7c3b40ba74df241393b8b2e41c691cd0961a04e834f84d71ffd65ce78dc32f04d81188f2ffcd0365189ccdb27dacd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.13.7)
4
+ souls (0.13.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/souls/init.rb CHANGED
@@ -723,7 +723,6 @@ module Souls
723
723
  f.write <<~EOS
724
724
  RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
725
725
  describe "#{class_name.camelize} データを登録する" do
726
- get_global_key = proc {|class_name, id| Base64.encode64(\"\#{class_name}:\#{id}\")}
727
726
  EOS
728
727
  end
729
728
  end
@@ -739,17 +738,32 @@ module Souls
739
738
  f.each_line.with_index do |line, i|
740
739
  if @on
741
740
  if line.include?("end") || line.include?("t.index")
742
- new_line.write <<-EOS
741
+ if @relation_params.empty?
742
+ new_line.write <<-EOS
743
+ let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}) }
744
+
745
+ let(:mutation) do
746
+ %(mutation {
747
+ create#{class_name.camelize}(input: {
748
+ EOS
749
+ else
750
+ new_line.write <<-EOS
751
+
752
+ get_global_key = proc { |class_name, id| Base64.encode64(\"\#{class_name}:\#{id}\") }
743
753
  let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(", ")}) }
744
754
 
745
755
  let(:mutation) do
746
756
  %(mutation {
747
757
  create#{class_name.camelize}(input: {
748
- EOS
758
+ EOS
759
+ end
749
760
  break
750
761
  end
751
762
  _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
752
763
  case name
764
+ when "user_id"
765
+ relation_col = name.gsub("_id", "")
766
+ new_line.write " let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n"
753
767
  when /$*_id\z/
754
768
  relation_col = name.gsub("_id", "")
755
769
  @relation_params << "#{name}: get_global_key.call(\"#{name.singularize.camelize.gsub("Id", "")}\", #{relation_col}.id)"
@@ -789,7 +803,7 @@ module Souls
789
803
  else
790
804
  case type
791
805
  when "string", "text", "date", "datetime"
792
- if array_true && name != "tag"
806
+ if array_true
793
807
  new_line.write " #{name.pluralize.camelize(:lower)}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
794
808
  else
795
809
  new_line.write " #{name.singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
@@ -954,6 +968,18 @@ module Souls
954
968
  f.each_line.with_index do |line, i|
955
969
  if @on
956
970
  if line.include?("end") || line.include?("t.index")
971
+ if @relation_params.empty?
972
+ new_line.write <<-EOS
973
+ let(:#{class_name}) { FactoryBot.create(:#{class_name} }
974
+
975
+ let(:query) do
976
+ data_id = Base64.encode64("#{class_name.camelize}:\#{#{class_name.singularize.underscore}.id}")
977
+ %(query {
978
+ #{class_name.singularize.camelize(:lower)}(id: \\"\#{data_id}\\") {
979
+ id
980
+ EOS
981
+ break
982
+ else
957
983
  new_line.write <<-EOS
958
984
  let(:#{class_name}) { FactoryBot.create(:#{class_name}, #{@relation_params.join(", ")}) }
959
985
 
@@ -964,6 +990,7 @@ module Souls
964
990
  id
965
991
  EOS
966
992
  break
993
+ end
967
994
  end
968
995
  _, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
969
996
  case name
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.13.8"
2
+ VERSION = "0.13.9"
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.13.8
4
+ version: 0.13.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI