Sha256: 5a730e0f408900b17538ef1d56354077b68e7c70294ed5cec59801426c017e93

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'forwardable'

module Gem
  module Release
    module Helper
      extend Forwardable
      def_delegators :context, :gem, :system
      def_delegators :system, :git_clean?, :git_remotes, :git_tags,
        :git_user_name, :git_user_email, :github_user_name

      def run(cmd)
        return true if send(cmd)
      end

      def cmd(cmd, *args)
        if cmd.is_a?(Symbol)
          info cmd, *args
          cmd = self.class::CMDS[cmd] % args
        end
        cmd = cmd.strip
        notice "$ #{cmd}"
        result = pretend? ? true : system.run(cmd)
        abort "The command `#{cmd}` was unsuccessful." unless result
      end

      def gem_cmd(cmd, *args)
        info cmd, *args if cmd.is_a?(Symbol)
        notice "$ gem #{cmd} #{args.join(' ')}"
        pretend? ? true : system.gem_cmd(cmd, *args)
      end

      %w(announce notice info warn error).each do |level|
        define_method(level) do |msg, *args|
          msg = self.class::MSGS[msg] % args if msg.is_a?(Symbol)
          context.send(level, msg.strip) unless quiet?
        end
      end

      def abort(msg, *args)
        msg = self.class::MSGS[msg] % args if msg.is_a?(Symbol)
        msg = "#{msg} Aborting."
        context.abort(msg)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gem-release-2.0.0.dev.5 lib/gem/release/helper.rb