Sha256: 0f28601699acb3ab86a6d1c4f86814afc384e03ae62b6e5552d7a32e807c6522

Contents?: true

Size: 1.35 KB

Versions: 40

Compression:

Stored size: 1.35 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"

  def main(session, options, usecase)
    super(session, options, usecase) do
      if method(:process_ooze).parameters.count == 0
        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(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(ooz = target)
    prompt_to_confirm!
    super(ooz)
  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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
eco-helpers-2.4.9 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.8 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.7 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.6 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.5 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.4 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.3 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.4.2 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.3.3 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.3.2 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.2.5 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.2.4 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.2.3 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.2.2 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.2.1 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.1.12 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.1.11 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.1.10 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.1.9 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb
eco-helpers-2.1.8 lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb