Sha256: 8c209e4b7fcc992e378a01d1413345c0838b0681063ad6ef5192d45ea355f68c

Contents?: true

Size: 1.86 KB

Versions: 44

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true

require 'eac_launcher/instances/runner_helper'

module Avm
  module Tools
    class Runner < ::EacRubyUtils::Console::DocoptRunner
      class Launcher < ::EacRubyUtils::Console::DocoptRunner
        class Publish < ::EacLauncher::Instances::RunnerHelper
          DOC = <<~DOCOPT
            Publica projetos ou instâncias.

            Usage:
              __PROGRAM__ [options] [<instance_path>...]
              __PROGRAM__ -h | --help

            Options:
              -h --help             Show this screen.
              --new                 Publish projects not published before.
              -s --stereotype=<st>  Publish only for stereotype <stereotype>.
              --all            Publish all instances.
              -d --dry-run          "Dry run" publishing.
              --pending             Publish only pending.
              --recache             Rewrite instances cache.
              --run                 Confirm publishing.

          DOCOPT

          def run
            ::EacLauncher::Context.current.recache = options['--recache']
            build_publish_options
            instances.each do |i|
              next unless i.options.publishable?

              i.send(instance_method)
            end
          end

          private

          def dry_run?
            options.fetch('--dry-run')
          end

          def instance_method
            run? || dry_run? ? 'publish_run' : 'publish_check'
          end

          def build_publish_options
            ::EacLauncher::Context.current.publish_options = publish_options
          end

          def publish_options
            { new: options.fetch('--new'), stereotype: options.fetch('--stereotype'),
              confirm: run? }
          end

          def run?
            options.fetch('--run') && !dry_run?
          end
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
avm-tools-0.62.0 lib/avm/tools/runner/launcher/publish.rb
avm-tools-0.61.0 lib/avm/tools/runner/launcher/publish.rb
avm-tools-0.60.0 lib/avm/tools/runner/launcher/publish.rb
avm-tools-0.59.0 lib/avm/tools/runner/launcher/publish.rb