Sha256: ef4205dca20676cb6ffbd14948ab1cc04d4cda6f40b3c237b62ef6095d662eae
Contents?: true
Size: 993 Bytes
Versions: 2
Compression:
Stored size: 993 Bytes
Contents
module OpenGem module CommonOptions def add_command_option(description=nil) add_option('-c', '--command COMMAND', description || 'Execute command at path of the rubygem') do |value, options| options[:command] = value end end def add_latest_version_option add_option('-l', '--latest', 'If there are multiple versions, open the latest') do |value, options| options[:latest] = true end end def get_spec(name) dep = Gem::Dependency.new name, options[:version] specs = Gem.source_index.search(dep).select{|spec| spec.has_rdoc?} if specs.length == 0 say "Could not find docs for '#{name}'" return nil elsif specs.length == 1 || options[:latest] return specs.last else choices = specs.map{|s|"#{s.name} #{s.version}"} c,i = choose_from_list "Open which gem?", choices return specs[i] if i end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
adamsanderson-open_gem-1.3.0 | lib/open_gem/common_options.rb |
open_gem-1.3.0 | lib/open_gem/common_options.rb |