souls 0.16.3 → 0.16.8

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: 95c7d5667fa4486a23b0feb0cd5f394baaf90940b9926afde3ac6f28aecff6d9
4
- data.tar.gz: cc1486ff2c54dc5050e1f190fa0dd7ddac28db4f3c1e849013aee46d6a8ee686
3
+ metadata.gz: '09d37b12a50b54d68e40410a8c69b930cc091553515f735df7575fa6daa88abb'
4
+ data.tar.gz: 770c7f445b61f046d1a2a166004dd4c4e42272aab1192636a4596db0753cb316
5
5
  SHA512:
6
- metadata.gz: 9cb1991fa03238cc123023aed9e147b97f978138cb1f3bd0560fa652dabe4af39379e22f38fea51d5de17817eadb5e050309fec5c4d5acbd14801a828ed981bc
7
- data.tar.gz: 70284bcb318f210b8b1010d03c70c65e13b966dd25b0801e531a68e4f18674b37eb41bb9ff9f9e2e83f09be76f72fb578c41da790d0c3ee9284225571c53e16b
6
+ metadata.gz: d15a89dae81309eeaacee343f636ab4fef4cf04ddc7a287a5ba9fd76e094a9a89c48ad6c42feee91a2f3c70ff09979eecfbf4d63ec882d01d970bc9340047410
7
+ data.tar.gz: 56c5ec546f7e536bbf72b87bba895b292a1b79daebceb2b4037a97729cc8f9c4a91736449872943c1cde940eb829b5087423f18399e649c0272ec9979bf24106
data/.rubocop.yml CHANGED
@@ -79,6 +79,7 @@ Style/HashSyntax:
79
79
  - "**/*.rake"
80
80
  - "Rakefile"
81
81
 
82
+
82
83
  Style/IfUnlessModifier:
83
84
  Enabled: false
84
85
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.16.3)
4
+ souls (0.16.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/souls CHANGED
@@ -33,7 +33,12 @@ begin
33
33
  when "media", "admin"
34
34
  system "yarn dev"
35
35
  else
36
- system "bundle exec irb"
36
+ case ARGV[1]
37
+ when "RACK_ENV=production"
38
+ system "bundle exec irb RACK_ENV=production"
39
+ else
40
+ system "bundle exec irb"
41
+ end
37
42
  end
38
43
  when "i", "infra"
39
44
  Souls.send ARGV[1]
@@ -43,6 +48,21 @@ begin
43
48
  Souls::Init.config_init
44
49
  when "-v", "--version"
45
50
  puts Souls::VERSION
51
+ when "add"
52
+ case ARGV[1]
53
+ when "mutation"
54
+ Souls::Init.add_mutation class_name: "user", file_name: "hoi"
55
+ when "type"
56
+ Souls::Init.add_type class_name: "user", file_name: "hoi"
57
+ when "connection"
58
+ Souls::Init.add_connection class_name: "user", file_name: "hoi"
59
+ when "edge"
60
+ Souls::Init.add_edge class_name: "user", file_name: "hoi"
61
+ when "rspec_mutation"
62
+ Souls::Init.add_rspec_mutation class_name: "user", file_name: "hoi"
63
+ else
64
+ puts "HOI!"
65
+ end
46
66
  when "g", "generate"
47
67
  case ARGV[1]
48
68
  when "test_dir"
@@ -87,11 +107,21 @@ begin
87
107
  when "db:create"
88
108
  system "rake db:create && rake db:create RACK_ENV=test"
89
109
  when "db:migrate"
90
- system "rake db:migrate && rake db:migrate RACK_ENV=test"
110
+ case ARGV[1]
111
+ when "RACK_ENV=production"
112
+ system "rake db:migrate RACK_ENV=production"
113
+ else
114
+ system "rake db:migrate && rake db:migrate RACK_ENV=test"
115
+ end
91
116
  when "db:seed"
92
117
  system "rake db:seed"
93
118
  when "db:migrate:reset"
94
- system "rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test"
119
+ case ARGV[1]
120
+ when "RACK_ENV=production"
121
+ system "rake db:migrate:reset RACK_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1"
122
+ else
123
+ system "rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test"
124
+ end
95
125
  when "t", "test"
96
126
  system "rubocop -a"
97
127
  system "bundle exec rspec"
@@ -1,6 +1,10 @@
1
1
  module Souls
2
2
  module Init
3
3
  class << self
4
+ def get_type_and_name line
5
+ line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
6
+ end
7
+
4
8
  def node_type class_name: "souls"
5
9
  file_path = "./app/graphql/types/#{class_name.singularize}_node_type.rb"
6
10
  File.open(file_path, "w") do |f|
@@ -15,9 +19,10 @@ module Souls
15
19
  [file_path]
16
20
  end
17
21
 
18
- def resolver class_name: "souls"
22
+ def resolver_head class_name: "souls"
19
23
  FileUtils.mkdir_p "./app/graphql/resolvers" unless Dir.exist? "./app/graphql/resolvers"
20
24
  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
25
+ @relation_params = []
21
26
  return ["Resolver already exist! #{file_path}"] if File.exist? file_path
22
27
  File.open(file_path, "w") do |f|
23
28
  f.write <<~EOS
@@ -30,63 +35,145 @@ module Souls
30
35
 
31
36
  class #{class_name.camelize}Filter < ::Types::BaseInputObject
32
37
  argument :OR, [self], required: false
38
+ EOS
39
+ end
40
+ end
33
41
 
34
- argument :is_deleted, Boolean, required: false
35
- argument :start_date, String, required: false
36
- argument :end_date, String, required: false
42
+ def resolver_params class_name: "souls"
43
+ file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
44
+ path = "./db/schema.rb"
45
+ @on = false
46
+ @user_exist = false
47
+ @relation_params = []
48
+ File.open(file_path, "a") do |new_line|
49
+ File.open(path, "r") do |f|
50
+ f.each_line.with_index do |line, i|
51
+ if @on
52
+ if line.include?("end") || line.include?("t.index")
53
+ break
54
+ end
55
+ field = "[String]" if line.include?("array: true")
56
+ type, name = get_type_and_name(line)
57
+ field ||= type_check type
58
+ case name
59
+ when "user_id"
60
+ @user_exist = true
61
+ when /$*_id\z/
62
+ @relation_params << name
63
+ new_line.write " argument :#{name}, String, required: false\n"
64
+ when "created_at", "updated_at"
65
+ next
66
+ else
67
+ new_line.write " argument :#{name}, #{field}, required: false\n"
37
68
  end
69
+ end
70
+ @on = true if table_check(line: line, class_name: class_name)
71
+ end
72
+ end
73
+ end
74
+ end
38
75
 
39
- option :filter, type: #{class_name.camelize}Filter, with: :apply_filter
40
- option :first, type: types.Int, with: :apply_first
41
- option :skip, type: types.Int, with: :apply_skip
76
+ def resolver_after_params class_name: "souls"
77
+ file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
78
+ File.open(file_path, "a") do |f|
79
+ f.write <<-EOS
80
+ argument :is_deleted, Boolean, required: false
81
+ argument :start_date, String, required: false
82
+ argument :end_date, String, required: false
83
+ end
42
84
 
43
- def apply_filter(scope, value)
44
- branches = normalize_filters(value).inject { |a, b| a.or(b) }
45
- scope.merge branches
46
- end
85
+ option :filter, type: #{class_name.camelize}Filter, with: :apply_filter
86
+ option :first, type: types.Int, with: :apply_first
87
+ option :skip, type: types.Int, with: :apply_skip
47
88
 
48
- def apply_first(scope, value)
49
- scope.limit(value)
50
- end
89
+ def apply_filter(scope, value)
90
+ branches = normalize_filters(value).inject { |a, b| a.or(b) }
91
+ scope.merge branches
92
+ end
51
93
 
52
- def apply_skip(scope, value)
53
- scope.offset(value)
54
- end
94
+ def normalize_filters(value, branches = [])
95
+ scope = ::#{class_name.camelize}.all
96
+ EOS
97
+ end
98
+ end
55
99
 
56
- def decode_global_key id
57
- _, data_id = SoulsApiSchema.from_global_id id
58
- data_id
100
+ def resolver_before_end class_name: "souls"
101
+ file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
102
+ path = "./db/schema.rb"
103
+ @on = false
104
+ @user_exist = false
105
+ @relation_params = []
106
+ File.open(file_path, "a") do |new_line|
107
+ File.open(path, "r") do |f|
108
+ f.each_line.with_index do |line, i|
109
+ if @on
110
+ if line.include?("end") || line.include?("t.index")
111
+ break
59
112
  end
113
+ type, name = get_type_and_name(line)
114
+ if line.include?("array: true")
115
+ new_line.write " scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
116
+ next
117
+ end
118
+ case name
119
+ when "user_id"
120
+ @user_exist = true
121
+ when /$*_id\z/
122
+ @relation_params << name
123
+ new_line.write " scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n"
124
+ when "created_at", "updated_at"
125
+ next
126
+ else
127
+ case type
128
+ when "boolean"
129
+ new_line.write " scope = scope.where(#{name}: value[:#{name}]) unless value[:#{name}].nil?\n"
130
+ else
131
+ new_line.write " scope = scope.where(#{name}: value[:#{name}]) if value[:#{name}]\n"
132
+ end
133
+ end
134
+ end
135
+ @on = true if table_check(line: line, class_name: class_name)
136
+ end
137
+ end
138
+ end
139
+ end
60
140
 
61
- def normalize_filters(value, branches = [])
62
- scope = ::#{class_name.camelize}.all
63
-
64
- scope = scope.where(is_deleted: value[:is_deleted]) if value[:is_deleted]
65
- scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
66
- scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
141
+ def resolver_end class_name: "souls"
142
+ file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
143
+ File.open(file_path, "a") do |f|
144
+ f.write <<-EOS
145
+ scope = scope.where(is_deleted: value[:is_deleted]) unless value[:is_deleted].nil?
146
+ scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
147
+ scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
67
148
 
68
- branches << scope
149
+ branches << scope
69
150
 
70
- value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
151
+ value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
71
152
 
72
- branches
73
- end
74
- end
75
- end
153
+ branches
154
+ end
155
+ end
156
+ end
76
157
  EOS
77
158
  end
78
159
  [file_path]
79
160
  end
80
161
 
162
+ def resolver class_name: "souls"
163
+ singularized_class_name = class_name.singularize.underscore
164
+ resolver_head class_name: singularized_class_name
165
+ resolver_params class_name: singularized_class_name
166
+ resolver_after_params class_name: singularized_class_name
167
+ resolver_before_end class_name: singularized_class_name
168
+ resolver_end class_name: singularized_class_name
169
+ end
170
+
81
171
  def job class_name: "send_mail"
82
172
  file_path = "./app/jobs/#{class_name.singularize}_job.rb"
83
173
  return ["Job already exist! #{file_path}"] if File.exist? file_path
84
174
  File.open(file_path, "w") do |f|
85
175
  f.write <<~EOS
86
176
  class #{class_name.camelize}
87
- include Sidekiq::Status::Worker
88
- include Sidekiq::Worker
89
- sidekiq_options queue: "default"
90
177
 
91
178
  def perform **args
92
179
  # write task code here
@@ -300,6 +387,36 @@ end
300
387
  rescue StandardError => error
301
388
  puts error
302
389
  end
390
+
391
+ def add_mutation class_name: "souls", file_name: "hoi"
392
+ singularized_class_name = class_name.singularize.underscore
393
+ file_path = "./app/graphql/mutations/#{singularized_class_name}/#{file_name}.rb"
394
+ file_path
395
+ end
396
+
397
+ def add_type class_name: "souls", file_name: "hoi"
398
+ singularized_class_name = class_name.singularize.underscore
399
+ file_path = "./app/graphql/types/#{file_name}.rb"
400
+ file_path
401
+ end
402
+
403
+ def add_edge class_name: "souls", file_name: "hoi"
404
+ singularized_class_name = class_name.singularize.underscore
405
+ file_path = "./app/graphql/types/#{file_name}.rb"
406
+ file_path
407
+ end
408
+
409
+ def add_connection class_name: "souls", file_name: "hoi"
410
+ singularized_class_name = class_name.singularize.underscore
411
+ file_path = "./app/graphql/types/#{file_name}.rb"
412
+ file_path
413
+ end
414
+
415
+ def add_rspec_mutation class_name: "souls", file_name: "hoi"
416
+ singularized_class_name = class_name.singularize.underscore
417
+ file_path = "./app/graphql/types/#{file_name}.rb"
418
+ file_path
419
+ end
303
420
  end
304
421
  end
305
422
  end
data/lib/souls/init.rb CHANGED
@@ -780,10 +780,6 @@ module Souls
780
780
  EOS
781
781
  else
782
782
  new_line.write <<-EOS
783
-
784
- def get_global_key class_name, id
785
- Base64.encode64(\"\#{class_name}:\#{id}\")
786
- end
787
783
  let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(", ")}) }
788
784
 
789
785
  let(:mutation) do
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.16.3"
2
+ VERSION = "0.16.8"
3
3
  end
data/souls.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = "SOULS is a Web Application Framework for Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition. You can focus on business logic. No more infra problems."
11
11
  spec.homepage = "https://github.com/elsoul/souls"
12
12
  spec.license = "Apache-2.0"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://github.com/elsoul/souls"
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.16.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
8
8
  - KishiTheMechanic
9
9
  - James Neve
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-03-01 00:00:00.000000000 Z
13
+ date: 2021-03-12 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.
@@ -55,7 +55,7 @@ metadata:
55
55
  homepage_uri: https://github.com/elsoul/souls
56
56
  source_code_uri: https://github.com/elsoul/souls
57
57
  changelog_uri: https://github.com/elsoul/souls
58
- post_install_message:
58
+ post_install_message:
59
59
  rdoc_options: []
60
60
  require_paths:
61
61
  - lib
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.7.0
66
+ version: 3.0.0
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubygems_version: 3.2.3
74
- signing_key:
74
+ signing_key:
75
75
  specification_version: 4
76
76
  summary: SOULS is a GraphQL Based Web Application Framework for Microservices on Multi
77
77
  Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.