Class: Gemsmith::Aids::Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsmith/aids/spec.rb

Overview

A convenience aid to the Gem::Specification object.

Instance Method Summary collapse

Constructor Details

#initialize(specification: ::Gem::Specification, shell: Open3) ⇒ Spec

Returns a new instance of Spec.



7
8
9
10
# File 'lib/gemsmith/aids/spec.rb', line 7

def initialize specification: ::Gem::Specification, shell: Open3
  @specification = specification
  @shell = shell
end

Instance Method Details

#editorObject



12
13
14
# File 'lib/gemsmith/aids/spec.rb', line 12

def editor
  ENV["EDITOR"]
end

#find(name, version) ⇒ Object



28
29
30
# File 'lib/gemsmith/aids/spec.rb', line 28

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

#find_all(name) ⇒ Object



32
33
34
# File 'lib/gemsmith/aids/spec.rb', line 32

def find_all name
  specification.find_all_by_name name
end

#open(spec = nil) ⇒ Object



16
17
18
19
# File 'lib/gemsmith/aids/spec.rb', line 16

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

#read(spec = nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/gemsmith/aids/spec.rb', line 21

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

  shell.capture2 "open", spec.homepage
end