Sha256: 69fb3bdf1ed156b3c91d013f7b198dd902fd4cd221ab8fd6dd1aec10af63a364

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

module Rip
  module Sh
    module Gem
      extend self

      def check?
        `which #{gembin}`.strip.any?
      end

      def rgem(command)
        Timeout.timeout(30) do
          `#{gembin} #{command} 2> /dev/null`
        end
      rescue Timeout::Error
        ''
      end

      def dependencies(name)
        if rgem("dependency #{name} --remote") =~ /(Gem #{name}-.*?)(Gem|\z)/m
          $1.split("\n").grep(/runtime\s*\)/).map do |line|
            line =~ /([\w-]+)\s*\([~><=]+\s*((?:\d+\.?)+\d+|\d)/
            source, version = $1, $2
            if source
              Package.for(source, version)
            else
              nil
            end
          end.compact
        else
          []
        end
      end

      def gembin
        ENV['GEMBIN'] || 'gem'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rip-0.0.4 lib/rip/sh/gem.rb
rip-0.0.5 lib/rip/sh/gem.rb