Sha256: 47b0dfcb2ab3fcb17efadb4977bbe34c5e7be3ccd4f35441e347c0ecb00d2559

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

# 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

  SAVE_PATCH = "ooze_patch_update.json".freeze

  def main(session, options, usecase)
    super(session, options, usecase) do
      if method(:process_ooze).parameters.count.zero?
        ooze # retrieve ooze
        process_ooze
      else
        process_ooze(ooze)
      end

      yield(target) if block_given?

      exit_if_no_changes!
      update_ooze(target)
    end
  end

  def process_ooze(page = target)
    raise "You need to redefine this method"
  end

  private

  def ooze
    super(ooze_id, stage_id: stage_id)
  end

  def stage(stage_id_name = stage_id, ooze: target)
    super
  end

  def ooze_id
    options.dig(:source, :ooze_id)
  end

  def stage_id
    options.dig(:source, :stage_id)
  end

  def update_ooze(ooz = target)
    prompt_to_confirm!

    super
  end

  def exit_if_no_changes!
    return if !!patch_doc["page"]

    log(:info) { "No Changes!!" }
    exit(0)
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-3.0.20 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb