lib/howzit/task.rb in howzit-2.0.34 vs lib/howzit/task.rb in howzit-2.1.0

- old
+ new

@@ -1,11 +1,11 @@ # frozen_string_literal: true module Howzit # Task object class Task - attr_reader :type, :title, :action, :parent, :optional, :default + attr_reader :type, :title, :action, :arguments, :parent, :optional, :default ## ## Initialize a Task object ## ## @param attributes [Hash] the task attributes @@ -19,26 +19,29 @@ ## @option attributes :action [String] task action ## @option attributes :parent [String] title of nested (included) topic origin def initialize(attributes, optional: false, default: true) @prefix = "{bw}\u{25B7}\u{25B7} {x}" # arrow = "{bw}\u{279F}{x}" + @arguments = attributes[:arguments] || [] @type = attributes[:type] || :run @title = attributes[:title] || nil - @action = attributes[:action].render_arguments || nil @parent = attributes[:parent] || nil + + @action = attributes[:action].render_arguments || nil + @optional = optional @default = default end ## ## Inspect ## ## @return [String] description ## def inspect - %(<#Howzit::Task @type=:#{@type} @title="#{@title}" @block?=#{@action.split(/\n/).count > 1}>) + %(<#Howzit::Task @type=:#{@type} @title="#{@title}" @arguments=#{@arguments} @block?=#{@action.split(/\n/).count > 1}>) end ## ## Output string representation ## @@ -73,11 +76,13 @@ ## ## @return [Array] [[Array] output, [Integer] number of tasks executed] ## def run_include output = [] - matches = Howzit.buildnote.find_topic(@action) - raise "Topic not found: #{@action}" if matches.empty? + action = @action + + matches = Howzit.buildnote.find_topic(action) + raise "Topic not found: #{action}" if matches.empty? Howzit.console.info("#{@prefix}{by}Running tasks from {bw}#{matches[0].title}{x}".c) output.concat(matches[0].run(nested: true)) Howzit.console.info("{by}End include: #{matches[0].tasks.count} tasks{x}".c) [output, matches[0].tasks.count]