Sha256: 378de8977d4b7d3c74bb1bb5d06227194b74e201a244defe201615848442ba56

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

# External
require 'rubygems/user_interaction'

# Internal
require 'gem_newgem/newgem/template'

module GemNewgem
  class Newgem
    module Validations
      include Gem::UserInteraction # Methods alert, ask, ask_yes_no...

      def validate
        validate_gem_name
        validate_target_dir
        Template.ensure_default
        template.validate
      end

      private

      def validate_gem_name
        if gem_name.nil? || gem_name.empty?
          alert_error "Please specify a gem name on the command line (e.g. gem newgem GEMNAME)"
          terminate_interaction(1)
        end
      end

      def validate_target_dir
        if Dir.exists?(gem_name)
          alert_error "Directory #{gem_name} already exists! Remove first."
          terminate_interaction(1)
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gem-newgem-0.1.3 lib/gem_newgem/newgem/validations.rb
gem-newgem-0.1.2 lib/gem_newgem/newgem/validations.rb
gem-newgem-0.1.1 lib/gem_newgem/newgem/validations.rb
gem-newgem-0.1.0 lib/gem_newgem/newgem/validations.rb