souls 0.17.0 → 0.17.5
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/exe/souls +14 -2
- data/lib/souls/generate.rb +106 -0
- data/lib/souls/init.rb +2 -2
- data/lib/souls/version.rb +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: 48f5dacba8fb3bd0da68f45b83208de7007abb6392b7d0c8eb9176755b97c185
|
4
|
+
data.tar.gz: 64283afa2ca8decda20078855d116d8c9dd7e3979dd8ce50560e9591dfcc5135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 507ef37fd28f186e6f7a4cc6c5e8528a5b48443afb989f247e60dab26fe4a1005733283caedb1391cc1bc0f3288ba099774ff25c3d573c2a5530ea331bfadb76
|
7
|
+
data.tar.gz: 8ae0b00d12c3acab94babcf5cb6cf19fa4a8923b26c82c5b1790de317d16fd421bf4f97e572615561d1ac7f90c6a918122625cf1420d371ef980d76870015651
|
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"
|
@@ -114,7 +121,12 @@ begin
|
|
114
121
|
system "rake db:migrate && rake db:migrate RACK_ENV=test"
|
115
122
|
end
|
116
123
|
when "db:seed"
|
117
|
-
|
124
|
+
case ARGV[1]
|
125
|
+
when "RACK_ENV=production"
|
126
|
+
system "rake db:seed RACK_ENV=production"
|
127
|
+
else
|
128
|
+
system "rake db:seed"
|
129
|
+
end
|
118
130
|
when "db:migrate:reset"
|
119
131
|
case ARGV[1]
|
120
132
|
when "RACK_ENV=production"
|
data/lib/souls/generate.rb
CHANGED
@@ -19,6 +19,90 @@ module Souls
|
|
19
19
|
[file_path]
|
20
20
|
end
|
21
21
|
|
22
|
+
def policy class_name: "souls"
|
23
|
+
file_path = "./app/policy/#{class_name.singularize}_policy.rb"
|
24
|
+
File.open(file_path, "w") do |f|
|
25
|
+
f.write <<~EOS
|
26
|
+
class #{class_name.camelize}Policy < ApplicationPolicy
|
27
|
+
def show?
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def index?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def create?
|
36
|
+
staff_permissions?
|
37
|
+
end
|
38
|
+
|
39
|
+
def update?
|
40
|
+
staff_permissions?
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete?
|
44
|
+
staff_permissions?
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def staff_permissions?
|
50
|
+
@user.master? or @user.admin? or @user.staff?
|
51
|
+
end
|
52
|
+
|
53
|
+
def admin_permissions?
|
54
|
+
@user.master? or @user.admin?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
EOS
|
58
|
+
end
|
59
|
+
[file_path]
|
60
|
+
end
|
61
|
+
|
62
|
+
def rspec_policy class_name: "souls"
|
63
|
+
dir_name = "./spec/policies"
|
64
|
+
FileUtils.mkdir_p dir_name unless Dir.exist? dir_name
|
65
|
+
file_path = "./spec/policies/#{class_name}_policy_spec.rb"
|
66
|
+
File.open(file_path, "w") do |new_line|
|
67
|
+
new_line.write <<~EOS
|
68
|
+
describe #{class_name.camelize}Policy do
|
69
|
+
subject { described_class.new(user, #{class_name.underscore}) }
|
70
|
+
|
71
|
+
let(:#{class_name.underscore}) { FactoryBot.create(:#{class_name.underscore}) }
|
72
|
+
|
73
|
+
context "being a visitor" do
|
74
|
+
let(:user) { FactoryBot.create(:user) }
|
75
|
+
|
76
|
+
it { is_expected.to permit_action(:index) }
|
77
|
+
it { is_expected.to permit_action(:show) }
|
78
|
+
it { is_expected.to forbid_actions([:create, :update, :delete]) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context "being a retailer" do
|
82
|
+
let(:user) { FactoryBot.create(:user, user_role: 1) }
|
83
|
+
|
84
|
+
it { is_expected.to permit_action(:index) }
|
85
|
+
it { is_expected.to permit_action(:show) }
|
86
|
+
it { is_expected.to forbid_actions([:create, :update, :delete]) }
|
87
|
+
end
|
88
|
+
|
89
|
+
context "being a staff" do
|
90
|
+
let(:user) { FactoryBot.create(:user, user_role: 3) }
|
91
|
+
|
92
|
+
it { is_expected.to permit_actions([:create, :update, :delete]) }
|
93
|
+
end
|
94
|
+
|
95
|
+
context "being an administrator" do
|
96
|
+
let(:user) { FactoryBot.create(:user, user_role: 4) }
|
97
|
+
|
98
|
+
it { is_expected.to permit_actions([:create, :update, :delete]) }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
EOS
|
102
|
+
end
|
103
|
+
[file_path]
|
104
|
+
end
|
105
|
+
|
22
106
|
def resolver_head class_name: "souls"
|
23
107
|
FileUtils.mkdir_p "./app/graphql/resolvers" unless Dir.exist? "./app/graphql/resolvers"
|
24
108
|
file_path = "./app/graphql/resolvers/#{class_name.singularize}_search.rb"
|
@@ -366,6 +450,28 @@ end
|
|
366
450
|
rspec_resolver_end class_name: singularized_class_name
|
367
451
|
end
|
368
452
|
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
def add_delete class_name: "souls"
|
457
|
+
singularized_class_name = class_name.singularize.underscore
|
458
|
+
pluralized_class_name = class_name.pluralize.underscore
|
459
|
+
FileUtils.rm_rf "./app/graphql/mutations/#{singularized_class_name}"
|
460
|
+
FileUtils.rm "./app/graphql/queries/#{singularized_class_name}.rb"
|
461
|
+
FileUtils.rm "./app/graphql/queries/#{pluralized_class_name}.rb"
|
462
|
+
FileUtils.rm "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
463
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_type.rb"
|
464
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_node_type.rb"
|
465
|
+
FileUtils.rm "./spec/factories/#{pluralized_class_name}.rb"
|
466
|
+
FileUtils.rm "./spec/mutations/#{singularized_class_name}_spec.rb"
|
467
|
+
FileUtils.rm "./spec/models/#{singularized_class_name}_spec.rb"
|
468
|
+
FileUtils.rm "./spec/queries/#{singularized_class_name}_spec.rb"
|
469
|
+
FileUtils.rm "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
470
|
+
puts "deleted #{class_name.camelize} CRUD!"
|
471
|
+
rescue StandardError => error
|
472
|
+
puts error
|
473
|
+
end
|
474
|
+
|
369
475
|
def delete_all class_name: "souls"
|
370
476
|
singularized_class_name = class_name.singularize.underscore
|
371
477
|
pluralized_class_name = class_name.pluralize.underscore
|
data/lib/souls/init.rb
CHANGED
data/lib/souls/version.rb
CHANGED
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.5
|
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-01 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.
|