souls 0.17.2 → 0.17.7

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: 36a0dab64172ffc88d5d0b08b585c7ee00a4c592ad0333e514965d325298f6cd
4
- data.tar.gz: b43bc48a6aa7f62b5399db04164b33312a03f7ec718247bfa516bf5b15800169
3
+ metadata.gz: 79ae1fd5651960fb5b8e025f51fd70d9d77f31f3d33c4f9be6169ed1b9e7adeb
4
+ data.tar.gz: 0dbefc7f05bd9f26e0bfca1746161ec1bce58b900b5c4c856fb9ac3c9e50f9e8
5
5
  SHA512:
6
- metadata.gz: beabb98cd7dd49f9e429ea3b8687a404d1a2eb6e1b3b1c15f6a981e54940d5b2cbf6184587ad8a54493f1d0e5bd6523307e11d017942501cfdc296e9d81b4c7a
7
- data.tar.gz: fab2fe6850ca6326e6427ab8e5102c17b9dcfc91b67224a496763fae9f7537fcf1b5f5ad5ba35a7e70997ee335f79898eea882d4bf58798f744820fbaad84d9f
6
+ metadata.gz: 34ca624d6c179c96f2dece10e52e2686b62806826cf455310f34873daa350cafb955cc8be6d1195c81063cfad4c9d7c0d0a5fe7ae9d170503d74cf64b94ae243
7
+ data.tar.gz: 43197559c83bcb48189cb9c7434d9a4fb037ac08909029bbd23a42dc53f6a7f1e0c04b85af4a3a99d9ebfe9d5630ba6385943149ad3e8b2ac8072bf49dc1ef2b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.16.7)
4
+ souls (0.17.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -77,6 +77,7 @@ GEM
77
77
 
78
78
  PLATFORMS
79
79
  x86_64-darwin-20
80
+ x86_64-linux
80
81
 
81
82
  DEPENDENCIES
82
83
  activesupport (= 6.1.0)
@@ -87,4 +88,4 @@ DEPENDENCIES
87
88
  steep (= 0.39.0)
88
89
 
89
90
  BUNDLED WITH
90
- 2.2.11
91
+ 2.2.14
data/Steepfile CHANGED
@@ -5,5 +5,4 @@ target :app do
5
5
 
6
6
  # check 'app'
7
7
  check "rbs"
8
-
9
8
  end
data/exe/souls CHANGED
@@ -67,6 +67,10 @@ begin
67
67
  case ARGV[1]
68
68
  when "test_dir"
69
69
  Souls::Init.test_dir
70
+ when "policy"
71
+ Souls::Init.policy class_name: ARGV[2]
72
+ when "rspec_policy"
73
+ Souls::Init.rspec_policy class_name: ARGV[2]
70
74
  when "node_type"
71
75
  Souls::Init.node_type class_name: ARGV[2]
72
76
  when "resolver"
data/lib/souls.rb CHANGED
@@ -118,11 +118,13 @@ module Souls
118
118
  app = Souls.configuration.app
119
119
  network = Souls.configuration.network
120
120
  sub_network = Souls.configuration.network
121
- system("gcloud compute network-endpoint-groups create #{app} \
121
+ system(
122
+ "gcloud compute network-endpoint-groups create #{app} \
122
123
  --default-port=0 \
123
124
  --network #{network} \
124
125
  --subnet #{sub_network} \
125
- --global")
126
+ --global"
127
+ )
126
128
  end
127
129
 
128
130
  def export_network_group
@@ -158,7 +160,8 @@ module Souls
158
160
  sub_network = Souls.configuration.network
159
161
  machine_type = Souls.configuration.machine_type
160
162
  zone = Souls.configuration.zone
161
- system("gcloud container clusters create #{app} \
163
+ system(
164
+ "gcloud container clusters create #{app} \
162
165
  --network #{network} \
163
166
  --subnetwork #{sub_network} \
164
167
  --zone #{zone} \
@@ -170,7 +173,8 @@ module Souls
170
173
  --enable-autoscaling \
171
174
  --min-nodes 1 \
172
175
  --max-nodes 4 \
173
- --tags=allow-health-checks")
176
+ --tags=allow-health-checks"
177
+ )
174
178
  end
175
179
 
176
180
  def deploy
@@ -19,6 +19,92 @@ module Souls
19
19
  [file_path]
20
20
  end
21
21
 
22
+ def policy class_name: "souls"
23
+ dir_name = "./app/policies"
24
+ FileUtils.mkdir_p dir_name unless Dir.exist? dir_name
25
+ file_path = "./app/policies/#{class_name.singularize}_policy.rb"
26
+ File.open(file_path, "w") do |f|
27
+ f.write <<~EOS
28
+ class #{class_name.camelize}Policy < ApplicationPolicy
29
+ def show?
30
+ true
31
+ end
32
+
33
+ def index?
34
+ true
35
+ end
36
+
37
+ def create?
38
+ staff_permissions?
39
+ end
40
+
41
+ def update?
42
+ staff_permissions?
43
+ end
44
+
45
+ def delete?
46
+ staff_permissions?
47
+ end
48
+
49
+ private
50
+
51
+ def staff_permissions?
52
+ @user.master? or @user.admin? or @user.staff?
53
+ end
54
+
55
+ def admin_permissions?
56
+ @user.master? or @user.admin?
57
+ end
58
+ end
59
+ EOS
60
+ end
61
+ [file_path]
62
+ end
63
+
64
+ def rspec_policy class_name: "souls"
65
+ dir_name = "./spec/policies"
66
+ FileUtils.mkdir_p dir_name unless Dir.exist? dir_name
67
+ file_path = "./spec/policies/#{class_name}_policy_spec.rb"
68
+ File.open(file_path, "w") do |new_line|
69
+ new_line.write <<~EOS
70
+ describe #{class_name.camelize}Policy do
71
+ subject { described_class.new(user, #{class_name.underscore}) }
72
+
73
+ let(:#{class_name.underscore}) { FactoryBot.create(:#{class_name.underscore}) }
74
+
75
+ context "being a visitor" do
76
+ let(:user) { FactoryBot.create(:user) }
77
+
78
+ it { is_expected.to permit_action(:index) }
79
+ it { is_expected.to permit_action(:show) }
80
+ it { is_expected.to forbid_actions([:create, :update, :delete]) }
81
+ end
82
+
83
+ context "being a retailer" do
84
+ let(:user) { FactoryBot.create(:user, user_role: 1) }
85
+
86
+ it { is_expected.to permit_action(:index) }
87
+ it { is_expected.to permit_action(:show) }
88
+ it { is_expected.to forbid_actions([:create, :update, :delete]) }
89
+ end
90
+
91
+ context "being a staff" do
92
+ let(:user) { FactoryBot.create(:user, user_role: 3) }
93
+
94
+ it { is_expected.to permit_actions([:create, :update, :delete]) }
95
+ end
96
+
97
+ context "being an administrator" do
98
+ let(:user) { FactoryBot.create(:user, user_role: 4) }
99
+
100
+ it { is_expected.to permit_actions([:create, :update, :delete]) }
101
+ end
102
+ end
103
+ EOS
104
+ end
105
+ [file_path]
106
+ end
107
+
22
108
  def resolver_head class_name: "souls"
23
109
  FileUtils.mkdir_p "./app/graphql/resolvers" unless Dir.exist? "./app/graphql/resolvers"
24
110
  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
@@ -140,18 +226,18 @@ module Souls
140
226
  def resolver_end class_name: "souls"
141
227
  file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
142
228
  File.open(file_path, "a") do |f|
143
- f.write <<-EOS
144
- scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
145
- scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
146
-
147
- branches << scope
148
-
149
- value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
150
-
151
- branches
152
- end
153
- end
154
- end
229
+ f.write <<~EOS
230
+ scope = scope.where("created_at >= ?", value[:start_date]) if value[:start_date]
231
+ scope = scope.where("created_at <= ?", value[:end_date]) if value[:end_date]
232
+ #{' '}
233
+ branches << scope
234
+ #{' '}
235
+ value[:OR].inject(branches) { |s, v| normalize_filters(v, s) } if value[:OR].present?
236
+ #{' '}
237
+ branches
238
+ end
239
+ end
240
+ end
155
241
  EOS
156
242
  end
157
243
  [file_path]
@@ -318,11 +404,11 @@ end
318
404
  f.each_line.with_index do |line, i|
319
405
  if @on
320
406
  if line.include?("end") || line.include?("t.index")
321
- new_line.write <<-EOS
322
- )
323
- end
324
- end
325
- end
407
+ new_line.write <<~EOS
408
+ )
409
+ end
410
+ end
411
+ end
326
412
  EOS
327
413
  break
328
414
  end
@@ -407,32 +493,27 @@ end
407
493
 
408
494
  def add_mutation class_name: "souls", file_name: "hoi"
409
495
  singularized_class_name = class_name.singularize.underscore
410
- file_path = "./app/graphql/mutations/#{singularized_class_name}/#{file_name}.rb"
411
- file_path
496
+ "./app/graphql/mutations/#{singularized_class_name}/#{file_name}.rb"
412
497
  end
413
498
 
414
499
  def add_type class_name: "souls", file_name: "hoi"
415
500
  singularized_class_name = class_name.singularize.underscore
416
- file_path = "./app/graphql/types/#{file_name}.rb"
417
- file_path
501
+ "./app/graphql/types/#{file_name}.rb"
418
502
  end
419
503
 
420
504
  def add_edge class_name: "souls", file_name: "hoi"
421
505
  singularized_class_name = class_name.singularize.underscore
422
- file_path = "./app/graphql/types/#{file_name}.rb"
423
- file_path
506
+ "./app/graphql/types/#{file_name}.rb"
424
507
  end
425
508
 
426
509
  def add_connection class_name: "souls", file_name: "hoi"
427
510
  singularized_class_name = class_name.singularize.underscore
428
- file_path = "./app/graphql/types/#{file_name}.rb"
429
- file_path
511
+ "./app/graphql/types/#{file_name}.rb"
430
512
  end
431
513
 
432
514
  def add_rspec_mutation class_name: "souls", file_name: "hoi"
433
515
  singularized_class_name = class_name.singularize.underscore
434
- file_path = "./app/graphql/types/#{file_name}.rb"
435
- file_path
516
+ "./app/graphql/types/#{file_name}.rb"
436
517
  end
437
518
  end
438
519
  end
data/lib/souls/init.rb CHANGED
@@ -289,8 +289,8 @@ module Souls
289
289
  float: 4.2,
290
290
  string: '"MyString"',
291
291
  text: '"MyString"',
292
- datetime: "DateTime.now",
293
- date: "DateTime.now",
292
+ datetime: "Time.now",
293
+ date: "Time.now",
294
294
  boolean: false,
295
295
  integer: 1
296
296
  }[type.to_sym]
data/lib/souls/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.17.2"
2
+ VERSION = "0.17.7"
3
3
  end
data/souls.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
  end
24
24
  spec.bindir = "exe"
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.17.2
4
+ version: 0.17.7
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-03-29 00:00:00.000000000 Z
13
+ date: 2021-04-02 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.