Sha256: 4ba41c7d3317d6a7233f1cb0e2f1d8360a1a38064aaf51e2449a9e61c82fb4df

Contents?: true

Size: 1.75 KB

Versions: 32

Compression:

Stored size: 1.75 KB

Contents

include Fulmar::Domain::Service::Helper::CommonHelper

namespace :versions do
  @versioned_servers = {}

  full_configuration[:environments].each_pair do |env, targets|
    next if env == :all

    targets.each_pair do |target, config|
      @versioned_servers["#{env}:#{target}"] = config if config[:type].to_s == 'rsync_with_versions'
    end
  end

  unless @versioned_servers.empty?

    @versioned_servers.each_key do |env|
      target_count = @versioned_servers.keys.reduce(0) { |a, e| e.split(':').first == env.split(':').first ? a + 1 : a }

      task_environment = (target_count > 1 ? env : env.split(':').first)

      namespace :list do
        # Count of there are multiple targets within the environment
        # if not, we can omit the target name in the task and shorten it a bit
        # This should apply for almost all cases.

        desc "List available versions for environment/target \"#{env}\""
        task task_environment do
          configuration.environment = env.split(':').first
          configuration.target = env.split(':').last
          file_sync.list_releases(false).each { |item| puts item }
        end
      end

      namespace :clean do
        desc "Delete obsolete versions for target \"#{env}\""
        task task_environment do
          configuration.environment = env.split(':').first
          configuration.target = env.split(':').last
          file_sync.cleanup
        end
      end

      namespace :revert do
        desc "Revert to the previous version for \"#{env}\""
        task task_environment do
          configuration.environment = env.split(':').first
          configuration.target = env.split(':').last
          error 'Cannot revert to previous version.' unless file_sync.revert
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
fulmar-1.10.1 lib/fulmar/domain/task/versions.rake
fulmar-1.10.0 lib/fulmar/domain/task/versions.rake
fulmar-1.9.2 lib/fulmar/domain/task/versions.rake
fulmar-1.9.1 lib/fulmar/domain/task/versions.rake
fulmar-1.9.0 lib/fulmar/domain/task/versions.rake
fulmar-1.8.15 lib/fulmar/domain/task/versions.rake
fulmar-1.8.14 lib/fulmar/domain/task/versions.rake
fulmar-1.8.13 lib/fulmar/domain/task/versions.rake
fulmar-1.8.12 lib/fulmar/domain/task/versions.rake
fulmar-1.8.11 lib/fulmar/domain/task/versions.rake
fulmar-1.8.10 lib/fulmar/domain/task/versions.rake
fulmar-1.8.9 lib/fulmar/domain/task/versions.rake
fulmar-1.8.8 lib/fulmar/domain/task/versions.rake
fulmar-1.8.7 lib/fulmar/domain/task/versions.rake
fulmar-1.8.6 lib/fulmar/domain/task/versions.rake
fulmar-1.8.5 lib/fulmar/domain/task/versions.rake
fulmar-1.8.4 lib/fulmar/domain/task/versions.rake
fulmar-1.8.3 lib/fulmar/domain/task/versions.rake
fulmar-1.8.2 lib/fulmar/domain/task/versions.rake
fulmar-1.8.1 lib/fulmar/domain/task/versions.rake