Sha256: 239cbd5c87cfb5dd82007b5ace944d2fbe9af4735360dc671efdc2c5307475db

Contents?: true

Size: 1.5 KB

Versions: 30

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'avm/eac_rails_base1/sources/base'
require 'avm/eac_redmine_base0/core_update'
require 'eac_cli/core_ext'

module Avm
  module EacRedmineBase0
    module Sources
      module Runners
        class CoreUpdate
          runner_with :help do
            arg_opt '-u', '--url', 'Core\'s package URL.'
            arg_opt '-v', '--version', 'Core\'s version.'
            desc 'Update instance\' core.'
          end

          def run
            start_banner
            validate
            update
          end

          private

          def start_banner
            infov 'URL', url
            infov 'Version', version
          end

          def update
            ::Avm::EacRedmineBase0::CoreUpdate.new(runner_context.call(:subject), version, url).run
          end

          def url
            parsed.url || url_by_version
          end

          def url_by_version
            parsed.version.if_present do |v|
              "https://www.redmine.org/releases/redmine-#{v}.tar.gz"
            end
          end

          def validate
            %w[url version].each do |attr|
              fatal_error "\"#{attr}\" is blank. See avaiable options." if send(attr).blank?
            end
          end

          def version
            parsed.version || version_by_url
          end

          def version_by_url
            parsed.url.if_present do |v|
              /(\d+.\d+.\d+)/.if_match(v, false) { |m| m[1] }
            end
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
eac_tools-0.30.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.29.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.28.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.27.2 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.27.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.14.0 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.27.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.26.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.13.0 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.25.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.25.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.24.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.24.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.12.0 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.23.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.22.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.21.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.20.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.19.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.18.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb