policy_check 0.1.0 → 0.1.1
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 +1 -1
- data/README.md +13 -5
- data/lib/policy_check/version.rb +1 -1
- data/policy_check.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a1e72d0560846575b9f7058c0143f736ba327fff679202f6b50630c6cf87907
|
|
4
|
+
data.tar.gz: c5dcf2ee63df0890a9ef835109b271b88ff0e8adf4648a98755ff4918e8add81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3621a014b73eda77689c064437c8fbbd267b05b541c6d2b5516f74f3c0841b86282e0194fb60e74f43ad1509fcb83f419919eef600c0f57641111baaae71e266
|
|
7
|
+
data.tar.gz: 3333297547cb1e00b83fb8e4b2d9fba03ca4a00657ea8cc00864a30480374f045ff5d07cffb1db4f26a2e3fd6c4a50c1e39281aadbe4cd1725e2b31cd6957fe5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
# PolicyCheck
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
DSL for policy definitions and allows get reasons for policy violations.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
10
10
|
|
|
11
11
|
```ruby
|
|
12
|
-
gem 'policy_check'
|
|
12
|
+
gem 'policy_check'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
And then execute:
|
|
@@ -19,11 +19,19 @@ And then execute:
|
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
|
+
```ruby
|
|
23
|
+
class Post
|
|
24
|
+
extend PolicyCheck #-> only add `.policy` method
|
|
25
|
+
end
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
|
|
22
30
|
### Inline policy
|
|
23
31
|
|
|
24
32
|
```ruby
|
|
25
33
|
class Post
|
|
26
|
-
extend PolicyCheck
|
|
34
|
+
extend PolicyCheck
|
|
27
35
|
|
|
28
36
|
def initialize
|
|
29
37
|
@status = :draft
|
|
@@ -54,7 +62,7 @@ post.publishable? #=> false
|
|
|
54
62
|
|
|
55
63
|
```ruby
|
|
56
64
|
class PostPublishablePolicy
|
|
57
|
-
extend PolicyCheck
|
|
65
|
+
extend PolicyCheck
|
|
58
66
|
|
|
59
67
|
def initialize(post, user)
|
|
60
68
|
@post = post
|
|
@@ -66,7 +74,7 @@ class PostPublishablePolicy
|
|
|
66
74
|
!user.admin?
|
|
67
75
|
end
|
|
68
76
|
|
|
69
|
-
policy do #-> only create `#valid?` and `#error_messages` method
|
|
77
|
+
policy do #-> only create `#valid?`, `#invalid?` and `#error_messages` method
|
|
70
78
|
error "user is not admin", &:not_admin?
|
|
71
79
|
error("status is not `draft`") { post.status != :draft }
|
|
72
80
|
error("body is empty") { post.body.empty? }
|
data/lib/policy_check/version.rb
CHANGED
data/policy_check.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.authors = ["HAZI"]
|
|
13
13
|
spec.email = ["yuhei.mukoyama@gmail.com"]
|
|
14
14
|
|
|
15
|
-
spec.summary = "
|
|
15
|
+
spec.summary = "DSL for policy definitions and allows get reasons for policy violations."
|
|
16
16
|
spec.homepage = "https://github.com/hazi/policy_check"
|
|
17
17
|
spec.license = "MIT"
|
|
18
18
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: policy_check
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- HAZI
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -59,5 +59,5 @@ requirements: []
|
|
|
59
59
|
rubygems_version: 3.3.26
|
|
60
60
|
signing_key:
|
|
61
61
|
specification_version: 4
|
|
62
|
-
summary:
|
|
62
|
+
summary: DSL for policy definitions and allows get reasons for policy violations.
|
|
63
63
|
test_files: []
|