souls 0.17.1 → 0.17.6
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 +8 -1
- data/lib/souls.rb +8 -4
- data/lib/souls/generate.rb +127 -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: bbb549404b0a81f37dff81fc568f7d93b69f4ef23ac321fd6f7ed4602e1a1195
|
4
|
+
data.tar.gz: 18b4d58e4969cb122387bb893d476fa3bf246a47a9ea31338adb95b80fea3b13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a060e41c870266b1441285ebe87e5cf25aacea694299858ffdf1223aae0b880ca688735a8f8ec5957eae87c0ebf4358365a69673fb33d4379f25c9aa52cb9d2c
|
7
|
+
data.tar.gz: 1fa8878a36982334b4244bd39e90da9010ca8e9a097bc33a75e49ce44360502e4bc6fe05a339cba30cd1ff5e6e6e4f7d7d29bbf769cf9a498579b9244ad0d760
|
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"
|
@@ -103,7 +107,10 @@ begin
|
|
103
107
|
"SOULs!"
|
104
108
|
end
|
105
109
|
when "d"
|
106
|
-
Souls::Init.
|
110
|
+
Souls::Init.add_delete class_name: ARGV[1]
|
111
|
+
when "update"
|
112
|
+
Souls::Init.add_delete class_name: ARGV[1]
|
113
|
+
Souls::Init.single_migrate class_name: ARGV[1]
|
107
114
|
when "db:create"
|
108
115
|
system "rake db:create && rake db:create RACK_ENV=test"
|
109
116
|
when "db:migrate"
|
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/policy"
|
24
|
+
FileUtils.mkdir_p dir_name unless Dir.exist? dir_name
|
25
|
+
file_path = "./app/policy/#{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
|
@@ -366,6 +452,25 @@ end
|
|
366
452
|
rspec_resolver_end class_name: singularized_class_name
|
367
453
|
end
|
368
454
|
|
455
|
+
def add_delete class_name: "souls"
|
456
|
+
singularized_class_name = class_name.singularize.underscore
|
457
|
+
pluralized_class_name = class_name.pluralize.underscore
|
458
|
+
FileUtils.rm_rf "./app/graphql/mutations/#{singularized_class_name}"
|
459
|
+
FileUtils.rm "./app/graphql/queries/#{singularized_class_name}.rb"
|
460
|
+
FileUtils.rm "./app/graphql/queries/#{pluralized_class_name}.rb"
|
461
|
+
FileUtils.rm "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
462
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_type.rb"
|
463
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_node_type.rb"
|
464
|
+
FileUtils.rm "./spec/factories/#{pluralized_class_name}.rb"
|
465
|
+
FileUtils.rm "./spec/mutations/#{singularized_class_name}_spec.rb"
|
466
|
+
FileUtils.rm "./spec/models/#{singularized_class_name}_spec.rb"
|
467
|
+
FileUtils.rm "./spec/queries/#{singularized_class_name}_spec.rb"
|
468
|
+
FileUtils.rm "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
469
|
+
puts "deleted #{class_name.camelize} CRUD!"
|
470
|
+
rescue StandardError => error
|
471
|
+
puts error
|
472
|
+
end
|
473
|
+
|
369
474
|
def delete_all class_name: "souls"
|
370
475
|
singularized_class_name = class_name.singularize.underscore
|
371
476
|
pluralized_class_name = class_name.pluralize.underscore
|
@@ -388,32 +493,27 @@ end
|
|
388
493
|
|
389
494
|
def add_mutation class_name: "souls", file_name: "hoi"
|
390
495
|
singularized_class_name = class_name.singularize.underscore
|
391
|
-
|
392
|
-
file_path
|
496
|
+
"./app/graphql/mutations/#{singularized_class_name}/#{file_name}.rb"
|
393
497
|
end
|
394
498
|
|
395
499
|
def add_type class_name: "souls", file_name: "hoi"
|
396
500
|
singularized_class_name = class_name.singularize.underscore
|
397
|
-
|
398
|
-
file_path
|
501
|
+
"./app/graphql/types/#{file_name}.rb"
|
399
502
|
end
|
400
503
|
|
401
504
|
def add_edge class_name: "souls", file_name: "hoi"
|
402
505
|
singularized_class_name = class_name.singularize.underscore
|
403
|
-
|
404
|
-
file_path
|
506
|
+
"./app/graphql/types/#{file_name}.rb"
|
405
507
|
end
|
406
508
|
|
407
509
|
def add_connection class_name: "souls", file_name: "hoi"
|
408
510
|
singularized_class_name = class_name.singularize.underscore
|
409
|
-
|
410
|
-
file_path
|
511
|
+
"./app/graphql/types/#{file_name}.rb"
|
411
512
|
end
|
412
513
|
|
413
514
|
def add_rspec_mutation class_name: "souls", file_name: "hoi"
|
414
515
|
singularized_class_name = class_name.singularize.underscore
|
415
|
-
|
416
|
-
file_path
|
516
|
+
"./app/graphql/types/#{file_name}.rb"
|
417
517
|
end
|
418
518
|
end
|
419
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.6
|
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.
|