Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
1a97bf10
Commit
1a97bf10
authored
Mar 05, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding custom validations for watchers
parent
fc74cc71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
validations.rb
lib/noah/validations.rb
+1
-0
watcher_validations.rb
lib/noah/validations/watcher_validations.rb
+36
-0
No files found.
lib/noah/validations.rb
0 → 100644
View file @
1a97bf10
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'validations'
,
'watcher_validations'
)
lib/noah/validations/watcher_validations.rb
0 → 100644
View file @
1a97bf10
module
Noah
module
WatcherValidations
def
assert_not_subset
(
error
=
[
:pattern
,
:already_provided
])
self
.
instance_of?
(
Noah
::
Watcher
)
?
(
assert
endpoint_covered?
,
error
)
:
(
assert
false
,
"Validation not applicable"
)
end
def
assert_not_superset
(
error
=
[
:pattern
,
:replaces_existing
])
self
.
instance_of?
(
Noah
::
Watcher
)
?
(
assert
endpoint_overrides?
,
error
)
:
(
assert
false
,
"Validation not applicable"
)
end
private
def
endpoint_covered?
watches
=
Watcher
.
all
.
find
(
:endpoint
=>
self
.
endpoint
).
sort
watches
.
each
do
|
w
|
if
(
w
.
pattern
.
size
<
self
.
pattern
.
size
)
&&
self
.
pattern
.
match
(
/^
#{
w
.
pattern
}
/
)
return
false
end
end
rescue
ArgumentError
return
false
end
def
endpoint_overrides?
watches
=
Watcher
.
all
.
find
(
:endpoint
=>
self
.
endpoint
).
sort
watches
.
each
do
|
w
|
if
(
w
.
pattern
.
size
>
self
.
pattern
.
size
)
&&
w
.
pattern
.
match
(
/^
#{
self
.
pattern
}
/
)
return
false
end
end
rescue
ArgumentError
return
false
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