Sha256: a2e91f6b721027ac8a3026f4e9fe4bafbca380fdc440cb19795a146cc7c25a21

Contents?: true

Size: 1.53 KB

Versions: 105

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

require 'avm/eac_rails_base1/sources/base'
require 'avm/eac_redmine_base0/sources/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::Sources::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

105 entries across 105 versions & 2 rubygems

Version Path
avm-eac_redmine_base0-0.22.3 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.91.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.22.2 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.87.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.22.1 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.86.11 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.83.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.82.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.81.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.22.0 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.80.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.21.2 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.79.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.21.1 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.78.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.77.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.77.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.76.1 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb
avm-eac_redmine_base0-0.21.0 lib/avm/eac_redmine_base0/sources/runners/core_update.rb
eac_tools-0.76.0 sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/core_update.rb