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 +4 -4
- data/Gemfile.lock +3 -2
- data/Steepfile +0 -1
- data/exe/souls +4 -0
- data/lib/souls.rb +8 -4
- data/lib/souls/generate.rb +108 -27
- data/lib/souls/init.rb +2 -2
- data/lib/souls/version.rb +1 -1
- data/souls.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79ae1fd5651960fb5b8e025f51fd70d9d77f31f3d33c4f9be6169ed1b9e7adeb
|
4
|
+
data.tar.gz: 0dbefc7f05bd9f26e0bfca1746161ec1bce58b900b5c4c856fb9ac3c9e50f9e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
91
|
+
2.2.14
|
data/Steepfile
CHANGED
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(
|
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(
|
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
|
data/lib/souls/generate.rb
CHANGED
@@ -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
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
322
|
-
|
323
|
-
|
324
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
data/lib/souls/version.rb
CHANGED
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
|
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.
|
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-
|
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.
|