Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cc96d697
Commit
cc96d697
authored
Mar 07, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Naming/FileName rule checking expected class/module per filename
parent
73463b08
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
179 additions
and
1 deletion
+179
-1
.rubocop.yml
.rubocop.yml
+71
-0
app/models/cycle_analytics/summary.rb
app/models/cycle_analytics/summary.rb
+0
-0
lib/declarative_policy.rb
lib/declarative_policy.rb
+3
-1
lib/declarative_policy/delegate_dsl.rb
lib/declarative_policy/delegate_dsl.rb
+16
-0
lib/declarative_policy/policy_dsl.rb
lib/declarative_policy/policy_dsl.rb
+44
-0
lib/declarative_policy/rule_dsl.rb
lib/declarative_policy/rule_dsl.rb
+45
-0
No files found.
.rubocop.yml
View file @
cc96d697
...
...
@@ -31,6 +31,77 @@ Style/MutableConstant:
-
'
ee/db/post_migrate/**/*'
-
'
ee/db/geo/migrate/**/*'
Naming/FileName
:
ExpectMatchingDefinition
:
true
Exclude
:
-
'
spec/**/*'
-
'
features/**/*'
-
'
ee/spec/**/*'
-
'
qa/spec/**/*'
-
'
qa/qa/specs/**/*'
-
'
qa/bin/*'
-
'
config/**/*'
-
'
lib/generators/**/*'
IgnoreExecutableScripts
:
true
AllowedAcronyms
:
-
EE
-
JSON
-
LDAP
-
IO
-
HMAC
-
QA
-
ENV
-
STL
-
PDF
-
SVG
-
CTE
-
DN
-
RSA
-
CI
-
CD
-
OAuth
# default ones:
-
CLI
-
DSL
-
ACL
-
API
-
ASCII
-
CPU
-
CSS
-
DNS
-
EOF
-
GUID
-
HTML
-
HTTP
-
HTTPS
-
ID
-
IP
-
JSON
-
LHS
-
QPS
-
RAM
-
RHS
-
RPC
-
SLA
-
SMTP
-
SQL
-
SSH
-
TCP
-
TLS
-
TTL
-
UDP
-
UI
-
UID
-
UUID
-
URI
-
URL
-
UTF8
-
VM
-
XML
-
XMPP
-
XSRF
-
XSS
# Gitlab ###################################################################
Gitlab/ModuleWithInstanceVariables
:
...
...
app/models/cycle_analytics/summary.rb
deleted
100644 → 0
View file @
73463b08
lib/declarative_policy.rb
View file @
cc96d697
require_dependency
'declarative_policy/cache'
require_dependency
'declarative_policy/condition'
require_dependency
'declarative_policy/dsl'
require_dependency
'declarative_policy/delegate_dsl'
require_dependency
'declarative_policy/policy_dsl'
require_dependency
'declarative_policy/rule_dsl'
require_dependency
'declarative_policy/preferred_scope'
require_dependency
'declarative_policy/rule'
require_dependency
'declarative_policy/runner'
...
...
lib/declarative_policy/delegate_dsl.rb
0 → 100644
View file @
cc96d697
module
DeclarativePolicy
# Used when the name of a delegate is mentioned in
# the rule DSL.
class
DelegateDsl
def
initialize
(
rule_dsl
,
delegate_name
)
@rule_dsl
=
rule_dsl
@delegate_name
=
delegate_name
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
@rule_dsl
.
delegate
(
@delegate_name
,
m
)
end
end
end
lib/declarative_policy/dsl.rb
→
lib/declarative_policy/
policy_
dsl.rb
View file @
cc96d697
module
DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects.
#
# See Base.rule
class
RuleDsl
def
initialize
(
context_class
)
@context_class
=
context_class
end
def
can?
(
ability
)
Rule
::
Ability
.
new
(
ability
)
end
def
all?
(
*
rules
)
Rule
::
And
.
make
(
rules
)
end
def
any?
(
*
rules
)
Rule
::
Or
.
make
(
rules
)
end
def
none?
(
*
rules
)
~
Rule
::
Or
.
new
(
rules
)
end
def
cond
(
condition
)
Rule
::
Condition
.
new
(
condition
)
end
def
delegate
(
delegate_name
,
condition
)
Rule
::
DelegatedCondition
.
new
(
delegate_name
,
condition
)
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
if
@context_class
.
delegations
.
key?
(
m
)
DelegateDsl
.
new
(
self
,
m
)
else
cond
(
m
.
to_sym
)
end
end
end
# Used when the name of a delegate is mentioned in
# the rule DSL.
class
DelegateDsl
def
initialize
(
rule_dsl
,
delegate_name
)
@rule_dsl
=
rule_dsl
@delegate_name
=
delegate_name
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
@rule_dsl
.
delegate
(
@delegate_name
,
m
)
end
end
# The return value of a rule { ... } declaration.
# Can call back to register rules with the containing
# Policy class (context_class here). See Base.rule
...
...
lib/declarative_policy/rule_dsl.rb
0 → 100644
View file @
cc96d697
module
DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects.
#
# See Base.rule
class
RuleDsl
def
initialize
(
context_class
)
@context_class
=
context_class
end
def
can?
(
ability
)
Rule
::
Ability
.
new
(
ability
)
end
def
all?
(
*
rules
)
Rule
::
And
.
make
(
rules
)
end
def
any?
(
*
rules
)
Rule
::
Or
.
make
(
rules
)
end
def
none?
(
*
rules
)
~
Rule
::
Or
.
new
(
rules
)
end
def
cond
(
condition
)
Rule
::
Condition
.
new
(
condition
)
end
def
delegate
(
delegate_name
,
condition
)
Rule
::
DelegatedCondition
.
new
(
delegate_name
,
condition
)
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
if
@context_class
.
delegations
.
key?
(
m
)
DelegateDsl
.
new
(
self
,
m
)
else
cond
(
m
.
to_sym
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment