lib/mutx/tasks/task.rb in mutx-0.1.24 vs lib/mutx/tasks/task.rb in mutx-0.1.25
- old
+ new
@@ -31,14 +31,15 @@
:subject,
:notifications,
:value_for_regex,
:regex,
:notify_on,
- :blocked
+ :blocked,
+ :blocked_stop
- REGEX_VALID_VALUES = ["failed","passed","none","warning"]
- NOTIFY_VALID_VALUES = ["any","warning","passed","failed"]
+ REGEX_VALID_VALUES = ["failed","passed","none"]
+ NOTIFY_VALID_VALUES = ["any","passed","failed"]
def self.valid_types
["task","test"]
end
@@ -64,10 +65,11 @@
@cron_time = task_data["cron_time"]
@mail = task_data["mail"]
@subject = task_data["subject"] || ""
@notifications = task_data["notifications"]
@blocked = task_data["blocked"]
+ @blocked_stop = task_data["blocked_stop"]
@last_exec_time = task_data["last_exec_time"]
@application = task_data["application"] || "command line"
@regex = task_data["regex"]
@value_for_regex = task_data["value_for_regex"]
@notify_on = task_data["notify_on"] || "any"
@@ -95,11 +97,13 @@
task_data = task_data.to_h if respond_to? :to_h
new(task_data) if task_data
end
def self.get_task_with name
- self.new(Mutx::Database::MongoConnector.task_data_for_name(name))
+ data = Mutx::Database::MongoConnector.task_data_for_name(name)
+ raise Mutx::Error::TaskNotFound, "Could not find data for task with name '#{name}'" if data.nil?
+ self.new(data)
end
def self.new_task(data)
Mutx::Support::Log.debug "Defining new task [#{data["name"]}]" if Mutx::Support::Log
@@ -118,10 +122,11 @@
"cron_time" => data["cron_time"],
"mail" => data["mail"],
"subject" => data["subject"],
"notifications" => data["notifications"],
"blocked" => data["blocked"],
+ "blocked_stop" => data["blocked_stop"],
"last_exec_time" => Time.now.utc,
"application" => data["application"],
"regex" => data["regex"],
"value_for_regex" => data["value_for_regex"],
"notify_on" => data["notify_on"]
@@ -247,9 +252,10 @@
"cronneable" => cronneable,
"mail" => mail,
"subject" => subject,
"notifications" => notifications,
"blocked" => blocked,
+ "blocked_stop" => blocked_stop,
"cron_time" => cron_time,
"last_exec_time" => last_exec_time,
"application" => application,
"regex" => regex,
"value_for_regex" => value_for_regex,
\ No newline at end of file