Sha256: 6425cc08468f88fb3a9a5fcab7807438608ce0d1eb888b445011e70f2c23e647

Contents?: true

Size: 1.2 KB

Versions: 18

Compression:

Stored size: 1.2 KB

Contents

module SimpleDeploy
  module CLI

    module Shared

      def parse_attributes(args)
        attributes = args[:attributes]
        attrs      = []

        attributes.each do |attribs|
          key   = attribs.split('=').first.gsub(/\s+/, "")
          value = attribs.gsub(/^.+?=/, '')
          SimpleDeploy.logger.info "Read #{key}=#{value}"
          attrs << { key => value }
        end
        attrs
      end

      def valid_options?(args)
        provided = args[:provided]
        required = args[:required]

        required.each do |opt|
          unless provided[opt]
            SimpleDeploy.logger.error "Option '#{opt} (-#{opt[0]})' required but not specified."
            exit 1
          end
        end

        if required.include? :environment
          unless SimpleDeploy.environments.keys.include? provided[:environment]
            SimpleDeploy.logger.error "Environment '#{provided[:environment]}' does not exist."
            exit 1
          end
        end
      end

      def command_name
        self.class.name.split('::').last.downcase
      end

      def rescue_exceptions_and_exit
        yield
      rescue SimpleDeploy::Exceptions::Base
        exit 1
      end

    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
simple_deploy-0.9.2 lib/simple_deploy/cli/shared.rb
simple_deploy-0.9.1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.9.0 lib/simple_deploy/cli/shared.rb
simple_deploy-0.8.2 lib/simple_deploy/cli/shared.rb
simple_deploy-0.8.2.beta1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.8.1.beta1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.8.0 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.8 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.7 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.7.beta.1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.6 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.6.beta.6 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.6.beta.5 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.6.beta.3 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.6.beta.1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.5 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.4 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.3 lib/simple_deploy/cli/shared.rb