Sha256: 175c40442a037b8c0d87a96c35cacb02dc40265b3fb988f5e7c34058595c2cf3

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 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(/^.+?=/, '')
          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]
            logger.error "Option '#{opt} (-#{opt[0]})' required but not specified."
            exit 1
          end
        end

        if required.include? :environment
          unless Config.new.environments.keys.include? provided[:environment]
            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_stackster_exceptions_and_exit
        yield
      rescue Stackster::Exceptions::Base
        exit 1
      end

    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simple_deploy-0.7.2 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.2.beta.1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.1 lib/simple_deploy/cli/shared.rb
simple_deploy-0.7.0 lib/simple_deploy/cli/shared.rb
simple_deploy-0.6.7 lib/simple_deploy/cli/shared.rb
simple_deploy-0.6.6 lib/simple_deploy/cli/shared.rb
simple_deploy-0.6.5 lib/simple_deploy/cli/shared.rb