Sha256: 9247272d235813ce01942e05c553656bc9f28e34a7a596038355018d521e5569

Contents?: true

Size: 1.48 KB

Versions: 76

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require 'eac_cli/core_ext'
require 'avm/eac_rails_base1/instances/runners/code_runner'

module Avm
  module EacRedmineBase0
    module Instances
      module Runners
        class ProjectRename
          runner_with :help, ::Avm::EacRailsBase1::RunnerWith::Bundle do
            pos_arg :from
            pos_arg :to
          end

          def run
            bundle_run
          end

          def start_banner
            infov 'From', from
            infov 'To', to
          end

          delegate :from, :to, to: :parsed

          def bundle_args
            %w[exec rails runner] + [code]
          end

          def code
            <<~CODE
              from_arg = '#{from}'
              to_arg = '#{to}'
              project = ::Project.where(identifier: from_arg).first
              if project.present?
                puts "Project found: \#{project}"
                puts "Renaming..."
                project.update_column(:identifier, to_arg)
                puts "Renamed. Testing..."
                project = ::Project.where(identifier: to_arg).first
                if project
                  puts "Project found: \#{project}"
                else
                  fail "After rename: project not found with identifier \\"\#{to_arg}\\""
                end
              else
                fail "Before rename: project not found with identifier \\"\#{from_arg}\\""
              end
            CODE
          end
        end
      end
    end
  end
end

Version data entries

76 entries across 76 versions & 2 rubygems

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