Class: Webbynode::Commands::Tasks
- Inherits:
-
Webbynode::Command
- Object
- Webbynode::Command
- Webbynode::Commands::Tasks
- Defined in:
- lib/webbynode/commands/tasks.rb
Constant Summary collapse
- TasksPath =
Constants Paths to the webbynode task files
".webbynode/tasks"
- BeforePushTasksFile =
".webbynode/tasks/before_push"
- AfterPushTasksFile =
".webbynode/tasks/after_push"
Constants inherited from Webbynode::Command
Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#command ⇒ Object
Returns the value of attribute command.
-
#session_file ⇒ Object
Returns the value of attribute session_file.
-
#session_tasks ⇒ Object
Returns the value of attribute session_tasks.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#ensure_tasks_folder ⇒ Object
Ensures the presence of the .webbynode/tasks folder Will create the necessary task files when they are not available.
- #execute ⇒ Object
-
#has_tasks? ⇒ Boolean
Checks to see if the session_tasks has any tasks.
-
#initialize(*args) ⇒ Tasks
constructor
A new instance of Tasks.
-
#read_tasks(file) ⇒ Object
Reads the tasks straight from the specified file and stores them inside (in order) the session_tasks method.
Methods inherited from Webbynode::Command
add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?
Constructor Details
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/webbynode/commands/tasks.rb', line 5 def action @action end |
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/webbynode/commands/tasks.rb', line 5 def command @command end |
#session_file ⇒ Object
Returns the value of attribute session_file.
5 6 7 |
# File 'lib/webbynode/commands/tasks.rb', line 5 def session_file @session_file end |
#session_tasks ⇒ Object
Returns the value of attribute session_tasks.
5 6 7 |
# File 'lib/webbynode/commands/tasks.rb', line 5 def session_tasks @session_tasks end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/webbynode/commands/tasks.rb', line 5 def type @type end |
Instance Method Details
#ensure_tasks_folder ⇒ Object
Ensures the presence of the .webbynode/tasks folder Will create the necessary task files when they are not available
60 61 62 63 64 65 |
# File 'lib/webbynode/commands/tasks.rb', line 60 def ensure_tasks_folder io.mkdir('.webbynode/tasks') unless io.directory?(".webbynode/tasks") %w[before_push after_push].each do |file| io.exec("touch .webbynode/tasks/#{file}") unless io.file_exists?(".webbynode/tasks/#{file}") end end |
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webbynode/commands/tasks.rb', line 23 def execute # Ensures that the tasks folder (.webbynode/tasks) is present # Will create the task files if they are not present ensure_tasks_folder # Should parse the parameters parse_parameters # Sets the current path, extracted from @type set_session_file # Reads out the currently set tasks read_tasks(session_file) # Initializes either [add], [remove] or [show] depending on user input send(action) end |
#has_tasks? ⇒ Boolean
Checks to see if the session_tasks has any tasks
44 45 46 47 |
# File 'lib/webbynode/commands/tasks.rb', line 44 def has_tasks? return true unless session_tasks.empty? false end |
#read_tasks(file) ⇒ Object
Reads the tasks straight from the specified file and stores them inside (in order) the session_tasks method.
51 52 53 54 55 56 |
# File 'lib/webbynode/commands/tasks.rb', line 51 def read_tasks(file) @session_tasks = [] io.read_file(file).each_line do |line| @session_tasks << line.gsub(/\n/,'') unless line.blank? end end |