Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F5131129
schedule.rb
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 17, 1:47 PM
Size
756 B
Mime Type
text/x-ruby
Expires
Wed, Aug 19, 1:47 PM (1 d, 2 h)
Engine
blob
Format
Raw Data
Handle
432848
Attached To
rARCHIVING archiving
schedule.rb
View Options
class
Schedule
<
ActiveRecord
::
Base
DEFAULT_RUNS
=
[
'Level=Full 1st sun at '
,
'Level=Differential 2nd-5th sun at '
,
'Level=Incremental mon-sat at '
]
attr_accessor
:runtime
serialize
:runs
,
JSON
validates
:name
,
:runs
,
presence
:
true
before_validation
:set_runs
,
if
:
Proc
.
new
{
|
s
|
s
.
runtime
.
present?
}
def
to_bacula_config_array
[
'Schedule {'
]
+
[
" Name =
\"
#{
name
}
\"
"
]
+
runs
.
map
{
|
r
|
" Run =
#{
r
}
"
}
+
[
'}'
]
end
private
def
set_runs
if
valid_runtime?
self
.
runs
=
DEFAULT_RUNS
.
map
{
|
r
|
r
+
runtime
}
else
self
.
errors
.
add
(
:runtime
,
:not_valid_24h_time
)
false
end
end
def
valid_runtime?
runtime
&&
runtime
[
/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/
]
end
end
Event Timeline
Log In to Comment