action_policy 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/.rbnext/1995.next/action_policy/utils/pretty_print.rb +2 -2
- data/lib/.rbnext/2.7/action_policy/utils/pretty_print.rb +2 -2
- data/lib/.rbnext/3.0/action_policy/policy/aliases.rb +8 -0
- data/lib/.rbnext/3.0/action_policy/policy/core.rb +9 -2
- data/lib/.rbnext/3.0/action_policy/utils/pretty_print.rb +2 -2
- data/lib/action_policy/version.rb +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: 021e6da5ccd46f76732cb52c0c04ae1a45ce3a74a2b64643e179ee16c40417e3
|
4
|
+
data.tar.gz: 96a978308fde0160f5b739d47abdd833005ba7109e97837ac0dd5721f1ec52a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69953fedcbaa8d007c3c922e17dd26618eda2ed840d59bac476111f62bb7aae7c20f2920606925eb4b3acab7e90f994a6e1a9a55b7de0a0740f3747bb4e85aa3
|
7
|
+
data.tar.gz: 23de3c82949db85f3a41f079187493087add27f88e0cd9315ccb492e925f4490390d5ae17fb493eb3ae290f5469f216ab258e21e7c155be9853de5728c8b3311
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
-
## 0.5.
|
5
|
+
## 0.5.7 (2021-03-03)
|
6
|
+
|
7
|
+
The previous release had incorrect dependencies (due to the missing transpiled files).
|
8
|
+
|
9
|
+
## ~~0.5.6 (2021-03-03)~~
|
6
10
|
|
7
11
|
- Add `ActionPolicy.enforce_predicate_rules_naming` config to catch rule missing question mark ([@skojin][])
|
8
12
|
|
@@ -146,8 +146,8 @@ module ActionPolicy
|
|
146
146
|
|
147
147
|
def colorize(val)
|
148
148
|
return val unless $stdout.isatty
|
149
|
-
return TRUE if val.eql?(true)
|
150
|
-
return FALSE if val.eql?(false)
|
149
|
+
return TRUE if val.eql?(true) # rubocop:disable Lint/DeprecatedConstants
|
150
|
+
return FALSE if val.eql?(false) # rubocop:disable Lint/DeprecatedConstants
|
151
151
|
val
|
152
152
|
end
|
153
153
|
end
|
@@ -146,8 +146,8 @@ module ActionPolicy
|
|
146
146
|
|
147
147
|
def colorize(val)
|
148
148
|
return val unless $stdout.isatty
|
149
|
-
return TRUE if val.eql?(true)
|
150
|
-
return FALSE if val.eql?(false)
|
149
|
+
return TRUE if val.eql?(true) # rubocop:disable Lint/DeprecatedConstants
|
150
|
+
return FALSE if val.eql?(false) # rubocop:disable Lint/DeprecatedConstants
|
151
151
|
val
|
152
152
|
end
|
153
153
|
end
|
@@ -31,10 +31,18 @@ module ActionPolicy
|
|
31
31
|
def resolve_rule(activity)
|
32
32
|
self.class.lookup_alias(activity) ||
|
33
33
|
(activity if respond_to?(activity)) ||
|
34
|
+
(check_rule_naming(activity) if ActionPolicy.enforce_predicate_rules_naming) ||
|
34
35
|
self.class.lookup_default_rule ||
|
35
36
|
super
|
36
37
|
end
|
37
38
|
|
39
|
+
private def check_rule_naming(activity)
|
40
|
+
unless activity[-1] == "?"
|
41
|
+
raise NonPredicateRule.new(self, activity)
|
42
|
+
end
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
38
46
|
module ClassMethods # :nodoc:
|
39
47
|
def default_rule(val)
|
40
48
|
rules_aliases[DEFAULT] = val
|
@@ -23,12 +23,19 @@ module ActionPolicy
|
|
23
23
|
def initialize(policy, rule)
|
24
24
|
@policy = policy.class
|
25
25
|
@rule = rule
|
26
|
-
@message =
|
27
|
-
"Couldn't find rule '#{@rule}' for #{@policy}" \
|
26
|
+
@message = "Couldn't find rule '#{@rule}' for #{@policy}" \
|
28
27
|
"#{suggest(@rule, @policy.instance_methods - Object.instance_methods)}"
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
31
|
+
class NonPredicateRule < UnknownRule
|
32
|
+
def initialize(policy, rule)
|
33
|
+
@policy = policy.class
|
34
|
+
@rule = rule
|
35
|
+
@message = "The rule '#{@rule}' of '#{@policy}' must ends with ? (question mark)\nDid you mean? #{@rule}?"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
32
39
|
module Policy
|
33
40
|
# Core policy API
|
34
41
|
module Core
|
@@ -146,8 +146,8 @@ module ActionPolicy
|
|
146
146
|
|
147
147
|
def colorize(val)
|
148
148
|
return val unless $stdout.isatty
|
149
|
-
return TRUE if val.eql?(true)
|
150
|
-
return FALSE if val.eql?(false)
|
149
|
+
return TRUE if val.eql?(true) # rubocop:disable Lint/DeprecatedConstants
|
150
|
+
return FALSE if val.eql?(false) # rubocop:disable Lint/DeprecatedConstants
|
151
151
|
val
|
152
152
|
end
|
153
153
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby-next
|
14
|
+
name: ruby-next-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|