Class: New::Task
Overview
New::Task is the base class that all custom tasks need to inherit from
Constant Summary collapse
- @@tasks =
global tasks for task class with a getter
{}
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
INSTANCE METHODS.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
INSTANCE METHODS.
Class Method Summary collapse
-
.get_task_name(task_path) ⇒ Object
derive a task name from a task path.
- .tasks ⇒ Object
Instance Method Summary collapse
- #class_options ⇒ Object
-
#description ⇒ Object
getters/setters for task meta data stored temporarily on a class var.
-
#run_command(command) ⇒ Boolean
run a system command.
-
#validate ⇒ Object
validate all options.
-
#verify ⇒ Object
task to check that outside dependencies are met before we run the tasks since verify is not a required method, we define a blank one to prevent undefined method errors.
Methods included from Validation
validate_class, validate_option
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/new/task.rb', line 41 def name @name end |
#options ⇒ Object
INSTANCE METHODS
40 41 42 |
# File 'lib/new/task.rb', line 40 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
41 42 43 |
# File 'lib/new/task.rb', line 41 def path @path end |
#source ⇒ Object
INSTANCE METHODS
40 41 42 |
# File 'lib/new/task.rb', line 40 def source @source end |
Class Method Details
.get_task_name(task_path) ⇒ Object
derive a task name from a task path
18 19 20 |
# File 'lib/new/task.rb', line 18 def get_task_name task_path task_path.match(/([^\/]*)_task\.rb$/)[1].to_sym end |
.tasks ⇒ Object
13 |
# File 'lib/new/task.rb', line 13 def tasks; @@tasks; end |
Instance Method Details
#class_options ⇒ Object
48 49 50 |
# File 'lib/new/task.rb', line 48 def @class_options ||= self.class.class_variable_get :@@options rescue {} end |
#description ⇒ Object
getters/setters for task meta data stored temporarily on a class var
44 45 46 |
# File 'lib/new/task.rb', line 44 def description @description ||= self.class.class_variable_get :@@description rescue '' end |
#run_command(command) ⇒ Boolean
run a system command
74 75 76 77 78 79 80 |
# File 'lib/new/task.rb', line 74 def run_command command # if verbose, dont redirect output to null command += ' >> /dev/null 2>&1' unless New.verbose # run the command Kernel.system command end |
#validate ⇒ Object
validate all options
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/new/task.rb', line 59 def validate .keys.each do |option_name| option_settings = [option_name] option_value = @options[:task_options][option_name] new_option_value = New::Task.validate_option(option_name, option_settings, option_value) # set the new validated value @options[:task_options][option_name] = new_option_value end end |
#verify ⇒ Object
task to check that outside dependencies are met before we run the tasks since verify is not a required method, we define a blank one to prevent undefined method errors
55 |
# File 'lib/new/task.rb', line 55 def verify; end |