Sha256: 85b8270f44f5ed1ce9b9ddf28671f7b4c37f6015b9a30c881907c7235fffffeb

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

require "open3"

module Gemsmith
  module Aids
    # A convenience aid to the Gem::Specification object.
    class Spec
      def initialize specification: ::Gem::Specification, shell: Open3
        @specification = specification
        @shell = shell
      end

      def editor
        ENV["EDITOR"]
      end

      def open spec = nil
        return unless spec
        shell.capture2 editor, spec.full_gem_path
      end

      def read spec = nil
        return unless spec
        return if spec.homepage.nil? || spec.homepage.empty?

        shell.capture2 "open", spec.homepage
      end

      def find name, version
        specification.find_by_name name, version
      end

      def find_all name
        specification.find_all_by_name name
      end

      private

      attr_reader :specification, :shell
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-6.0.0 lib/gemsmith/aids/spec.rb