Sha256: b592cb1dc232526df6aa26cdf9cc7f92a26375b45716395f349ccb5e41e090ac

Contents?: true

Size: 921 Bytes

Versions: 7

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

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
        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
        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

7 entries across 7 versions & 1 rubygems

Version Path
gemsmith-7.6.0 lib/gemsmith/aids/spec.rb
gemsmith-7.5.0 lib/gemsmith/aids/spec.rb
gemsmith-7.4.0 lib/gemsmith/aids/spec.rb
gemsmith-7.3.0 lib/gemsmith/aids/spec.rb
gemsmith-7.2.0 lib/gemsmith/aids/spec.rb
gemsmith-7.1.0 lib/gemsmith/aids/spec.rb
gemsmith-7.0.0 lib/gemsmith/aids/spec.rb