# Base class to run a script against a single ooze. class Eco::API::UseCases::OozeSamples::OozeRunBaseCase < Eco::API::UseCases::OozeSamples::OozeBaseCase name "ooze-run-base" type :other attr_reader :session, :options, :usecase SAVE_PATCH = "ooze_patch_update.json" def main(session, options, usecase, &block) raise "You need to inherit from this class and call super with a block" unless block @session = session; @options = options; @usecase = usecase process_ooze(&block) end def process_ooze(ooze = target) raise "You need to inherit from this class and call super with a block" unless block_given? super(ooze) do yield(ooze) exit_if_no_changes! end end private def ooze super(ooze_id, stage_id: stage_id) end def stage(stage_id_name = stage_id, ooze: target) super(stage_id_name, ooze: ooze) end def ooze_id options.dig(:source, :ooze_id) end def stage_id options.dig(:source, :stage_id) end def update_ooze prompt_to_confirm! super end def exit_if_no_changes! unless changes = !!patch_doc["page"] logger.warn "No Changes!!" exit(0) end end def prompt_to_confirm! micro.prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response| exit(1) unless response.upcase.start_with?("Y") end end end