Class: Winever::CronEntry
- Inherits:
-
Object
- Object
- Winever::CronEntry
- Defined in:
- lib/winever/cron_entry.rb
Instance Attribute Summary collapse
-
#cron_line ⇒ Object
Returns the value of attribute cron_line.
-
#cron_time ⇒ Object
Returns the value of attribute cron_time.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#task_folder ⇒ Object
Returns the value of attribute task_folder.
-
#task_name ⇒ Object
Returns the value of attribute task_name.
-
#working_directory ⇒ Object
Returns the value of attribute working_directory.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cron_line) ⇒ CronEntry
constructor
A new instance of CronEntry.
- #invalid_reason ⇒ Object
- #triggers ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(cron_line) ⇒ CronEntry
Returns a new instance of CronEntry.
11 12 13 14 15 16 |
# File 'lib/winever/cron_entry.rb', line 11 def initialize(cron_line) @cron_line = cron_line @cron_parts = cron_line.split("|", 5) cron_time_string, @task_folder, @task_name, @working_directory, @parameters = @cron_parts @cron_time = Winever::CronTime.new(cron_time_string) end |
Instance Attribute Details
#cron_line ⇒ Object
Returns the value of attribute cron_line.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def cron_line @cron_line end |
#cron_time ⇒ Object
Returns the value of attribute cron_time.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def cron_time @cron_time end |
#parameters ⇒ Object
Returns the value of attribute parameters.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def parameters @parameters end |
#task_folder ⇒ Object
Returns the value of attribute task_folder.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def task_folder @task_folder end |
#task_name ⇒ Object
Returns the value of attribute task_name.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def task_name @task_name end |
#working_directory ⇒ Object
Returns the value of attribute working_directory.
3 4 5 |
# File 'lib/winever/cron_entry.rb', line 3 def working_directory @working_directory end |
Class Method Details
.from_cron_output(cron_output, include_invalid = false) ⇒ Object
5 6 7 8 9 |
# File 'lib/winever/cron_entry.rb', line 5 def self.from_cron_output cron_output, include_invalid=false entries = cron_output.split("\n").reject(&:empty?).map{|o| new(o)} entries = entries.select(&:valid?) unless include_invalid entries end |
Instance Method Details
#invalid_reason ⇒ Object
26 27 28 29 30 31 |
# File 'lib/winever/cron_entry.rb', line 26 def invalid_reason return "Doesn't match the Winever format" unless @cron_parts.length == 5 return "Doesn't have a task_name specified" if @task_name.nil? || @task_name.empty? return "Problem with schedule: #{@cron_time.unsupported_reason}" unless @cron_time.supported? nil end |
#triggers ⇒ Object
18 19 20 |
# File 'lib/winever/cron_entry.rb', line 18 def triggers @cron_time.triggers end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/winever/cron_entry.rb', line 22 def valid? invalid_reason.nil? end |